feat:[REQ-3282] 暂时提交,完成节点基本查询
This commit is contained in:
parent
433f763ac3
commit
0b6ca636f5
@ -114,15 +114,32 @@ public interface NodeQueryRepository {
|
|||||||
@CriteriaField(field = "topNodeId", operator = Operator.IN)
|
@CriteriaField(field = "topNodeId", operator = Operator.IN)
|
||||||
private Collection<Long> topNodeIds = Collections.emptySet();
|
private Collection<Long> topNodeIds = Collections.emptySet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* path右值
|
||||||
|
*/
|
||||||
|
@CriteriaField(ignore = true)
|
||||||
|
@Builder.Default
|
||||||
|
private Set<String> pathsRight = Collections.emptySet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* path右值
|
||||||
|
*/
|
||||||
|
@CriteriaField(field = "parentId", operator = Operator.IN)
|
||||||
|
@Builder.Default
|
||||||
|
private Set<Long> parentIds = Collections.emptySet();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否查询删除的
|
* 是否查询删除的
|
||||||
*/
|
*/
|
||||||
|
@CriteriaField(ignore = true)
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private Boolean includeDelete = false;
|
private Boolean includeDelete = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 只返回topNode节点
|
* 只返回topNode节点
|
||||||
*/
|
*/
|
||||||
|
@CriteriaField(ignore = true)
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private Boolean isSelectTopNodeOnly = false;
|
private Boolean isSelectTopNodeOnly = false;
|
||||||
|
|
||||||
|
|||||||
@ -37,10 +37,20 @@ public class NodeQueryRepositoryImpl implements NodeQueryRepository {
|
|||||||
IPage<OrganizationalNode> page = PageConverter.toMybatis(req, OrganizationalNode.class);
|
IPage<OrganizationalNode> page = PageConverter.toMybatis(req, OrganizationalNode.class);
|
||||||
QueryWrapper<OrganizationalNode> wrapper = QueryWrapperHelper.fromBean(req, OrganizationalNode.class);
|
QueryWrapper<OrganizationalNode> wrapper = QueryWrapperHelper.fromBean(req, OrganizationalNode.class);
|
||||||
|
|
||||||
if (req.getIsSelectTopNodeOnly()) {
|
if (BooleanUtil.isTrue(req.getIsSelectTopNodeOnly())) {
|
||||||
wrapper.apply(" top_node_id = id ");
|
wrapper.apply(" top_node_id = id ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询子集
|
||||||
|
if (CollUtil.isNotEmpty(req.getPathsRight())) {
|
||||||
|
// 遍历pathsRight转换成wrapper
|
||||||
|
wrapper.and(w -> {
|
||||||
|
for (String pathRight : req.getPathsRight()) {
|
||||||
|
w.or().likeRight("path", pathRight);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
IPage<NodeResp> results = nodeDao.page(page, wrapper)
|
IPage<NodeResp> results = nodeDao.page(page, wrapper)
|
||||||
.convert(e -> BeanUtil.toBean(e, NodeResp.class));
|
.convert(e -> BeanUtil.toBean(e, NodeResp.class));
|
||||||
PageResp<NodeResp> resp = PageConverter.toResp(results);
|
PageResp<NodeResp> resp = PageConverter.toResp(results);
|
||||||
|
|||||||
@ -59,6 +59,6 @@ public interface NodeFoundationService {
|
|||||||
* @param function
|
* @param function
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
<T> Set<T> extract(List<OrganizationalNode> currentNodeList, Function<OrganizationalNode, T> function);
|
<R, T extends OrganizationalNode> Set<R> extract(List<T> currentNodeList, Function<T, R> function);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,7 +116,7 @@ public class NodeFoundationServiceImpl implements NodeFoundationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> Set<T> extract(List<OrganizationalNode> list, Function<OrganizationalNode, T> function) {
|
public <R, T extends OrganizationalNode> Set<R> extract(List<T> list, Function<T, R> function) {
|
||||||
return list.stream().map(function).collect(Collectors.toSet());
|
return list.stream().map(function).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,36 +135,40 @@ public class NodeServiceImpl implements NodeService {
|
|||||||
return emptyPageResp;
|
return emptyPageResp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 是否查询祖父节点
|
// 是否查询父级节点
|
||||||
if (BooleanUtil.isTrue(req.getIncludeParent())) {
|
if (BooleanUtil.isTrue(req.getIncludeParent())) {
|
||||||
nodeFoundationService.extractParentIds(page.getData());
|
Set<Long> parentIds = nodeFoundationService.extractParentIds(page.getData());
|
||||||
|
List<NodeQueryRepository.NodeResp> parentNodes = nodeQueryRepository.list(NodeQueryRepository.ListReq.builder().ids(parentIds).build());
|
||||||
|
page.getData().addAll(parentNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 是否查询祖父节点
|
||||||
|
if (BooleanUtil.isTrue(req.getIncludeAncestors())) {
|
||||||
|
Set<Long> ancestorIds = nodeFoundationService.extractAncestorIds(page.getData());
|
||||||
|
List<NodeQueryRepository.NodeResp> parentNodes = nodeQueryRepository.list(NodeQueryRepository.ListReq.builder().ids(ancestorIds).build());
|
||||||
|
page.getData().addAll(parentNodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否查询子孙节点
|
||||||
|
if (BooleanUtil.isTrue(req.getIncludeDescendants())) {
|
||||||
|
Set<String> paths = nodeFoundationService.extractPaths(page.getData(), ",");
|
||||||
|
List<NodeQueryRepository.NodeResp> descendantsNodes = nodeQueryRepository.list(
|
||||||
|
NodeQueryRepository.ListReq.builder()
|
||||||
|
.pathsRight(paths).build());
|
||||||
|
page.getData().addAll(descendantsNodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否查询子节点
|
||||||
|
if (BooleanUtil.isTrue(req.getIncludeChildren())) {
|
||||||
|
Set<Long> ids = nodeFoundationService.extract(page.getData(), NodeQueryRepository.NodeResp::getId);
|
||||||
|
List<NodeQueryRepository.NodeResp> descendantShipNodes = nodeQueryRepository.list(
|
||||||
|
NodeQueryRepository.ListReq.builder()
|
||||||
|
.parentIds(ids).build());
|
||||||
|
page.getData().addAll(descendantShipNodes);
|
||||||
|
}
|
||||||
List<OrgNodeDTO> records = page.getData().stream().map(e -> BeanUtil.toBean(e, OrgNodeDTO.class)).collect(Collectors.toList());
|
List<OrgNodeDTO> records = page.getData().stream().map(e -> BeanUtil.toBean(e, OrgNodeDTO.class)).collect(Collectors.toList());
|
||||||
return new PageResp<>(page.getTotal(), page.getSize(), page.getCurrent(), records);
|
return new PageResp<>(page.getTotal(), page.getSize(), page.getCurrent(), records);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// private void assembleCooperateShip(List<OrganizationalNodeResp> nodes) {
|
|
||||||
// List<Long> nodeTopNodeIds = nodes.stream().map(OrganizationalNodeResp::getTopNodeId).distinct().collect(Collectors.toList());
|
|
||||||
// Map<Long, SaasCooperateShip> cooperateShips = saasCooperateShipDao.listByBO(SaasCooperateShipBO.builder()
|
|
||||||
// .organizationalNodeIds(nodeTopNodeIds)
|
|
||||||
// .build()).stream().collect(Collectors.toMap(SaasCooperateShip::getOrganizationalNodeId, Function.identity()));
|
|
||||||
// // 补充 workspaceId 和 cooperateType
|
|
||||||
// nodes.forEach(node -> {
|
|
||||||
// SaasCooperateShip cooperateShip = cooperateShips.get(node.getTopNodeId());
|
|
||||||
// if (cooperateShip != null) {
|
|
||||||
// node.setWorkspaceId(cooperateShip.getWorkspaceId());
|
|
||||||
// // 平台班组类型,找到的是 平台班组所属的企业
|
|
||||||
// if (Objects.equals(node.getNodeType(), OrganizationalNodeTypeEnum.TEAM.getValue())) {
|
|
||||||
// node.setCooperateType(SaasCooperateShipCooperateTypeEnum.ENT_TEAM.getCode());
|
|
||||||
// node.setCooperateStatus(SaasCooperateShipStatusEnum.ACTIVE.getStatus());
|
|
||||||
// } else {
|
|
||||||
// node.setCooperateType(cooperateShip.getCooperateType());
|
|
||||||
// node.setCooperateStatus(cooperateShip.getStatus());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user