feat: (feature/REQ-3068) 提供新接口优化,原接口引用地方太多,需要回归的地方太多

This commit is contained in:
lilong 2024-10-12 11:40:34 +08:00
parent b1f98935f9
commit f414070272
4 changed files with 44 additions and 0 deletions

View File

@ -107,9 +107,13 @@ public interface TyrSaasRoleApi {
*
* @return
*/
@Deprecated
@PostMapping("/api/saasRole/queryBatchByIdentityIdType")
ApiResult<List<QueryBatchByIdentityIdTypeRes>> queryBatchByIdentityIdType(@RequestBody List<QueryByIdentityIdTypeReq> req);
@PostMapping("/api/saasRole/queryBatchByIdentityIdType/v2")
ApiResult<List<QueryBatchByIdentityIdTypeRes>> queryBatchByIdentityIdTypeV2(@RequestBody List<QueryByIdentityIdTypeReq> req);
/**
* 根据身份id身份类型查询是否为超管
*

View File

@ -173,6 +173,11 @@ public class SaasRoleController implements TyrSaasRoleApi {
return ApiResult.ok(roleService.queryBatchByIdentityIdType(req));
}
@Override
public ApiResult<List<QueryBatchByIdentityIdTypeRes>> queryBatchByIdentityIdTypeV2(List<QueryByIdentityIdTypeReq> req) {
return ApiResult.ok(roleService.queryBatchByIdentityIdTypeV2(req));
}
@Override
public ApiResult<List<IsSuperAdminRes>> isSuperAdmin(List<QueryByIdentityIdTypeReq> req) {
return ApiResult.ok(roleService.isSuperAdmin(req));

View File

@ -55,8 +55,11 @@ public interface RoleService extends IService<SaasRole> {
List<SaasRoleVO> query(QuerySaasRoleReq req);
@Deprecated
List<QueryBatchByIdentityIdTypeRes> queryBatchByIdentityIdType(List<QueryByIdentityIdTypeReq> req);
List<QueryBatchByIdentityIdTypeRes> queryBatchByIdentityIdTypeV2(List<QueryByIdentityIdTypeReq> req);
Long saveOrUpdate(SaveOrUpdateRoleVO saveOrUpdateRole);
List<IsSuperAdminRes> isSuperAdmin(List<QueryByIdentityIdTypeReq> req);

View File

@ -333,6 +333,38 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
@Override
public List<QueryBatchByIdentityIdTypeRes> queryBatchByIdentityIdType(List<QueryByIdentityIdTypeReq> req) {
List<QueryBatchByIdentityIdTypeRes> result = new ArrayList<>();
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
public List<QueryBatchByIdentityIdTypeRes> queryBatchByIdentityIdTypeV2(List<QueryByIdentityIdTypeReq> req) {
// 一起查询减少数据库io原来入参过多时接口性能很差
List<ListRoleUserRelationParam.BatchPerson> batchPersons = req.stream()
.distinct()