mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、还原超管myabtis-plus自动塞入organId;
2、修复修改菜单权限,角色权限,用户权限没有立刻生效的问题;
This commit is contained in:
+16
-3
@@ -192,6 +192,12 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
// 角色菜单权限发生修改,通知刷新本地缓存
|
||||
if (CollectionUtil.isNotEmpty(createMenuIds) || CollectionUtil.isNotEmpty(deleteMenuIds)) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
// 获取新增和删除菜单id的并集
|
||||
Collection<Long> delKeys = CollUtil.union(createMenuIds, deleteMenuIds);
|
||||
delKeys.forEach(menuId -> {
|
||||
// 移除redis中的缓存
|
||||
redisTemplate.delete(String.format(String.valueOf(new StringBuffer(RedisKeyConstants.USER_ROLE_ID_LIST).append(":%s:%s")), organId, menuId));
|
||||
});
|
||||
redisTemplate.convertAndSend(RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, "");
|
||||
}).exceptionally(e -> {
|
||||
log.error("redis message发送失败, topic:{}, 异常:{}", RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, e.getMessage());
|
||||
@@ -288,7 +294,7 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
throw new ServiceException(ErrorCodeConstants.ROLE_NOT_SUPERADMIN_NO_ORGAN_ID_OPER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
final Long finalOrganId = organId;
|
||||
Long roleId = reqVO.getRoleId();
|
||||
// 当前用户不能操作含有自己的角色
|
||||
if (CollectionUtil.isNotEmpty(userIds)) {
|
||||
@@ -307,7 +313,6 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
// 筛选要新增的userRole:前端有,数据库没有
|
||||
Collection<Long> createRoleUserIds = CollUtil.subtract(userIds, roleUserIds);
|
||||
if (!CollectionUtil.isEmpty(createRoleUserIds)) {
|
||||
Long finalOrganId = organId;
|
||||
userRoleMapper.insertBatch(CollectionUtils.convertList(createRoleUserIds, userId -> {
|
||||
UserRoleDO entity = new UserRoleDO();
|
||||
entity.setUserId(userId).setRoleId(roleId).setOrganId(finalOrganId);
|
||||
@@ -324,6 +329,12 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
// 角色菜单权限发生修改,通知刷新本地缓存
|
||||
if (CollectionUtil.isNotEmpty(createRoleUserIds) || CollectionUtil.isNotEmpty(deleteRoleUserIds)) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
// 获取新增和删除用户id的并集
|
||||
Collection<Long> delKeys = CollUtil.union(createRoleUserIds, deleteRoleUserIds);
|
||||
delKeys.forEach(userId -> {
|
||||
// 移除redis中的缓存
|
||||
redisTemplate.delete(String.format(String.valueOf(new StringBuffer(RedisKeyConstants.USER_ROLE_ID_LIST).append(":%s:%s")), finalOrganId, userId));
|
||||
});
|
||||
redisTemplate.convertAndSend(RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, "");
|
||||
}).exceptionally(e -> {
|
||||
log.error("redis message发送失败, topic:{}, 异常:{}", RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, e.getMessage());
|
||||
@@ -404,9 +415,11 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
// 角色菜单权限发生修改,通知刷新本地缓存
|
||||
if (CollectionUtil.isNotEmpty(createRoleIds) || CollectionUtil.isNotEmpty(deleteMenuIds)) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
// 移除redis中的缓存
|
||||
redisTemplate.delete(String.format(String.valueOf(new StringBuffer(RedisKeyConstants.USER_ROLE_ID_LIST).append(":%s:%s")), organId, userId));
|
||||
redisTemplate.convertAndSend(RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, "");
|
||||
}).exceptionally(e -> {
|
||||
log.error("redis message发送失败, topic:{}, 异常:{}", RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, e.getMessage());
|
||||
log.error("redis 清空user_role_ids或message发送失败, topic:{}, 异常:{}", RedisRefreshChannelTopicConstants.PERMISSION_REFRESH, e.getMessage());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user