feat:[REQ-3282] 暂时提交
This commit is contained in:
parent
f9d7859d47
commit
433f763ac3
@ -1,13 +1,16 @@
|
|||||||
package cn.axzo.orgmanax.dto.node.dto;
|
package cn.axzo.orgmanax.dto.node.dto;
|
||||||
|
|
||||||
|
import cn.axzo.orgmanax.dto.cooperateship.dto.OrgCooperateShipDTO;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ -99,4 +102,10 @@ public class OrgNodeDTO implements Serializable {
|
|||||||
private Long isDelete = 0L;
|
private Long isDelete = 0L;
|
||||||
|
|
||||||
private OrgNodeDTO parentNode;
|
private OrgNodeDTO parentNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 协同关系信息
|
||||||
|
*/
|
||||||
|
private OrgCooperateShipDTO cooperateShip;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,11 +102,6 @@ public class ListNodeReq extends PageReqV2 {
|
|||||||
*/
|
*/
|
||||||
private Set<Long> workspaceIds;
|
private Set<Long> workspaceIds;
|
||||||
|
|
||||||
/**
|
|
||||||
* 需要返回管理员信息
|
|
||||||
*/
|
|
||||||
private Boolean needAdmin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 需要返回父节点信息
|
* 需要返回父节点信息
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
package cn.axzo.orgmanax.infra.client.tyr;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.axzo.orgmanax.infra.client.tyr.dto.BatchSuperAdminListReq;
|
||||||
|
import cn.axzo.orgmanax.infra.client.tyr.dto.BatchSuperAdminListResp;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface TyrSaasRoleUserClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量获取超管
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<BatchSuperAdminListResp> batchSuperAdminList(List<BatchSuperAdminListReq> param);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package cn.axzo.orgmanax.infra.client.tyr.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class BatchSuperAdminListReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作台ID
|
||||||
|
*/
|
||||||
|
private Long workspaceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单位ID
|
||||||
|
*/
|
||||||
|
private Long ouId;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package cn.axzo.orgmanax.infra.client.tyr.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BatchSuperAdminListResp {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自然人id
|
||||||
|
*/
|
||||||
|
private Long personId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份ID
|
||||||
|
*/
|
||||||
|
private Long identityId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份类型
|
||||||
|
*/
|
||||||
|
private Integer identityType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作台Id
|
||||||
|
*/
|
||||||
|
private Long workspaceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单位Id
|
||||||
|
*/
|
||||||
|
private Long ouId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -18,8 +18,8 @@ import lombok.experimental.SuperBuilder;
|
|||||||
import org.springframework.data.annotation.Transient;
|
import org.springframework.data.annotation.Transient;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.Objects;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组织节点表表实体类
|
* 组织节点表表实体类
|
||||||
@ -36,8 +36,8 @@ import java.util.Objects;
|
|||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class OrganizationalNode implements Serializable {
|
public class OrganizationalNode implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -14708237380609631L;
|
private static final long serialVersionUID = -14708237380609631L;
|
||||||
|
public static final String PATH_SPLITER = ",";
|
||||||
@TableId(
|
@TableId(
|
||||||
type = IdType.AUTO
|
type = IdType.AUTO
|
||||||
)
|
)
|
||||||
@ -161,5 +161,37 @@ public class OrganizationalNode implements Serializable {
|
|||||||
return Objects.equals(topNodeId, id);
|
return Objects.equals(topNodeId, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为根节点
|
||||||
|
* @param path
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isRootNode(String path) {
|
||||||
|
return !path.contains(PATH_SPLITER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从path中提取祖先的节点id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Long> parseAncestorIdsFromPath() {
|
||||||
|
if (isRootNode(path)) {
|
||||||
|
// 根节点没有父节点
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
List<Long> parentIds = parsePath(path);
|
||||||
|
// 移除路径的最后一个结点
|
||||||
|
return parentIds.subList(0, parentIds.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析path
|
||||||
|
* @param path
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Long> parsePath(String path) {
|
||||||
|
return Arrays.stream(path.split(PATH_SPLITER)).map(e -> Long.valueOf(e.trim())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,9 +13,7 @@ import com.google.common.base.Preconditions;
|
|||||||
import lombok.*;
|
import lombok.*;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tanjie@axzo.cn
|
* @author tanjie@axzo.cn
|
||||||
@ -66,6 +64,11 @@ public interface NodeQueryRepository {
|
|||||||
* @see ListNodeReq#getNeedParent()
|
* @see ListNodeReq#getNeedParent()
|
||||||
*/
|
*/
|
||||||
private NodeResp parentNode;
|
private NodeResp parentNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目ID
|
||||||
|
*/
|
||||||
|
private Long workspaceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -80,64 +83,49 @@ public interface NodeQueryRepository {
|
|||||||
/**
|
/**
|
||||||
* ids
|
* ids
|
||||||
*/
|
*/
|
||||||
|
@Builder.Default
|
||||||
@CriteriaField(field = "id", operator = Operator.IN)
|
@CriteriaField(field = "id", operator = Operator.IN)
|
||||||
private Set<Long> ids;
|
private Collection<Long> ids = Collections.emptySet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组织单位ids
|
* 组织单位ids
|
||||||
*/
|
*/
|
||||||
|
@Builder.Default
|
||||||
@CriteriaField(field = "ouId", operator = Operator.IN)
|
@CriteriaField(field = "ouId", operator = Operator.IN)
|
||||||
private Set<Long> ouIds;
|
private Collection<Long> ouIds = Collections.emptySet();
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 项目id集合
|
|
||||||
*/
|
|
||||||
private Set<Long> workspaceIds;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 指定部门类型
|
* 指定部门类型
|
||||||
*/
|
*/
|
||||||
|
@Builder.Default
|
||||||
@CriteriaField(field = "nodeType", operator = Operator.IN)
|
@CriteriaField(field = "nodeType", operator = Operator.IN)
|
||||||
private Set<Integer> includeOrgNodeTypes;
|
private Collection<Integer> includeOrgNodeTypes = Collections.emptySet();
|
||||||
/**
|
/**
|
||||||
* 排除部门类型
|
* 排除部门类型
|
||||||
*/
|
*/
|
||||||
|
@Builder.Default
|
||||||
@CriteriaField(field = "nodeType", operator = Operator.NOT_IN)
|
@CriteriaField(field = "nodeType", operator = Operator.NOT_IN)
|
||||||
private Set<Integer> excludeOrgNodeTypes;
|
private Collection<Integer> excludeOrgNodeTypes = Collections.emptySet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 顶级节点ID集合
|
* 顶级节点ID集合
|
||||||
*/
|
*/
|
||||||
|
@Builder.Default
|
||||||
@CriteriaField(field = "topNodeId", operator = Operator.IN)
|
@CriteriaField(field = "topNodeId", operator = Operator.IN)
|
||||||
private Set<Long> topNodeIds;
|
private Collection<Long> topNodeIds = Collections.emptySet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否查询删除的
|
* 是否查询删除的
|
||||||
*/
|
*/
|
||||||
private Boolean includeDelete;
|
@Builder.Default
|
||||||
|
private Boolean includeDelete = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 只返回topNode节点
|
* 只返回topNode节点
|
||||||
*/
|
*/
|
||||||
private Boolean isSelectTopNodeOnly;
|
@Builder.Default
|
||||||
|
private Boolean isSelectTopNodeOnly = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据workspace和ouId组合查询
|
|
||||||
*/
|
|
||||||
private Set<ListNodeReq.WorkspaceOuPair> workspaceOuPairs;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
class WorkspaceOuPair {
|
|
||||||
private Long workspaceId;
|
|
||||||
private Long ouId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,6 +61,10 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.axzo.tyr</groupId>
|
||||||
|
<artifactId>tyr-api</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@ -55,7 +55,7 @@ public class RpcWrapper {
|
|||||||
* @return
|
* @return
|
||||||
* @param <T>
|
* @param <T>
|
||||||
*/
|
*/
|
||||||
protected <T> T wrapApiResult(Supplier<ApiResult<T>> supplier) {
|
public static <T> T wrapApiResult(Supplier<ApiResult<T>> supplier) {
|
||||||
ApiResult<T> result = supplier.get();
|
ApiResult<T> result = supplier.get();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
throw new BusinessException(BizResultCode.RPC_ERROR);
|
throw new BusinessException(BizResultCode.RPC_ERROR);
|
||||||
|
|||||||
@ -0,0 +1,29 @@
|
|||||||
|
package cn.axzo.orgmanax.integration.sdk.tyr;
|
||||||
|
|
||||||
|
import cn.axzo.orgmanax.infra.client.tyr.TyrSaasRoleUserClient;
|
||||||
|
import cn.axzo.orgmanax.infra.client.tyr.dto.BatchSuperAdminListReq;
|
||||||
|
import cn.axzo.orgmanax.infra.client.tyr.dto.BatchSuperAdminListResp;
|
||||||
|
import cn.axzo.orgmanax.integration.core.RpcWrapper;
|
||||||
|
import cn.axzo.tyr.client.feign.TyrSaasRoleUserApi;
|
||||||
|
import cn.axzo.tyr.client.model.roleuser.dto.SuperAminInfoResp;
|
||||||
|
import cn.axzo.tyr.client.model.roleuser.req.RoleUserReq;
|
||||||
|
import cn.axzo.tyr.client.model.roleuser.req.SuperAdminParam;
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Component
|
||||||
|
public class TyrSaasRoleUserClientImpl implements TyrSaasRoleUserClient {
|
||||||
|
|
||||||
|
private final TyrSaasRoleUserApi tyrSaasRoleUserApi;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BatchSuperAdminListResp> batchSuperAdminList(List<BatchSuperAdminListReq> param) {
|
||||||
|
List<SuperAdminParam> reqList = BeanUtil.copyToList(param, SuperAdminParam.class);
|
||||||
|
List<SuperAminInfoResp> superAminInfoResps = RpcWrapper.wrapApiResult(() -> tyrSaasRoleUserApi.batchSuperAdminList(reqList));
|
||||||
|
return BeanUtil.copyToList(superAminInfoResps, BatchSuperAdminListResp.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,10 +1,16 @@
|
|||||||
package cn.axzo.orgmanax.server.node.foundation;
|
package cn.axzo.orgmanax.server.node.foundation;
|
||||||
|
|
||||||
|
import cn.axzo.orgmanax.infra.dao.cooperateship.entity.SaasCooperateShip;
|
||||||
import cn.axzo.orgmanax.infra.dao.node.entity.OrganizationalNode;
|
import cn.axzo.orgmanax.infra.dao.node.entity.OrganizationalNode;
|
||||||
|
import cn.axzo.orgmanax.infra.dao.node.repository.NodeQueryRepository;
|
||||||
import cn.axzo.orgmanax.server.node.foundation.req.NodeCreate;
|
import cn.axzo.orgmanax.server.node.foundation.req.NodeCreate;
|
||||||
import cn.axzo.orgmanax.server.node.foundation.req.NodeUpdate;
|
import cn.axzo.orgmanax.server.node.foundation.req.NodeUpdate;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public interface NodeFoundationService {
|
public interface NodeFoundationService {
|
||||||
/**
|
/**
|
||||||
* 创建部门
|
* 创建部门
|
||||||
@ -24,4 +30,35 @@ public interface NodeFoundationService {
|
|||||||
@Transactional(rollbackFor = Throwable.class)
|
@Transactional(rollbackFor = Throwable.class)
|
||||||
OrganizationalNode update(NodeUpdate req);
|
OrganizationalNode update(NodeUpdate req);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提取祖级的数据
|
||||||
|
* @param list
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
<T extends OrganizationalNode> Set<Long> extractAncestorIds(List<T> list);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提取父级信息
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
<T extends OrganizationalNode> Set<Long> extractParentIds(List<T> data);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提取path数据
|
||||||
|
* @param list 当前节点
|
||||||
|
* @param suffix 后缀
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
<T extends OrganizationalNode> Set<String> extractPaths(List<T> list, String suffix);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提取集合中的字段值
|
||||||
|
* @param currentNodeList
|
||||||
|
* @param function
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
<T> Set<T> extract(List<OrganizationalNode> currentNodeList, Function<OrganizationalNode, T> function);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package cn.axzo.orgmanax.server.node.foundation.impl;
|
|||||||
import cn.axzo.foundation.event.support.Event;
|
import cn.axzo.foundation.event.support.Event;
|
||||||
import cn.axzo.foundation.event.support.producer.EventProducer;
|
import cn.axzo.foundation.event.support.producer.EventProducer;
|
||||||
import cn.axzo.orgmanax.common.config.BizResultCode;
|
import cn.axzo.orgmanax.common.config.BizResultCode;
|
||||||
|
import cn.axzo.orgmanax.infra.dao.cooperateship.entity.SaasCooperateShip;
|
||||||
import cn.axzo.orgmanax.infra.dao.node.entity.OrganizationalNode;
|
import cn.axzo.orgmanax.infra.dao.node.entity.OrganizationalNode;
|
||||||
import cn.axzo.orgmanax.infra.dao.node.repository.NodeQueryRepository;
|
import cn.axzo.orgmanax.infra.dao.node.repository.NodeQueryRepository;
|
||||||
import cn.axzo.orgmanax.infra.dao.node.repository.NodeUpsertRepository;
|
import cn.axzo.orgmanax.infra.dao.node.repository.NodeUpsertRepository;
|
||||||
@ -13,10 +14,16 @@ import cn.axzo.orgmanax.server.node.foundation.NodeFoundationService;
|
|||||||
import cn.axzo.orgmanax.server.node.foundation.req.NodeCreate;
|
import cn.axzo.orgmanax.server.node.foundation.req.NodeCreate;
|
||||||
import cn.axzo.orgmanax.server.node.foundation.req.NodeUpdate;
|
import cn.axzo.orgmanax.server.node.foundation.req.NodeUpdate;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tanjie@axzo.cn
|
* @author tanjie@axzo.cn
|
||||||
* @date 2024/12/2 16:55
|
* @date 2024/12/2 16:55
|
||||||
@ -90,4 +97,26 @@ public class NodeFoundationServiceImpl implements NodeFoundationService {
|
|||||||
NodeUpsertRepository.UpdateReq updateReq = BeanUtil.toBean(req, NodeUpsertRepository.UpdateReq.class);
|
NodeUpsertRepository.UpdateReq updateReq = BeanUtil.toBean(req, NodeUpsertRepository.UpdateReq.class);
|
||||||
return nodeUpsertRepository.update(updateReq);
|
return nodeUpsertRepository.update(updateReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends OrganizationalNode> Set<Long> extractAncestorIds(List<T> list) {
|
||||||
|
return list.stream()
|
||||||
|
.flatMap(e -> e.parseAncestorIdsFromPath().stream())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends OrganizationalNode> Set<Long> extractParentIds(List<T> list) {
|
||||||
|
return list.stream().map(OrganizationalNode::getParentId).filter(parentId -> parentId != 0).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends OrganizationalNode> Set<String> extractPaths(List<T> list, String suffix) {
|
||||||
|
return list.stream().map(t -> StrUtil.isNotBlank(suffix) ? StrUtil.concat(true, t.getPath(), suffix) : t.getPath()).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> Set<T> extract(List<OrganizationalNode> list, Function<OrganizationalNode, T> function) {
|
||||||
|
return list.stream().map(function).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,10 +2,14 @@ package cn.axzo.orgmanax.server.node.service.impl;
|
|||||||
|
|
||||||
import cn.axzo.foundation.exception.Axssert;
|
import cn.axzo.foundation.exception.Axssert;
|
||||||
import cn.axzo.foundation.page.PageResp;
|
import cn.axzo.foundation.page.PageResp;
|
||||||
|
import cn.axzo.orgmanax.dto.cooperateship.enums.SaasCooperateShipCooperateTypeEnum;
|
||||||
import cn.axzo.orgmanax.dto.node.req.ListNodeReq;
|
import cn.axzo.orgmanax.dto.node.req.ListNodeReq;
|
||||||
import cn.axzo.orgmanax.dto.node.req.ProcessNodeReq;
|
import cn.axzo.orgmanax.dto.node.req.ProcessNodeReq;
|
||||||
import cn.axzo.orgmanax.dto.node.dto.OrgNodeDTO;
|
import cn.axzo.orgmanax.dto.node.dto.OrgNodeDTO;
|
||||||
import cn.axzo.orgmanax.common.config.BizResultCode;
|
import cn.axzo.orgmanax.common.config.BizResultCode;
|
||||||
|
import cn.axzo.orgmanax.infra.client.tyr.TyrSaasRoleUserClient;
|
||||||
|
import cn.axzo.orgmanax.infra.client.tyr.dto.BatchSuperAdminListReq;
|
||||||
|
import cn.axzo.orgmanax.infra.client.tyr.dto.BatchSuperAdminListResp;
|
||||||
import cn.axzo.orgmanax.infra.dao.cooperateship.entity.SaasCooperateShip;
|
import cn.axzo.orgmanax.infra.dao.cooperateship.entity.SaasCooperateShip;
|
||||||
import cn.axzo.orgmanax.dto.nodeuser.req.ListNodeUserReq;
|
import cn.axzo.orgmanax.dto.nodeuser.req.ListNodeUserReq;
|
||||||
import cn.axzo.orgmanax.infra.dao.cooperateship.repository.CooperateShipQueryRepository;
|
import cn.axzo.orgmanax.infra.dao.cooperateship.repository.CooperateShipQueryRepository;
|
||||||
@ -14,21 +18,24 @@ import cn.axzo.orgmanax.infra.dao.nodeuser.entity.OrganizationalNodeUser;
|
|||||||
import cn.axzo.orgmanax.infra.dao.nodeuser.repository.NodeUserQueryRepository;
|
import cn.axzo.orgmanax.infra.dao.nodeuser.repository.NodeUserQueryRepository;
|
||||||
import cn.axzo.orgmanax.infra.dao.orgjob.entity.OrgJob;
|
import cn.axzo.orgmanax.infra.dao.orgjob.entity.OrgJob;
|
||||||
import cn.axzo.orgmanax.infra.dao.orgjob.repository.OrgJobQueryRepository;
|
import cn.axzo.orgmanax.infra.dao.orgjob.repository.OrgJobQueryRepository;
|
||||||
|
import cn.axzo.orgmanax.server.node.foundation.NodeFoundationService;
|
||||||
import cn.axzo.orgmanax.server.node.service.NodeService;
|
import cn.axzo.orgmanax.server.node.service.NodeService;
|
||||||
import cn.axzo.orgmanax.server.node.service.processor.NodeProcessor;
|
import cn.axzo.orgmanax.server.node.service.processor.NodeProcessor;
|
||||||
import cn.axzo.orgmanax.server.nodeuser.foundation.NodeUserFoundationService;
|
import cn.axzo.orgmanax.server.nodeuser.foundation.NodeUserFoundationService;
|
||||||
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.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
|
import cn.hutool.core.util.BooleanUtil;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
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 org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.function.Consumer;
|
||||||
import java.util.Objects;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -42,6 +49,7 @@ public class NodeServiceImpl implements NodeService {
|
|||||||
private final OrgJobQueryRepository orgJobQueryRepository;
|
private final OrgJobQueryRepository orgJobQueryRepository;
|
||||||
private final NodeUserFoundationService nodeUserFoundationService;
|
private final NodeUserFoundationService nodeUserFoundationService;
|
||||||
private final CooperateShipQueryRepository cooperateShipQueryRepository;
|
private final CooperateShipQueryRepository cooperateShipQueryRepository;
|
||||||
|
private final NodeFoundationService nodeFoundationService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeProcessor.ProcessResult process(ProcessNodeReq req) {
|
public NodeProcessor.ProcessResult process(ProcessNodeReq req) {
|
||||||
@ -68,16 +76,27 @@ public class NodeServiceImpl implements NodeService {
|
|||||||
@Override
|
@Override
|
||||||
public PageResp<OrgNodeDTO> page(ListNodeReq req) {
|
public PageResp<OrgNodeDTO> page(ListNodeReq req) {
|
||||||
|
|
||||||
List<NodeUserQueryRepository.NodeUserResp> nodeUsers = Collections.emptyList();
|
// 初始化:组织节点查询对象
|
||||||
List<Long> topNodeIds;
|
NodeQueryRepository.ListReq.ListReqBuilder<?, ?> reqListBuilder = NodeQueryRepository.ListReq.builder();
|
||||||
|
reqListBuilder
|
||||||
|
.page(req.getPage())
|
||||||
|
.pageSize(req.getPageSize())
|
||||||
|
.ids(req.getIds())
|
||||||
|
.ouIds(req.getOuIds())
|
||||||
|
.includeOrgNodeTypes(req.getIncludeOrgNodeTypes())
|
||||||
|
.excludeOrgNodeTypes(req.getExcludeOrgNodeTypes())
|
||||||
|
.includeDelete(req.getIncludeDelete())
|
||||||
|
.isSelectTopNodeOnly(req.getIsSelectTopNodeOnly());
|
||||||
|
// 初始化:空响应
|
||||||
PageResp<OrgNodeDTO> emptyPageResp = PageResp.<OrgNodeDTO>builder()
|
PageResp<OrgNodeDTO> emptyPageResp = PageResp.<OrgNodeDTO>builder()
|
||||||
.current(req.getPage())
|
.current(req.getPage())
|
||||||
.size(req.getPageSize())
|
.size(req.getPageSize())
|
||||||
.total(0)
|
.total(0)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 获取部门用户信息, 若获取不到直接返回
|
// 获取部门用户信息, 若获取不到直接返回
|
||||||
if (Objects.nonNull(req.getPersonId())) {
|
if (Objects.nonNull(req.getPersonId())) {
|
||||||
nodeUsers = nodeUserQueryRepository.list(ListNodeUserReq
|
List<NodeUserQueryRepository.NodeUserResp> nodeUsers = nodeUserQueryRepository.list(ListNodeUserReq
|
||||||
.builder().build());
|
.builder().build());
|
||||||
if (CollUtil.isEmpty(nodeUsers)) {
|
if (CollUtil.isEmpty(nodeUsers)) {
|
||||||
return emptyPageResp;
|
return emptyPageResp;
|
||||||
@ -95,30 +114,57 @@ public class NodeServiceImpl implements NodeService {
|
|||||||
if (CollUtil.isEmpty(nodeUsers)) {
|
if (CollUtil.isEmpty(nodeUsers)) {
|
||||||
return emptyPageResp;
|
return emptyPageResp;
|
||||||
}
|
}
|
||||||
// 设置ids
|
reqListBuilder.ids(nodeUsers.stream().map(OrganizationalNodeUser::getOrganizationalNodeId).collect(Collectors.toSet()));
|
||||||
req.setIds(nodeUsers.stream().map(OrganizationalNodeUser::getOrganizationalNodeId).collect(Collectors.toSet()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 项目ID
|
// 根据项目ID获取topNodeId进行组织节点过滤
|
||||||
if (CollUtil.isNotEmpty(req.getWorkspaceIds())) {
|
if (CollUtil.isNotEmpty(req.getWorkspaceIds())) {
|
||||||
topNodeIds = CollUtil.map(cooperateShipQueryRepository.list(CooperateShipQueryRepository.ListReq.builder()
|
List<Long> topNodeIds = CollUtil.map(cooperateShipQueryRepository.list(CooperateShipQueryRepository.ListReq.builder()
|
||||||
.workspaceIds(req.getWorkspaceIds())
|
.workspaceIds(req.getWorkspaceIds())
|
||||||
.workspaceOuPairs(BeanUtil.copyToList(req.getWorkspaceIds(), CooperateShipQueryRepository.WorkspaceOuPair.class))
|
.workspaceOuPairs(BeanUtil.copyToList(req.getWorkspaceIds(), CooperateShipQueryRepository.WorkspaceOuPair.class))
|
||||||
.build()), SaasCooperateShip::getOrganizationalNodeId, true);
|
.build()), SaasCooperateShip::getOrganizationalNodeId, true);
|
||||||
|
if (CollUtil.isEmpty(topNodeIds)) {
|
||||||
|
return emptyPageResp;
|
||||||
|
}
|
||||||
|
reqListBuilder.topNodeIds(new HashSet<>(topNodeIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeQueryRepository.ListReq.ListReqBuilder<?, ?> builder = NodeQueryRepository.ListReq.builder();
|
// 查询组织节点
|
||||||
builder.page(req.getPage()).pageSize(req.getPageSize());
|
PageResp<NodeQueryRepository.NodeResp> page = nodeQueryRepository.page(reqListBuilder.build());
|
||||||
|
if (CollUtil.isEmpty(page.getData())) {
|
||||||
if (CollUtil.isNotEmpty(nodeUsers)) {
|
return emptyPageResp;
|
||||||
builder.ids(nodeUsers.stream().map(OrganizationalNodeUser::getOrganizationalNodeId).collect(Collectors.toSet()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PageResp<NodeQueryRepository.NodeResp> page = nodeQueryRepository.page(NodeQueryRepository.ListReq.builder()
|
// 是否查询祖父节点
|
||||||
.build());
|
if (BooleanUtil.isTrue(req.getIncludeParent())) {
|
||||||
|
nodeFoundationService.extractParentIds(page.getData());
|
||||||
|
}
|
||||||
|
|
||||||
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());
|
||||||
// assemble data if needed
|
|
||||||
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