查询角色信息通用接口默认不返回角色下的权限集信息,提高接口处理速度

This commit is contained in:
陈维伟 2023-10-20 14:08:17 +08:00
parent 886a1a10a0
commit 7d0e7d68fd
4 changed files with 7 additions and 8 deletions

View File

@ -57,7 +57,7 @@ public interface TyrSaasRoleApi {
ApiResult delete(@RequestBody List<Long> id); ApiResult delete(@RequestBody List<Long> id);
/** /**
* 根据身份id身份类型查询权限列表批量 * 根据身份id身份类型查询权限列表只返回角色信息
* @param identityType 身份类型 1:工人 2:班组长 3:从业人员 4:监管人员 5:运营人员 * @param identityType 身份类型 1:工人 2:班组长 3:从业人员 4:监管人员 5:运营人员
* @return * @return
*/ */
@ -65,7 +65,7 @@ public interface TyrSaasRoleApi {
ApiResult<List<SaasRoleVO>> queryByIdentityIdType(@RequestParam(required = true) Long identityId,@RequestParam(required = true) Integer identityType,@RequestParam(required = true) Long workspaceId,@RequestParam(required = true) Long ouId); ApiResult<List<SaasRoleVO>> queryByIdentityIdType(@RequestParam(required = true) Long identityId,@RequestParam(required = true) Integer identityType,@RequestParam(required = true) Long workspaceId,@RequestParam(required = true) Long ouId);
/** /**
* 根据身份id身份类型查询权限列表批量 * 根据身份id身份类型查询权限列表批量,只返回角色信息
* @return * @return
*/ */
@PostMapping("/api/saasRole/queryBatchByIdentityIdType") @PostMapping("/api/saasRole/queryBatchByIdentityIdType")

View File

@ -66,7 +66,7 @@ public class SaasRoleController implements TyrSaasRoleApi {
@Override @Override
public ApiResult<List<SaasRoleVO>> queryByIdentityIdType(Long identityId, Integer identityType,Long workspaceId,Long ouId) { public ApiResult<List<SaasRoleVO>> queryByIdentityIdType(Long identityId, Integer identityType,Long workspaceId,Long ouId) {
return ApiResult.ok(roleService.queryByIdentityIdType(identityId, identityType,workspaceId,ouId)); return ApiResult.ok(roleService.queryByIdentityIdType(identityId, identityType,workspaceId,ouId, false));
} }
@Override @Override

View File

@ -25,7 +25,7 @@ import java.util.Set;
public interface RoleService { public interface RoleService {
List<SaasRoleVO> queryByIdentityIdType(Long identityId, Integer identityType,Long workspaceId,Long ouId); List<SaasRoleVO> queryByIdentityIdType(Long identityId, Integer identityType,Long workspaceId,Long ouId, Boolean includePermissionGroup);
List<SaasRoleVO> query(QuerySaasRoleReq req); List<SaasRoleVO> query(QuerySaasRoleReq req);

View File

@ -76,13 +76,13 @@ public class RoleServiceImpl implements RoleService {
SaasRoleUserRelationDao saasRoleUserRelationDao; SaasRoleUserRelationDao saasRoleUserRelationDao;
@Override @Override
public List<SaasRoleVO> queryByIdentityIdType(Long identityId, Integer identityType, Long workspaceId, Long ouId) { public List<SaasRoleVO> queryByIdentityIdType(Long identityId, Integer identityType, Long workspaceId, Long ouId, Boolean includePermissionGroup) {
// 查询人关联的角色id // 查询人关联的角色id
List<Long> roleIds = roleUserRelationDao.query(identityId, identityType, workspaceId, ouId).stream().map(SaasRoleUserRelation::getRoleId).collect(Collectors.toList()); List<Long> roleIds = roleUserRelationDao.query(identityId, identityType, workspaceId, ouId).stream().map(SaasRoleUserRelation::getRoleId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(roleIds)) { if (CollectionUtils.isEmpty(roleIds)) {
return new ArrayList<>(); return new ArrayList<>();
} }
return getByIds(roleIds, null, null,null, false); return getByIds(roleIds, null, null,null, includePermissionGroup);
} }
/** /**
@ -194,14 +194,13 @@ public class RoleServiceImpl implements RoleService {
@Override @Override
public List<QueryBatchByIdentityIdTypeRes> queryBatchByIdentityIdType(List<QueryByIdentityIdTypeReq> req) { public List<QueryBatchByIdentityIdTypeRes> queryBatchByIdentityIdType(List<QueryByIdentityIdTypeReq> req) {
List<QueryBatchByIdentityIdTypeRes> result = new ArrayList<>(); List<QueryBatchByIdentityIdTypeRes> result = new ArrayList<>();
req.forEach(e -> { req.forEach(e -> {
result.add(QueryBatchByIdentityIdTypeRes.builder() result.add(QueryBatchByIdentityIdTypeRes.builder()
.identityId(e.getIdentityId()) .identityId(e.getIdentityId())
.identityType(e.getIdentityType()) .identityType(e.getIdentityType())
.workspaceId(e.getWorkspaceId()) .workspaceId(e.getWorkspaceId())
.ouId(e.getOuId()) .ouId(e.getOuId())
.role(queryByIdentityIdType(e.getIdentityId(),e.getIdentityType(),e.getWorkspaceId(),e.getOuId())) .role(queryByIdentityIdType(e.getIdentityId(),e.getIdentityType(),e.getWorkspaceId(),e.getOuId(),false))
.build()); .build());
}); });
return result; return result;