模块权限修订,超管权限
This commit is contained in:
@@ -76,9 +76,9 @@ public class UserController {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Integer effectiveGroupId = resolveEffectiveGroupId(userId, schId);
|
||||
if (effectiveGroupId == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// 注意:超管即使没有学校/归属组,service.findUserPermissionTree 内部也会走超管短路返回全部权限,
|
||||
// 因此这里不能因 effectiveGroupId 为 null 直接返回空,否则超管在 oapi/user/modules 永远拿不到权限;
|
||||
// 普通用户无组/无学校时,findUserPermissionTree 同样会返回空列表,行为一致。
|
||||
List<UserPermissionCategoryVo> tree = groupAuthzService.findUserPermissionTree(effectiveGroupId, userId);
|
||||
if (tree == null || tree.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -1188,6 +1188,12 @@ public class GroupAuthzService implements IGroupAuthzService {
|
||||
public boolean hasModulePermission(Integer userId, Integer moduleId) {
|
||||
Objects.requireNonNull(userId, "用户ID不能为空");
|
||||
Objects.requireNonNull(moduleId, "模块ID不能为空");
|
||||
// 超级管理员(UserTypeEnum.SUPER_ADMIN / 基石账号):直接赋予全部模块权限,
|
||||
// 不做任何组/角色/继承判定——避免「超管不归属任何组 → userRels 为空 → 直接返回 false(即无任何权限)」的 bug。
|
||||
SysUser user = sysUserRepository.findById(userId).orElse(null);
|
||||
if (user != null && isSuperAdmin(user.getType(), userId)) {
|
||||
return true;
|
||||
}
|
||||
AppModule module = appModuleRepository.findById(moduleId).orElse(null);
|
||||
if (module == null) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user