feat:(REQ-3068) 优化人员查询接口

This commit is contained in:
lilong 2024-10-11 13:43:25 +08:00
parent bd0f4e83d1
commit 8870a1830d

View File

@ -347,12 +347,14 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
.build());
// 原代码是入参有personId就使用personId查询不能同时使用personId和identityIdidentityType
Map<Long, Set<Long>> personRoles = saasRoleUsers.stream()
.collect(Collectors.groupingBy(e -> e.getSaasRoleUser().getPersonId(),
Map<String, Set<Long>> personRoles = saasRoleUsers.stream()
.collect(Collectors.groupingBy(e ->
e.getSaasRoleUser().getPersonId() + "_" + e.getSaasRoleUser().getWorkspaceId() + "_" + e.getSaasRoleUser().getOuId(),
Collectors.mapping(SaasRoleUserV2DTO::getRoleId, Collectors.toSet())));
Map<String, Set<Long>> identityRoles = saasRoleUsers.stream()
.collect(Collectors.groupingBy(e -> e.getSaasRoleUser().getIdentityId() + "_" + e.getSaasRoleUser().getIdentityType(),
.collect(Collectors.groupingBy(e -> e.getSaasRoleUser().getIdentityId() + "_" + e.getSaasRoleUser().getIdentityType()
+ "_" + e.getSaasRoleUser().getWorkspaceId() + "_" + e.getSaasRoleUser().getOuId(),
Collectors.mapping(SaasRoleUserV2DTO::getRoleId, Collectors.toSet())));
List<Long> allRoleIds = saasRoleUsers.stream()
@ -372,9 +374,9 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
// 原代码是入参有personId就使用personId查询不能同时使用personId和identityIdidentityType
Set<Long> roleIds;
if (Objects.nonNull(e.getPersonId())) {
roleIds = personRoles.get(e.getPersonId());
roleIds = personRoles.get(e.getPersonId() + "_" + e.getWorkspaceId() + "_" + e.getOuId());
} else {
roleIds = identityRoles.get(e.getIdentityId() + "_" + e.getIdentityType());
roleIds = identityRoles.get(e.getIdentityId() + "_" + e.getIdentityType() + "_" + e.getWorkspaceId() + "_" + e.getOuId());
}
if (CollectionUtils.isNotEmpty(roleIds)) {
@ -383,35 +385,6 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
return result;
})
.collect(Collectors.toList());
// req.stream().distinct().forEach(e -> {
// if (e.getPersonId() != null) {
// List<Long> roleIds = roleUserRelationDao.queryByPersonId(e.getPersonId(), e.getWorkspaceId(), e.getOuId())
// .stream()
// .map(SaasRoleUserRelation::getRoleId)
// .collect(Collectors.toList());
// List<SaasRoleVO> saasRoles = getByIds(roleIds, null, null, null, false, null);
// result.add(QueryBatchByIdentityIdTypeRes.builder()
// .identityId(e.getIdentityId())
// .identityType(e.getIdentityType())
// .workspaceId(e.getWorkspaceId())
// .ouId(e.getOuId())
// .personId(e.getPersonId())
// .role(saasRoles)
// .build());
// } else {
// result.add(QueryBatchByIdentityIdTypeRes.builder()
// .identityId(e.getIdentityId())
// .identityType(e.getIdentityType())
// .workspaceId(e.getWorkspaceId())
// .ouId(e.getOuId())
// .role(queryByIdentityIdType(e.getIdentityId(), e.getIdentityType(), e.getWorkspaceId(), e.getOuId(), false))
// .build());
// }
//
// });
// return result;
}
@Override