ソースを参照

fix(auth):修复角色权限缓存键判断逻辑

- 调整角色代码拼接顺序,先拼接租户代码再判断缓存键是否存在
- 确保权限列表获取前已完成角色代码转换- 避免因缓存键判断错误导致权限数据重复加载
chejianzheng 3 週間 前
コミット
5149042003

+ 3 - 3
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/config/UserAuthService.java

@@ -54,9 +54,9 @@ public class UserAuthService {
 
             List<String> newRoleCodeList = new ArrayList<>();
             for (String roleCode : roleCodeList) {
-                if (!redisService.hasKey(RedisCacheConstant.ROLE_PERM_KEY_PRE + roleCode)) {
-                    String newRoleCode = StringUtils.hasText(tenantCode) ? tenantCode + "_" + roleCode : roleCode;
-                    newRoleCodeList.add(newRoleCode);
+                String newRoleCode = StringUtils.hasText(tenantCode) ? tenantCode + "_" + roleCode : roleCode;
+                newRoleCodeList.add(newRoleCode);
+                if (!redisService.hasKey(RedisCacheConstant.ROLE_PERM_KEY_PRE + newRoleCode)) {
                     List<String> permCodeList = this.getPermCodeList(roleCode);
                     if (!CollectionUtils.isEmpty(permCodeList)) {
                         // 永久期限