From 5e6290f5c52d8dcaf517ee8be6ec5f645383e983 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Wed, 10 Sep 2025 20:37:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(system/user)=EF=BC=9A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E7=A7=9F=E6=88=B7=E7=9A=84=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E7=94=A8=E6=88=B7=E8=A7=92=E8=89=B2=E5=9B=9E=E6=98=BE?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/impl/RoleServiceImpl.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/continew-system/src/main/java/top/continew/admin/system/service/impl/RoleServiceImpl.java b/continew-system/src/main/java/top/continew/admin/system/service/impl/RoleServiceImpl.java index 8a6a0941..7ff97946 100644 --- a/continew-system/src/main/java/top/continew/admin/system/service/impl/RoleServiceImpl.java +++ b/continew-system/src/main/java/top/continew/admin/system/service/impl/RoleServiceImpl.java @@ -16,7 +16,6 @@ package top.continew.admin.system.service.impl; -import cn.dev33.satoken.stp.StpUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import com.alicp.jetcache.anno.CacheInvalidate; @@ -36,8 +35,8 @@ import top.continew.admin.system.constant.SystemConstants; import top.continew.admin.system.mapper.RoleMapper; import top.continew.admin.system.model.entity.RoleDO; import top.continew.admin.system.model.query.RoleQuery; -import top.continew.admin.system.model.req.RoleReq; import top.continew.admin.system.model.req.RolePermissionUpdateReq; +import top.continew.admin.system.model.req.RoleReq; import top.continew.admin.system.model.resp.MenuResp; import top.continew.admin.system.model.resp.role.RoleDetailResp; import top.continew.admin.system.model.resp.role.RoleResp; @@ -51,7 +50,6 @@ import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; /** * 角色业务实现 @@ -137,13 +135,10 @@ public class RoleServiceImpl extends BaseServiceImpl dict(RoleQuery query, SortQuery sortQuery) { - List currentUserRoleCodes = StpUtil.getRoleList(); - final List superRoleCodes = RoleCodeEnum.getSuperRoleCodes(); - // dict查询的时候,需要查询当前用户拥有的角色而不是排除,避免前端显示角色数字而不是角色名称 - final List excludeRoleCodes = superRoleCodes.stream() - .filter(roleCode -> !currentUserRoleCodes.contains(roleCode)) - .collect(Collectors.toList()); - query.setExcludeRoleCodes(CollUtil.defaultIfEmpty(excludeRoleCodes, superRoleCodes)); + boolean isTenantAdmin = UserContextHolder.isTenantAdmin(); + query.setExcludeRoleCodes(isTenantAdmin + ? List.of(RoleCodeEnum.SUPER_ADMIN.getCode()) + : RoleCodeEnum.getSuperRoleCodes()); return super.dict(query, sortQuery); }