Merge branch 'hotfix-20240920' into 'master'
feat:hotfix-20240920 修改项目下只有管理员角色导致差普通角色时加载缓存接口过慢 See merge request universal/infrastructure/backend/tyr!204
This commit is contained in:
commit
aa9fc3c09f
@ -63,4 +63,11 @@ public enum RoleTypeEnum {
|
|||||||
.map(RoleTypeEnum::getValue)
|
.map(RoleTypeEnum::getValue)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> listNormal() {
|
||||||
|
return Arrays.stream(values())
|
||||||
|
.filter(e -> !e.isAdmin)
|
||||||
|
.map(RoleTypeEnum::getValue)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -583,7 +583,7 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Set<Long> resolvePermissionNormalRole(ListPermissionUser req,
|
private Set<Long> resolvePermissionNormalRole(ListPermissionUser req,
|
||||||
List<ProductPermissionCacheService.PermissionDTO> productPermissions,
|
List<ProductPermissionCacheService.PermissionDTO> productPermissions,
|
||||||
Set<Long> featureIds) {
|
Set<Long> featureIds) {
|
||||||
|
|
||||||
// 因为通过权限id找对应的角色数据量巨大,所以通过找项目的角色,再找有权限的角色比较快
|
// 因为通过权限id找对应的角色数据量巨大,所以通过找项目的角色,再找有权限的角色比较快
|
||||||
@ -595,8 +595,17 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
|||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<SaasRoleRes> normalRoles = roleService.list(RoleService.ListSaasRoleParam.builder()
|
||||||
|
.roleIds(Lists.newArrayList(allRoleIds))
|
||||||
|
.roleTypes(RoleTypeEnum.listNormal())
|
||||||
|
.build());
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(normalRoles)) {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
RolePermissionCacheService.ListRolePermissionParam listRolePermissionParam = RolePermissionCacheService.ListRolePermissionParam.builder()
|
RolePermissionCacheService.ListRolePermissionParam listRolePermissionParam = RolePermissionCacheService.ListRolePermissionParam.builder()
|
||||||
.roleIds(allRoleIds)
|
.roleIds(normalRoles.stream().map(SaasRoleRes::getId).collect(Collectors.toSet()))
|
||||||
.featureCodes(productPermissions.stream()
|
.featureCodes(productPermissions.stream()
|
||||||
.map(ProductPermissionCacheService.PermissionDTO::getFeatureCode)
|
.map(ProductPermissionCacheService.PermissionDTO::getFeatureCode)
|
||||||
.collect(Collectors.toSet()))
|
.collect(Collectors.toSet()))
|
||||||
@ -610,10 +619,8 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
|||||||
|| e.getValue().stream().anyMatch(p -> Objects.equals(p.getTerminal(), req.getTerminal())))
|
|| e.getValue().stream().anyMatch(p -> Objects.equals(p.getTerminal(), req.getTerminal())))
|
||||||
.map(Map.Entry::getKey)
|
.map(Map.Entry::getKey)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
Map<Long, SaasRoleRes> normalRoles = roleService.list(RoleService.ListSaasRoleParam.builder()
|
Map<Long, SaasRoleRes> normalRoleMap = normalRoles.stream()
|
||||||
.roleIds(Lists.newArrayList(normalRoleIds))
|
.filter(e -> normalRoleIds.contains(e.getId()))
|
||||||
.build())
|
|
||||||
.stream()
|
|
||||||
.collect(Collectors.toMap(SaasRoleRes::getId, Function.identity()));
|
.collect(Collectors.toMap(SaasRoleRes::getId, Function.identity()));
|
||||||
|
|
||||||
Map<String, Set<String>> featureCodeCooperateTypeMap = productPermissions.stream()
|
Map<String, Set<String>> featureCodeCooperateTypeMap = productPermissions.stream()
|
||||||
@ -621,7 +628,7 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
|||||||
Collectors.mapping(ProductPermissionCacheService.PermissionDTO::getCooperateType, Collectors.toSet())));
|
Collectors.mapping(ProductPermissionCacheService.PermissionDTO::getCooperateType, Collectors.toSet())));
|
||||||
return normalRolePermissionMap.entrySet().stream()
|
return normalRolePermissionMap.entrySet().stream()
|
||||||
.filter(e -> {
|
.filter(e -> {
|
||||||
SaasRoleRes saasRoleRes = normalRoles.get(e.getKey());
|
SaasRoleRes saasRoleRes = normalRoleMap.get(e.getKey());
|
||||||
if (Objects.isNull(saasRoleRes)) {
|
if (Objects.isNull(saasRoleRes)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user