feat: (feature/REQ-3068) 提供新接口优化,原接口引用地方太多,需要回归的地方太多
This commit is contained in:
parent
b1f98935f9
commit
f414070272
@ -107,9 +107,13 @@ public interface TyrSaasRoleApi {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@PostMapping("/api/saasRole/queryBatchByIdentityIdType")
|
@PostMapping("/api/saasRole/queryBatchByIdentityIdType")
|
||||||
ApiResult<List<QueryBatchByIdentityIdTypeRes>> queryBatchByIdentityIdType(@RequestBody List<QueryByIdentityIdTypeReq> req);
|
ApiResult<List<QueryBatchByIdentityIdTypeRes>> queryBatchByIdentityIdType(@RequestBody List<QueryByIdentityIdTypeReq> req);
|
||||||
|
|
||||||
|
@PostMapping("/api/saasRole/queryBatchByIdentityIdType/v2")
|
||||||
|
ApiResult<List<QueryBatchByIdentityIdTypeRes>> queryBatchByIdentityIdTypeV2(@RequestBody List<QueryByIdentityIdTypeReq> req);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据身份id身份类型查询是否为超管
|
* 根据身份id身份类型查询是否为超管
|
||||||
*
|
*
|
||||||
|
|||||||
@ -173,6 +173,11 @@ public class SaasRoleController implements TyrSaasRoleApi {
|
|||||||
return ApiResult.ok(roleService.queryBatchByIdentityIdType(req));
|
return ApiResult.ok(roleService.queryBatchByIdentityIdType(req));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiResult<List<QueryBatchByIdentityIdTypeRes>> queryBatchByIdentityIdTypeV2(List<QueryByIdentityIdTypeReq> req) {
|
||||||
|
return ApiResult.ok(roleService.queryBatchByIdentityIdTypeV2(req));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiResult<List<IsSuperAdminRes>> isSuperAdmin(List<QueryByIdentityIdTypeReq> req) {
|
public ApiResult<List<IsSuperAdminRes>> isSuperAdmin(List<QueryByIdentityIdTypeReq> req) {
|
||||||
return ApiResult.ok(roleService.isSuperAdmin(req));
|
return ApiResult.ok(roleService.isSuperAdmin(req));
|
||||||
|
|||||||
@ -55,8 +55,11 @@ public interface RoleService extends IService<SaasRole> {
|
|||||||
|
|
||||||
List<SaasRoleVO> query(QuerySaasRoleReq req);
|
List<SaasRoleVO> query(QuerySaasRoleReq req);
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
List<QueryBatchByIdentityIdTypeRes> queryBatchByIdentityIdType(List<QueryByIdentityIdTypeReq> req);
|
List<QueryBatchByIdentityIdTypeRes> queryBatchByIdentityIdType(List<QueryByIdentityIdTypeReq> req);
|
||||||
|
|
||||||
|
List<QueryBatchByIdentityIdTypeRes> queryBatchByIdentityIdTypeV2(List<QueryByIdentityIdTypeReq> req);
|
||||||
|
|
||||||
Long saveOrUpdate(SaveOrUpdateRoleVO saveOrUpdateRole);
|
Long saveOrUpdate(SaveOrUpdateRoleVO saveOrUpdateRole);
|
||||||
|
|
||||||
List<IsSuperAdminRes> isSuperAdmin(List<QueryByIdentityIdTypeReq> req);
|
List<IsSuperAdminRes> isSuperAdmin(List<QueryByIdentityIdTypeReq> req);
|
||||||
|
|||||||
@ -333,6 +333,38 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<QueryBatchByIdentityIdTypeRes> queryBatchByIdentityIdType(List<QueryByIdentityIdTypeReq> req) {
|
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,原来入参过多时,接口性能很差
|
// 一起查询,减少数据库io,原来入参过多时,接口性能很差
|
||||||
List<ListRoleUserRelationParam.BatchPerson> batchPersons = req.stream()
|
List<ListRoleUserRelationParam.BatchPerson> batchPersons = req.stream()
|
||||||
.distinct()
|
.distinct()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user