|
@@ -84,7 +84,7 @@ public class RoleServiceImpl implements RoleService {
|
|
|
@Override
|
|
|
@Cacheable(key = "'id:' + #p0")
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public RoleDto findById(String id) {
|
|
|
+ public RoleDto findById(Long id) {
|
|
|
Role role = roleRepository.findById(id).orElseGet(Role::new);
|
|
|
ValidationUtil.isNull(role.getId(), "Role", "id", id);
|
|
|
return roleMapper.toDto(role);
|
|
@@ -151,8 +151,8 @@ public class RoleServiceImpl implements RoleService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void delete(Set<String> ids) {
|
|
|
- for (String id : ids) {
|
|
|
+ public void delete(Set<Long> ids) {
|
|
|
+ for (Long id : ids) {
|
|
|
// 更新相关缓存
|
|
|
delCaches(id, null);
|
|
|
}
|
|
@@ -209,7 +209,7 @@ public class RoleServiceImpl implements RoleService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void verification(Set<String> ids) {
|
|
|
+ public void verification(Set<Long> ids) {
|
|
|
if (userRepository.countByRoles(ids) > 0) {
|
|
|
throw new BadRequestException("所选角色存在用户关联,请解除关联再试!");
|
|
|
}
|
|
@@ -224,14 +224,14 @@ public class RoleServiceImpl implements RoleService {
|
|
|
* 清理缓存
|
|
|
* @param id /
|
|
|
*/
|
|
|
- public void delCaches(String id, List<User> users) {
|
|
|
+ public void delCaches(Long id, List<User> users) {
|
|
|
users = CollectionUtil.isEmpty(users) ? userRepository.findByRoleId(id) : users;
|
|
|
if (CollectionUtil.isNotEmpty(users)) {
|
|
|
users.forEach(item -> userCacheClean.cleanUserCache(item.getUsername()));
|
|
|
Set<String> userIds = users.stream().map(User::getId).collect(Collectors.toSet());
|
|
|
- redisUtils.delByKeys(CacheKey.DATA_USER, userIds);
|
|
|
- redisUtils.delByKeys(CacheKey.MENU_USER, userIds);
|
|
|
- redisUtils.delByKeys(CacheKey.ROLE_AUTH, userIds);
|
|
|
+ redisUtils.delByKeysString(CacheKey.DATA_USER, userIds);
|
|
|
+ redisUtils.delByKeysString(CacheKey.MENU_USER, userIds);
|
|
|
+ redisUtils.delByKeysString(CacheKey.ROLE_AUTH, userIds);
|
|
|
}
|
|
|
redisUtils.del(CacheKey.ROLE_ID + id);
|
|
|
}
|