mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-03-08 07:41:09 +08:00
fix 修复 移除超级管理员角色后新增角色分配校验,避免无角色分配时报错
This commit is contained in:
@@ -497,6 +497,11 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
roleList.remove(SystemConstants.SUPER_ADMIN_ID);
|
||||
}
|
||||
|
||||
// 移除超管角色后若无剩余角色,说明仅选了超管角色且不允许分配,显式报错
|
||||
if (roleList.isEmpty()) {
|
||||
throw new ServiceException("不允许为普通用户分配超级管理员角色,请至少选择一个其他角色");
|
||||
}
|
||||
|
||||
// 校验是否有权限访问这些角色(含数据权限控制)
|
||||
if (roleMapper.selectRoleCount(roleList) != roleList.size()) {
|
||||
throw new ServiceException("没有权限访问角色的数据");
|
||||
|
||||
Reference in New Issue
Block a user