From 30fbfb61432e254305d447802cc5e85d9c63c861 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 27 May 2022 20:10:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E7=9A=84=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=9C=AA=E5=88=86=E9=85=8D=E8=A7=92=E8=89=B2=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=87=AA=E5=B7=B1=E4=BF=A1=E6=81=AF=E5=9B=9E?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/permission/PermissionServiceImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java index 9c71e8bdb..775c89b58 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java @@ -458,13 +458,16 @@ public class PermissionServiceImpl implements PermissionService { @DataPermission(enable = false) // 关闭数据权限,不然就会出现递归获取数据权限的问题 @TenantIgnore // 忽略多租户的自动过滤。如果不忽略,会导致添加租户时,因为切换租户,导致获取不到 User。即使忽略,本身该方法不存在跨租户的操作,不会存在问题。 public DeptDataPermissionRespDTO getDeptDataPermission(Long userId) { - DeptDataPermissionRespDTO result = new DeptDataPermissionRespDTO(); // 获得用户的角色 Set roleIds = getUserRoleIdsFromCache(userId, singleton(CommonStatusEnum.ENABLE.getStatus())); + // 如果角色为空,则只能查看自己 + DeptDataPermissionRespDTO result = new DeptDataPermissionRespDTO(); if (CollUtil.isEmpty(roleIds)) { + result.setSelf(true); return result; } List roles = roleService.getRolesFromCache(roleIds); + // 获得用户的部门编号的缓存,通过 Guava 的 Suppliers 惰性求值,即有且仅有第一次发起 DB 的查询 Supplier userDeptIdCache = Suppliers.memoize(() -> userService.getUser(userId).getDeptId()); // 遍历每个角色,计算