feat:(REQ-3068) 解决查询人员角色时,只给ouId的情况
This commit is contained in:
parent
d766af05aa
commit
0e9e269f4b
@ -346,17 +346,6 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
|
|||||||
.batchPersons(batchPersons)
|
.batchPersons(batchPersons)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
// 原代码是入参有personId就使用personId查询,不能同时使用personId和identityId、identityType
|
|
||||||
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()
|
|
||||||
+ "_" + e.getSaasRoleUser().getWorkspaceId() + "_" + e.getSaasRoleUser().getOuId(),
|
|
||||||
Collectors.mapping(SaasRoleUserV2DTO::getRoleId, Collectors.toSet())));
|
|
||||||
|
|
||||||
List<Long> allRoleIds = saasRoleUsers.stream()
|
List<Long> allRoleIds = saasRoleUsers.stream()
|
||||||
.map(SaasRoleUserV2DTO::getRoleId)
|
.map(SaasRoleUserV2DTO::getRoleId)
|
||||||
.distinct()
|
.distinct()
|
||||||
@ -372,15 +361,35 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
|
|||||||
QueryBatchByIdentityIdTypeRes result = QueryBatchByIdentityIdTypeRes.builder().build();
|
QueryBatchByIdentityIdTypeRes result = QueryBatchByIdentityIdTypeRes.builder().build();
|
||||||
BeanUtils.copyProperties(e, result);
|
BeanUtils.copyProperties(e, result);
|
||||||
// 原代码是入参有personId就使用personId查询,不能同时使用personId和identityId、identityType
|
// 原代码是入参有personId就使用personId查询,不能同时使用personId和identityId、identityType
|
||||||
Set<Long> roleIds;
|
// 因为入参workspaceId和ouId不一定都有,所以不好转成map去取,只能遍历,数据量不大,所以还好
|
||||||
if (Objects.nonNull(e.getPersonId())) {
|
Set<Long> roleIds = saasRoleUsers.stream()
|
||||||
roleIds = personRoles.get(e.getPersonId() + "_" + e.getWorkspaceId() + "_" + e.getOuId());
|
.filter(role -> {
|
||||||
} else {
|
if (Objects.nonNull(e.getIdentityType()) && !Objects.equals(e.getIdentityType(), role.getSaasRoleUser().getIdentityType())) {
|
||||||
roleIds = identityRoles.get(e.getIdentityId() + "_" + e.getIdentityType() + "_" + e.getWorkspaceId() + "_" + e.getOuId());
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Objects.nonNull(e.getIdentityId()) && !Objects.equals(e.getIdentityId(), role.getSaasRoleUser().getIdentityId())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Objects.nonNull(e.getPersonId()) && !Objects.equals(e.getPersonId(), role.getSaasRoleUser().getPersonId())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Objects.nonNull(e.getWorkspaceId()) && !Objects.equals(e.getWorkspaceId(), role.getSaasRoleUser().getWorkspaceId())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Objects.nonNull(e.getOuId()) && !Objects.equals(e.getOuId(), role.getSaasRoleUser().getOuId())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.map(SaasRoleUserV2DTO::getRoleId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(roleIds)) {
|
if (CollectionUtils.isNotEmpty(roleIds)) {
|
||||||
result.setRole(roleIds.stream().map(saasRoles::get).collect(Collectors.toList()));
|
result.setRole(roleIds.stream().map(saasRoles::get).filter(Objects::nonNull).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user