【底座】修复 #IJZRLG 当修改“按钮授权”后,用户需要退出后重新登录才能生效

This commit is contained in:
xuyuxiang
2026-07-09 00:26:28 +08:00
parent 0dd90656b5
commit e5b4ea83a5
3 changed files with 23 additions and 1 deletions
@@ -107,6 +107,9 @@ public class SysRoleApiProvider implements SysRoleApi {
.eq(SysRelation::getCategory, SysRelationCategoryEnum.SYS_ROLE_HAS_RESOURCE.getValue()).notIn(SysRelation::getTargetId, existMenuIdList));
}
sysRelationService.saveRelationBatchWithAppend(superAdminRoleId, menuIdList, SysRelationCategoryEnum.SYS_ROLE_HAS_RESOURCE.getValue(), extJsonList);
// 刷新拥有该角色的所有在线用户的权限缓存
sysRoleService.refreshRoleLoginUserCache(superAdminRoleId);
}
@Transactional(rollbackFor = Exception.class)
@@ -152,6 +152,14 @@ public interface SysRoleService extends IService<SysRole> {
**/
void grantUser(SysRoleGrantUserParam sysRoleGrantUserParam);
/**
* 刷新拥有该角色的所有在线用户的权限缓存
*
* @author xuyuxiang
* @date 2022/4/29 10:12
**/
void refreshRoleLoginUserCache(String roleId);
/* ====角色部分所需要用到的选择器==== */
/**
@@ -275,6 +275,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
.map(JSONUtil::toJsonStr).collect(Collectors.toList());
sysRelationService.saveRelationBatchWithClear(id, menuIdList, SysRelationCategoryEnum.SYS_ROLE_HAS_RESOURCE.getValue(),
extJsonList);
// 刷新拥有该角色的所有在线用户的权限缓存
this.refreshRoleLoginUserCache(id);
}
@Override
@@ -296,6 +299,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
.map(JSONUtil::toJsonStr).collect(Collectors.toList());
sysRelationService.saveRelationBatchWithClear(id, menuIdList, SysRelationCategoryEnum.SYS_ROLE_HAS_MOBILE_MENU.getValue(),
extJsonList);
// 刷新拥有该角色的所有在线用户的权限缓存
this.refreshRoleLoginUserCache(id);
}
@Override
@@ -333,8 +339,13 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
sysRelationService.saveRelationBatchWithAppend(id, apiUrlList, SysRelationCategoryEnum.SYS_ROLE_HAS_PERMISSION.getValue(),
extJsonList);
// 刷新拥有该角色的所有在线用户的权限缓存
this.refreshRoleLoginUserCache(id);
}
@Override
public void refreshRoleLoginUserCache(String roleId) {
List<String> userIdList = sysRelationService.getRelationObjectIdListByTargetIdAndCategory(
id, SysRelationCategoryEnum.SYS_USER_HAS_ROLE.getValue());
roleId, SysRelationCategoryEnum.SYS_USER_HAS_ROLE.getValue());
userIdList.forEach(loginUserApi::refreshOnlineUserPermission);
}