feat: (feature/REQ-2750) 1、解决组件资源更新时groupCode被覆盖成code的问题

2、解决查询项目下有权限的人无法查询出admin角色的人的问题
This commit is contained in:
lilong 2024-10-25 11:01:52 +08:00
parent 19ae1ee0d0
commit 784db6f298
2 changed files with 31 additions and 26 deletions

View File

@ -604,6 +604,11 @@ public class SaasPageElementServiceImpl extends ServiceImpl<SaasPageElementMappe
// 更新关联关系的page_element_code
saasPageElementFeatureResourceRelationDao.updateGroupCode(dbPageElement.getCode(), basePageElement.getCode(), dbPageElement.getTerminal());
}
// page的groupCode是自己的code但是component的groupCode是父级页面的code
// 原来component在更新时会把自己的groupCode更新成自己的code
if (PageElementTypeEnum.COMPONENT.getCode().equals(req.getType())) {
basePageElement.setGroupCode(req.getGroupCode());
}
saasPageElementDao.updateById(basePageElement);
} else {
if (PageElementTypeEnum.PAGE.getCode().equals(req.getType())) {

View File

@ -561,16 +561,6 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
return result;
}
private List<SaasRoleRes> listAdminRole(ListPermissionUser req) {
//超管和管理员
ListRoleReq listSaasRoleParam = ListRoleReq.builder()
.workspaceId(req.getWorkspaceId())
.ouId(req.getOuId())
.roleTypes(Lists.newArrayList(RoleTypeEnum.SUPER_ADMIN.getValue(), RoleTypeEnum.ADMIN.getValue()))
.build();
return roleService.list(listSaasRoleParam);
}
private Set<Long> resolvePermissionAdminRole(List<SaasRoleRes> adminRoles,
List<ProductPermissionCacheService.PermissionDTO> productPermissions) {
Set<String> cooperateTypes = productPermissions.stream()
@ -585,21 +575,12 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
private Set<Long> resolvePermissionNormalRole(ListPermissionUser req,
List<ProductPermissionCacheService.PermissionDTO> productPermissions,
Set<Long> featureIds) {
Set<Long> featureIds,
List<SaasRoleRes> allRoles) {
// 因为通过权限id找对应的角色数据量巨大所以通过找项目的角色再找有权限的角色比较快
Set<Long> allRoleIds = saasRoleUserRelationMapper.listRoleIds(SaasRoleUserRelationMapper.ListRole.builder()
.ouId(req.getOuId())
.workspaceId(req.getWorkspaceId())
.build());
if (CollectionUtils.isEmpty(allRoleIds)) {
return Collections.emptySet();
}
List<SaasRoleRes> normalRoles = roleService.list(RoleService.ListSaasRoleParam.builder()
.roleIds(Lists.newArrayList(allRoleIds))
.roleTypes(RoleTypeEnum.listNormal())
.build());
List<SaasRoleRes> normalRoles = allRoles.stream()
.filter(e -> !RoleTypeEnum.isAdmin(e.getRoleType()))
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(normalRoles)) {
return Collections.emptySet();
@ -653,11 +634,30 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
List<ProductPermissionCacheService.PermissionDTO> productPermissions,
Set<Long> featureIds) {
// 因为通过权限id找对应的角色数据量巨大所以通过找项目的角色再找有权限的角色比较快
Set<Long> allRoleIds = saasRoleUserRelationMapper.listRoleIds(SaasRoleUserRelationMapper.ListRole.builder()
.ouId(req.getOuId())
.workspaceId(req.getWorkspaceId())
.build());
if (CollectionUtils.isEmpty(allRoleIds)) {
return Collections.emptyList();
}
List<SaasRoleRes> allRoles = roleService.list(ListRoleReq.builder()
.roleIds(Lists.newArrayList(allRoleIds))
.build());
if (CollectionUtils.isEmpty(allRoles)) {
return Collections.emptyList();
}
//超管和管理员
List<SaasRoleRes> adminRoles = listAdminRole(req);
List<SaasRoleRes> adminRoles = allRoles.stream()
.filter(e -> RoleTypeEnum.isAdmin(e.getRoleType()))
.collect(Collectors.toList());
Set<Long> adminPermissionRoleIds = resolvePermissionAdminRole(adminRoles, productPermissions);
Set<Long> normalPermissionRoleIds = resolvePermissionNormalRole(req, productPermissions, featureIds);
Set<Long> normalPermissionRoleIds = resolvePermissionNormalRole(req, productPermissions, featureIds, allRoles);
Set<Long> roleIds = Sets.newHashSet();
roleIds.addAll(adminPermissionRoleIds);