Commit d42f4be4cac8fb6c107f050c89fa5a57436277c0
1 parent
fe1ca9bc
refactor: 住户管理员权限兼容老版本
1、用租户管理员的用户ID取权限信息 2、用租户ID取权限ID
Showing
1 changed file
with
8 additions
and
6 deletions
... | ... | @@ -110,20 +110,22 @@ public class SysRoleServiceImpl extends AbstractBaseService<RoleMapper, SysRoleE |
110 | 110 | cacheUtils.get(FastIotConstants.CacheConfigKey.CACHE_CONFIG_KEY, cacheKey); |
111 | 111 | cachePresent = optionalPermission.isPresent(); |
112 | 112 | allPermission = optionalPermission.orElseGet(menuMapper::getAllPermission); |
113 | - } else if (isTenantAdmin) { | |
114 | - cacheKey = FastIotConstants.CacheConfigKey.USER_PERMISSION_PREFIX + tenantId; | |
113 | + } else { | |
114 | + cacheKey = FastIotConstants.CacheConfigKey.USER_PERMISSION_PREFIX + useerId; | |
115 | 115 | Optional<Set<String>> optionalPermission = |
116 | 116 | cacheUtils.get(FastIotConstants.CacheConfigKey.CACHE_CONFIG_KEY, cacheKey); |
117 | 117 | cachePresent = optionalPermission.isPresent(); |
118 | 118 | allPermission = |
119 | - optionalPermission.orElseGet(() -> menuMapper.getAllPermissionsByTenantId(tenantId)); | |
120 | - } else { | |
121 | - cacheKey = FastIotConstants.CacheConfigKey.USER_PERMISSION_PREFIX + useerId; | |
119 | + optionalPermission.orElseGet(() -> menuMapper.getAllPermissionsByUserId(useerId)); | |
120 | + } | |
121 | + /**租户管理员未获取到用户权限时,默认使用租户的权限*/ | |
122 | + if (isTenantAdmin && allPermission.isEmpty()) { | |
123 | + cacheKey = FastIotConstants.CacheConfigKey.USER_PERMISSION_PREFIX + tenantId; | |
122 | 124 | Optional<Set<String>> optionalPermission = |
123 | 125 | cacheUtils.get(FastIotConstants.CacheConfigKey.CACHE_CONFIG_KEY, cacheKey); |
124 | 126 | cachePresent = optionalPermission.isPresent(); |
125 | 127 | allPermission = |
126 | - optionalPermission.orElseGet(() -> menuMapper.getAllPermissionsByUserId(useerId)); | |
128 | + optionalPermission.orElseGet(() -> menuMapper.getAllPermissionsByTenantId(tenantId)); | |
127 | 129 | } |
128 | 130 | if (cachePresent) { |
129 | 131 | return allPermission; | ... | ... |