feat(server): 实现ListNodeUserReq.Needs.role查询参数。
This commit is contained in:
parent
9fe926ef19
commit
ed4cd26183
@ -0,0 +1,19 @@
|
|||||||
|
package cn.axzo.orgmanax.dto.common;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Data
|
||||||
|
public class RoleBriefDTO implements Serializable {
|
||||||
|
private Long roleId;
|
||||||
|
private String roleCode;
|
||||||
|
private String name;
|
||||||
|
private String roleType;
|
||||||
|
}
|
||||||
@ -1,15 +1,13 @@
|
|||||||
package cn.axzo.orgmanax.dto.nodeuser.dto;
|
package cn.axzo.orgmanax.dto.nodeuser.dto;
|
||||||
|
|
||||||
import cn.axzo.orgmanax.dto.common.PersonProfileBriefDTO;
|
import cn.axzo.orgmanax.dto.common.PersonProfileBriefDTO;
|
||||||
|
import cn.axzo.orgmanax.dto.common.RoleBriefDTO;
|
||||||
import cn.axzo.orgmanax.dto.common.WorkspaceBriefDTO;
|
import cn.axzo.orgmanax.dto.common.WorkspaceBriefDTO;
|
||||||
import cn.axzo.orgmanax.dto.cooperateship.dto.OrgCooperateShipDTO;
|
import cn.axzo.orgmanax.dto.cooperateship.dto.OrgCooperateShipDTO;
|
||||||
import cn.axzo.orgmanax.dto.job.dto.OrgJobBriefDTO;
|
import cn.axzo.orgmanax.dto.job.dto.OrgJobBriefDTO;
|
||||||
import cn.axzo.orgmanax.dto.node.dto.NodeProfile;
|
|
||||||
import cn.axzo.orgmanax.dto.node.dto.OrgNodeBriefDTO;
|
import cn.axzo.orgmanax.dto.node.dto.OrgNodeBriefDTO;
|
||||||
import cn.axzo.orgmanax.dto.node.enums.NodeTypeEnum;
|
|
||||||
import cn.axzo.orgmanax.dto.nodeuser.req.ListNodeUserReq;
|
import cn.axzo.orgmanax.dto.nodeuser.req.ListNodeUserReq;
|
||||||
import cn.axzo.orgmanax.dto.unit.dto.OrgUnitBriefDTO;
|
import cn.axzo.orgmanax.dto.unit.dto.OrgUnitBriefDTO;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -191,6 +189,11 @@ public class NodeUserDTO implements Serializable {
|
|||||||
* 注意:平台班组是不会返回这个的。
|
* 注意:平台班组是不会返回这个的。
|
||||||
*/
|
*/
|
||||||
private List<NodeUserBriefDTO> subordinateUsers;
|
private List<NodeUserBriefDTO> subordinateUsers;
|
||||||
|
/**
|
||||||
|
* 需指定{@link ListNodeUserReq.Needs#getRole()} 为true才会返回。
|
||||||
|
* 注意:平台班组是不会返回这个的。
|
||||||
|
*/
|
||||||
|
private List<RoleBriefDTO> roles;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -229,6 +229,7 @@ public class ListNodeUserReq extends PageReqV2 {
|
|||||||
private Long projectWorkerId;
|
private Long projectWorkerId;
|
||||||
private Collection<Long> projectWorkerIds;
|
private Collection<Long> projectWorkerIds;
|
||||||
private Long projectGroupId;
|
private Long projectGroupId;
|
||||||
|
private Integer projectGroupWorkerStatus;
|
||||||
|
|
||||||
// ~ 结束。
|
// ~ 结束。
|
||||||
|
|
||||||
@ -308,13 +309,6 @@ public class ListNodeUserReq extends PageReqV2 {
|
|||||||
*/
|
*/
|
||||||
private DistinctRule distinctRule;
|
private DistinctRule distinctRule;
|
||||||
|
|
||||||
/**
|
|
||||||
* todo 未实现
|
|
||||||
* 项目小组工人状态
|
|
||||||
* @see ProjectGroupWorkerStatusEnum
|
|
||||||
*/
|
|
||||||
private Integer projectGroupWorkerStatus;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
// 指定聚合信息
|
// 指定聚合信息
|
||||||
@ -342,10 +336,6 @@ public class ListNodeUserReq extends PageReqV2 {
|
|||||||
* 是否需要部门及父级部门信息,默认不返回
|
* 是否需要部门及父级部门信息,默认不返回
|
||||||
*/
|
*/
|
||||||
private Boolean ancestorNodes;
|
private Boolean ancestorNodes;
|
||||||
/**
|
|
||||||
* 返回node and path
|
|
||||||
*/
|
|
||||||
private Boolean nodeAndPath; // TODO : 待实现
|
|
||||||
/**
|
/**
|
||||||
* 返回参与项目数量
|
* 返回参与项目数量
|
||||||
*/
|
*/
|
||||||
@ -367,7 +357,7 @@ public class ListNodeUserReq extends PageReqV2 {
|
|||||||
/**
|
/**
|
||||||
* 是否需要角色信息
|
* 是否需要角色信息
|
||||||
*/
|
*/
|
||||||
private Boolean role; // TODO : 待实现
|
private Boolean role;
|
||||||
|
|
||||||
private Boolean cooperateShip;
|
private Boolean cooperateShip;
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,26 @@
|
|||||||
|
package cn.axzo.orgmanax.infra.client.tyr;
|
||||||
|
|
||||||
|
import cn.axzo.foundation.util.PageUtils;
|
||||||
|
import cn.axzo.orgmanax.infra.client.RpcWrapper;
|
||||||
|
import cn.axzo.tyr.feign.api.RoleUserApi;
|
||||||
|
import cn.axzo.tyr.feign.req.PageRoleUserReq;
|
||||||
|
import cn.axzo.tyr.feign.resp.RoleUserResp;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class RoleUserGateway {
|
||||||
|
private final RoleUserApi roleUserApi;
|
||||||
|
|
||||||
|
public List<RoleUserResp> pageAll(PageRoleUserReq req) {
|
||||||
|
return PageUtils.drainAll((pageNumber) -> {
|
||||||
|
req.setPage(pageNumber);
|
||||||
|
return RpcWrapper.wrapApiResult(() -> roleUserApi.page(req), "分页获取用户角色", req);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -84,6 +84,7 @@ public class NodeUserFoundationServiceImpl implements NodeUserFoundationService
|
|||||||
nodeUser.setPhone(personProfile.getPhone());
|
nodeUser.setPhone(personProfile.getPhone());
|
||||||
nodeUser.setRealName(personProfile.getRealName());
|
nodeUser.setRealName(personProfile.getRealName());
|
||||||
nodeUser.setIdNumber(personProfile.getIdNumber());
|
nodeUser.setIdNumber(personProfile.getIdNumber());
|
||||||
|
nodeUser.setPersonId(personProfile.getId());
|
||||||
// assemble unit info
|
// assemble unit info
|
||||||
nodeUser.setOrganizationalUnitId(node.getOrganizationalUnitId());
|
nodeUser.setOrganizationalUnitId(node.getOrganizationalUnitId());
|
||||||
// assemble node info
|
// assemble node info
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import cn.axzo.foundation.exception.Axssert;
|
|||||||
import cn.axzo.foundation.page.PageResp;
|
import cn.axzo.foundation.page.PageResp;
|
||||||
import cn.axzo.orgmanax.common.config.BizResultCode;
|
import cn.axzo.orgmanax.common.config.BizResultCode;
|
||||||
import cn.axzo.orgmanax.dto.common.PersonProfileBriefDTO;
|
import cn.axzo.orgmanax.dto.common.PersonProfileBriefDTO;
|
||||||
|
import cn.axzo.orgmanax.dto.common.RoleBriefDTO;
|
||||||
import cn.axzo.orgmanax.dto.common.WorkspaceBriefDTO;
|
import cn.axzo.orgmanax.dto.common.WorkspaceBriefDTO;
|
||||||
import cn.axzo.orgmanax.dto.cooperateship.dto.OrgCooperateShipDTO;
|
import cn.axzo.orgmanax.dto.cooperateship.dto.OrgCooperateShipDTO;
|
||||||
import cn.axzo.orgmanax.dto.job.dto.OrgJobBriefDTO;
|
import cn.axzo.orgmanax.dto.job.dto.OrgJobBriefDTO;
|
||||||
@ -24,6 +25,7 @@ import cn.axzo.orgmanax.infra.client.karma.KarmaDataObjectGateway;
|
|||||||
import cn.axzo.orgmanax.infra.client.karma.MergeMatchDataResp;
|
import cn.axzo.orgmanax.infra.client.karma.MergeMatchDataResp;
|
||||||
import cn.axzo.orgmanax.infra.client.profile.PersonProfileGateway;
|
import cn.axzo.orgmanax.infra.client.profile.PersonProfileGateway;
|
||||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfileGetPersonProfileListReq;
|
import cn.axzo.orgmanax.infra.client.profile.dto.ProfileGetPersonProfileListReq;
|
||||||
|
import cn.axzo.orgmanax.infra.client.tyr.RoleUserGateway;
|
||||||
import cn.axzo.orgmanax.infra.client.workspace.WorkspaceGateway;
|
import cn.axzo.orgmanax.infra.client.workspace.WorkspaceGateway;
|
||||||
import cn.axzo.orgmanax.infra.dao.cooperateship.repository.CooperateShipQueryRepository;
|
import cn.axzo.orgmanax.infra.dao.cooperateship.repository.CooperateShipQueryRepository;
|
||||||
import cn.axzo.orgmanax.infra.dao.node.repository.NodeQueryRepository;
|
import cn.axzo.orgmanax.infra.dao.node.repository.NodeQueryRepository;
|
||||||
@ -36,6 +38,7 @@ import cn.axzo.orgmanax.server.nodeuser.foundation.NodeUserFoundationService;
|
|||||||
import cn.axzo.orgmanax.server.nodeuser.service.NodeUserService;
|
import cn.axzo.orgmanax.server.nodeuser.service.NodeUserService;
|
||||||
import cn.axzo.orgmanax.server.nodeuser.service.processor.NodeUserProcessor;
|
import cn.axzo.orgmanax.server.nodeuser.service.processor.NodeUserProcessor;
|
||||||
import cn.axzo.orgmanax.server.util.QueryConditionAssembler;
|
import cn.axzo.orgmanax.server.util.QueryConditionAssembler;
|
||||||
|
import cn.axzo.tyr.feign.req.PageRoleUserReq;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.BooleanUtil;
|
import cn.hutool.core.util.BooleanUtil;
|
||||||
@ -43,14 +46,18 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -70,6 +77,7 @@ public class NodeUserServiceImpl implements NodeUserService {
|
|||||||
private final NodeUserFoundationService nodeUserFoundationService;
|
private final NodeUserFoundationService nodeUserFoundationService;
|
||||||
private final NodeService nodeService;
|
private final NodeService nodeService;
|
||||||
private final KarmaDataObjectGateway karmaDataObjectGateway;
|
private final KarmaDataObjectGateway karmaDataObjectGateway;
|
||||||
|
private final RoleUserGateway roleUserGateway;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeUserProcessor.ProcessResult process(ProcessNodeUserReq req) {
|
public NodeUserProcessor.ProcessResult process(ProcessNodeUserReq req) {
|
||||||
@ -259,6 +267,13 @@ public class NodeUserServiceImpl implements NodeUserService {
|
|||||||
.data(req.getProjectGroupId())
|
.data(req.getProjectGroupId())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
// groupWorkerStatus
|
||||||
|
if (req.getProjectGroupWorkerStatus() != null) {
|
||||||
|
listReq.addProfileQueries(MybatisPlusOperatorProcessor.JSONQuery.builder()
|
||||||
|
.jsonPath("$.status")
|
||||||
|
.data(req.getProjectGroupWorkerStatus())
|
||||||
|
.build());
|
||||||
|
}
|
||||||
return listReq;
|
return listReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,6 +338,7 @@ public class NodeUserServiceImpl implements NodeUserService {
|
|||||||
assemblePersonProfile(req, records);
|
assemblePersonProfile(req, records);
|
||||||
assembleCooperateShip(req, records);
|
assembleCooperateShip(req, records);
|
||||||
assembleSubordinateUsers(req, records);
|
assembleSubordinateUsers(req, records);
|
||||||
|
assembleRole(req, records);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<NodeUserDTO> filterRecords(ListNodeUserReq req, List<NodeUserDTO> records) {
|
private List<NodeUserDTO> filterRecords(ListNodeUserReq req, List<NodeUserDTO> records) {
|
||||||
@ -569,4 +585,36 @@ public class NodeUserServiceImpl implements NodeUserService {
|
|||||||
|
|
||||||
records.forEach(r -> r.setSubordinateUsers(subordinateUsers.getOrDefault(r.getOrganizationalUnitId() + ":" + r.getPersonId(), ImmutableList.of())));
|
records.forEach(r -> r.setSubordinateUsers(subordinateUsers.getOrDefault(r.getOrganizationalUnitId() + ":" + r.getPersonId(), ImmutableList.of())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assembleRole(ListNodeUserReq req, List<NodeUserDTO> records) {
|
||||||
|
if (CollUtil.isEmpty(records)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean need = (req.getNeeds() != null && BooleanUtil.isTrue(req.getNeeds().getRole()));
|
||||||
|
if (!need) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, List<RoleBriefDTO>> roleUsers = roleUserGateway.pageAll(PageRoleUserReq.builder()
|
||||||
|
.needRole(true)
|
||||||
|
.batchPersons(records.stream()
|
||||||
|
.map(e -> PageRoleUserReq.BatchPerson.builder()
|
||||||
|
.personId(e.getPersonId())
|
||||||
|
.workspaceId(e.getWorkspaceId())
|
||||||
|
.ouId(e.getOrganizationalUnitId())
|
||||||
|
.identityId(e.getIdentityId())
|
||||||
|
.identityType(e.getIdentityType()).build())
|
||||||
|
.collect(Collectors.toSet()))
|
||||||
|
.build())
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.groupingBy(e -> buildKey(e.getIdentityId(), e.getIdentityType(), e.getPersonId(), e.getWorkspaceId(), e.getOuId()),
|
||||||
|
Collectors.mapping(e -> BeanUtil.toBean(e.getRole(), RoleBriefDTO.class), Collectors.toList())));
|
||||||
|
|
||||||
|
records.forEach(r -> r.setRoles(roleUsers.getOrDefault(buildKey(r.getIdentityId(), r.getIdentityType(),
|
||||||
|
r.getPersonId(), r.getWorkspaceId(), r.getOrganizationalUnitId()), ImmutableList.of())));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildKey(Long identityId, Integer identityType, Long personId, Long workspaceId, Long ouId) {
|
||||||
|
return String.format("%s_%s_%s_%s_%s", identityId, identityType, personId, workspaceId, ouId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user