소스 검색

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

- 调整角色代码拼接顺序,先拼接租户代码再判断缓存键是否存在
- 确保权限列表获取前已完成角色代码转换- 避免因缓存键判断错误导致权限数据重复加载
chejianzheng 3 주 전
부모
커밋
5149042003
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/config/UserAuthService.java

+ 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)) {
                         // 永久期限