feature(REQ-3282): node查询,unit接口定义
This commit is contained in:
parent
9e863a1b47
commit
1731607ce0
@ -15,6 +15,7 @@ import lombok.NoArgsConstructor;
|
||||
public class NodeProcessReq {
|
||||
private Long id;
|
||||
private Long operatorId;
|
||||
private String description;
|
||||
private Action action;
|
||||
private JSONObject param;
|
||||
|
||||
|
||||
@ -92,9 +92,11 @@ public class OrgNodeDTO implements Serializable {
|
||||
*/
|
||||
private JSONObject profile;
|
||||
|
||||
protected Date createAt;
|
||||
protected Long createBy;
|
||||
protected Date updateAt;
|
||||
protected Long updateBy;
|
||||
protected Long isDelete = 0L;
|
||||
private Date createAt;
|
||||
private Long createBy;
|
||||
private Date updateAt;
|
||||
private Long updateBy;
|
||||
private Long isDelete = 0L;
|
||||
|
||||
private OrgNodeDTO parentNode;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import cn.axzo.orgmanax.api.unit.req.CreateUnitReq;
|
||||
import cn.axzo.orgmanax.api.unit.req.ListUnitReq;
|
||||
import cn.axzo.orgmanax.api.unit.req.UpdateUnitReq;
|
||||
import cn.axzo.orgmanax.api.unit.resp.CreateUnitResp;
|
||||
import cn.axzo.orgmanax.api.unit.resp.ListUnitResp;
|
||||
import cn.axzo.orgmanax.api.unit.resp.OrgUnitDTO;
|
||||
import cn.axzo.orgmanax.api.unit.resp.UpdateUnitResp;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -29,7 +29,15 @@ public interface OrgUnitApi {
|
||||
@PostMapping("/api/org/unit/update")
|
||||
ApiResult<UpdateUnitResp> update(@RequestBody @Validated UpdateUnitReq req);
|
||||
|
||||
/**
|
||||
* 分页列表接口。
|
||||
* XXX:本接口默认分页,单页最多返回1000条数据。调用方使用时需注意。
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
* @see ListUnitReq#getPageSize()
|
||||
*/
|
||||
@PostMapping("/api/org/unit/list")
|
||||
ApiResult<ListUnitResp> list(@RequestBody @Validated ListUnitReq req);
|
||||
ApiResult<OrgUnitDTO> list(@RequestBody @Validated ListUnitReq req);
|
||||
|
||||
}
|
||||
|
||||
@ -1,18 +1,50 @@
|
||||
package cn.axzo.orgmanax.api.unit.req;
|
||||
|
||||
import cn.axzo.foundation.dao.support.wrapper.CriteriaField;
|
||||
import cn.axzo.foundation.dao.support.wrapper.Operator;
|
||||
import cn.axzo.foundation.page.IPageReq;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Builder
|
||||
public class ListUnitReq implements Serializable {
|
||||
@SuperBuilder
|
||||
public class ListUnitReq implements IPageReq {
|
||||
|
||||
private String test;
|
||||
@CriteriaField
|
||||
private Long id;
|
||||
@CriteriaField(field = "id", operator = Operator.IN)
|
||||
private Set<Long> ids;
|
||||
/**
|
||||
* 用于遍历数据
|
||||
*/
|
||||
@CriteriaField(field = "id", operator = Operator.GT)
|
||||
private Long idGt;
|
||||
@CriteriaField
|
||||
private Long parentId;
|
||||
@CriteriaField(field = "parentId", operator = Operator.IN)
|
||||
private Set<Long> parentIds;
|
||||
@CriteriaField
|
||||
private String name;
|
||||
@CriteriaField(field = "name", operator = Operator.LIKE)
|
||||
private String nameLike;
|
||||
@CriteriaField
|
||||
private Integer nature;
|
||||
@CriteriaField
|
||||
private String uniformSocialCreditCode;
|
||||
@CriteriaField
|
||||
private Integer entTag;
|
||||
@CriteriaField(ignore = true)
|
||||
Integer page;
|
||||
@CriteriaField(ignore = true)
|
||||
Integer pageSize;
|
||||
@CriteriaField(ignore = true)
|
||||
List<String> sort;
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
package cn.axzo.orgmanax.api.unit.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@Data
|
||||
public class ListUnitResp implements Serializable {
|
||||
|
||||
}
|
||||
@ -0,0 +1,225 @@
|
||||
package cn.axzo.orgmanax.api.unit.resp;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class OrgUnitDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 父单位id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 单位名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 单位logo url地址
|
||||
*/
|
||||
private String logoUrl;
|
||||
|
||||
/**
|
||||
* 单位介绍
|
||||
*/
|
||||
private String introduction;
|
||||
|
||||
/**
|
||||
* 单位类型 1:总包单位 2:建设单位 3:监理单位 4:劳务分包 5:专业分包 6.项目外班组 7.安心筑平台
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 单位性质:0:其他 1:团队 2:企业 3:班组
|
||||
*/
|
||||
private Integer nature;
|
||||
|
||||
/**
|
||||
* 营业执照号图片url地址
|
||||
*/
|
||||
private String usccPicUrl;
|
||||
|
||||
/**
|
||||
* 认证公函
|
||||
*/
|
||||
private String certificationLetterUrl;
|
||||
|
||||
/**
|
||||
* 统一社会信用码
|
||||
*/
|
||||
private String uniformSocialCreditCode;
|
||||
|
||||
/**
|
||||
* 法人代表姓名
|
||||
*/
|
||||
private String legalName;
|
||||
|
||||
/**
|
||||
* 法人手机号
|
||||
*/
|
||||
private String legalPhone;
|
||||
|
||||
/**
|
||||
* 法人代表身份证
|
||||
*/
|
||||
private String legalIdCard;
|
||||
|
||||
/**
|
||||
* 班组长身份id
|
||||
*/
|
||||
private Long identityId;
|
||||
|
||||
/**
|
||||
* 身份类型 1.无身份 2.班组长
|
||||
*/
|
||||
private Integer identityType;
|
||||
|
||||
/**
|
||||
* 单位注册地址
|
||||
*/
|
||||
private String registeredAddress;
|
||||
|
||||
/**
|
||||
* 存续状态
|
||||
*/
|
||||
private String survivalStatus;
|
||||
|
||||
/**
|
||||
* 省市区区编码,以“/”隔开
|
||||
*/
|
||||
private String areaCode;
|
||||
|
||||
/**
|
||||
* 省市区名字,以“/”隔开(四川省/成都市/武侯区)
|
||||
*/
|
||||
private String areaName;
|
||||
|
||||
/**
|
||||
* 企业详细地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 企业POI地址
|
||||
*/
|
||||
private String addressPoi;
|
||||
|
||||
/**
|
||||
* 经纬度,以“/”隔开经度,纬度(124.32421/142.424432)
|
||||
*/
|
||||
private String longLat;
|
||||
|
||||
/**
|
||||
* 官网
|
||||
*/
|
||||
private String website;
|
||||
|
||||
/**
|
||||
* 状态:0:初始化,10:审核中,20:审核拒绝,30:审核通过,40:未认证,50:已认证
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否启用:0禁用,1启用
|
||||
*/
|
||||
private Integer enable;
|
||||
|
||||
/**
|
||||
* 来源场景:0:其他,1:客户注册,2:平台录入,3:总包创建,4:网络抓取,5:班组创建
|
||||
*/
|
||||
private Integer sceneType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String memo;
|
||||
|
||||
/**
|
||||
* 是否删除 0否,其他是
|
||||
*/
|
||||
private Long isDelete = 0L;
|
||||
|
||||
/**
|
||||
* 扩展字段
|
||||
*/
|
||||
private JSONObject extra;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createAt;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateAt;
|
||||
|
||||
/**
|
||||
* 迁移数据临时源id
|
||||
*/
|
||||
private Long tempSourceId;
|
||||
|
||||
/**
|
||||
* 企业标签1正式企业 2测试企业
|
||||
*/
|
||||
private Integer entTag;
|
||||
|
||||
/**
|
||||
* 营业期限(纯字符串不做解析)
|
||||
*/
|
||||
private String operatingPeriod;
|
||||
|
||||
/**
|
||||
* 经营范围(纯字符串不做解析)
|
||||
*/
|
||||
private String businessScope;
|
||||
|
||||
/**
|
||||
* 历史平台班组的同步数据,0:还未同步,1:同步完成
|
||||
*/
|
||||
private Integer syncState;
|
||||
|
||||
/**
|
||||
* 企业邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 企业电话
|
||||
*/
|
||||
private String telephone;
|
||||
|
||||
/**
|
||||
* 省编码
|
||||
*/
|
||||
private String provinceCode;
|
||||
|
||||
/**
|
||||
* 省份名称
|
||||
*/
|
||||
private String provinceName;
|
||||
|
||||
/**
|
||||
* 市编码
|
||||
*/
|
||||
private String cityCode;
|
||||
|
||||
/**
|
||||
* 市名称
|
||||
*/
|
||||
private String cityName;
|
||||
|
||||
}
|
||||
@ -1,12 +1,15 @@
|
||||
package cn.axzo.orgmanax.infra.dao.node.repository;
|
||||
|
||||
|
||||
import cn.axzo.foundation.exception.Axssert;
|
||||
import cn.axzo.orgmanax.infra.dao.node.entity.OrganizationalNode;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@ -18,7 +21,7 @@ import java.util.Set;
|
||||
public interface NodeUpsertRepository {
|
||||
OrganizationalNode create(OrganizationalNode node);
|
||||
|
||||
OrganizationalNode update(OrganizationalNode node);
|
||||
OrganizationalNode update(UpdateReq node);
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ -33,17 +36,22 @@ public interface NodeUpsertRepository {
|
||||
private Long operatorId;
|
||||
}
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Builder
|
||||
class UpdateReq {
|
||||
@SuperBuilder
|
||||
class UpdateReq extends OrganizationalNode {
|
||||
private Long id;
|
||||
private OrganizationalNode node;
|
||||
private String scene;
|
||||
/**
|
||||
* 由于updateById不支持将值设置为null,这里提供这个
|
||||
*/
|
||||
Set<SFunction<OrganizationalNode, ?>> setNullFields = new HashSet<>();
|
||||
|
||||
public void check() {
|
||||
Axssert.checkNonNull(getId(), "要更新的部门id不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
package cn.axzo.orgmanax.infra.dao.node.repository.impl;
|
||||
|
||||
import cn.axzo.foundation.exception.Axssert;
|
||||
import cn.axzo.orgmanax.infra.dao.node.entity.OrganizationalNode;
|
||||
import cn.axzo.orgmanax.infra.dao.node.dao.NodeDao;
|
||||
import cn.axzo.orgmanax.infra.dao.node.entity.OrganizationalNode;
|
||||
import cn.axzo.orgmanax.infra.dao.node.repository.NodeUpsertRepository;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -25,9 +27,14 @@ public class NodeUpsertRepositoryImpl implements NodeUpsertRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrganizationalNode update(OrganizationalNode node) {
|
||||
Axssert.checkNonNull(node.getId(), "更新部门,部门id不能为空");
|
||||
nodeDao.updateById(node);
|
||||
return nodeDao.getById(node.getId());
|
||||
public OrganizationalNode update(UpdateReq req) {
|
||||
Axssert.checkNonNull(req.getId(), "更新部门,部门id不能为空");
|
||||
|
||||
LambdaUpdateChainWrapper<OrganizationalNode> wrapper = nodeDao.lambdaUpdate().eq(OrganizationalNode::getId, req.getId());
|
||||
if (CollUtil.isNotEmpty(req.getSetNullFields())) {
|
||||
req.getSetNullFields().forEach(e -> wrapper.set(e, null));
|
||||
}
|
||||
wrapper.update(req);
|
||||
return nodeDao.getById(req.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package cn.axzo.orgmanax.server.node.foundation;
|
||||
|
||||
import cn.axzo.orgmanax.infra.dao.node.entity.OrganizationalNode;
|
||||
import cn.axzo.orgmanax.server.node.foundation.req.NodeCreate;
|
||||
import cn.axzo.orgmanax.server.node.foundation.req.NodeUpdate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface NodeFoundationService {
|
||||
@ -14,6 +15,13 @@ public interface NodeFoundationService {
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
OrganizationalNode create(NodeCreate nodeCreate);
|
||||
|
||||
|
||||
/**
|
||||
* 该接口为更新的收口接口,业务使用的时候,需要自行做业务判断
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
OrganizationalNode update(NodeUpdate req);
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package cn.axzo.orgmanax.server.node.foundation.impl;
|
||||
|
||||
import cn.axzo.foundation.event.support.Event;
|
||||
import cn.axzo.foundation.event.support.producer.EventProducer;
|
||||
import cn.axzo.foundation.exception.Axssert;
|
||||
import cn.axzo.orgmanax.common.config.BizResultCode;
|
||||
import cn.axzo.orgmanax.infra.dao.node.entity.OrganizationalNode;
|
||||
import cn.axzo.orgmanax.infra.dao.node.repository.NodeQueryRepository;
|
||||
@ -12,6 +11,8 @@ import cn.axzo.orgmanax.server.node.event.inner.NodeEventType;
|
||||
import cn.axzo.orgmanax.server.node.event.inner.payload.NodeUpsertedPayload;
|
||||
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.NodeUpdate;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -55,10 +56,13 @@ public class NodeFoundationServiceImpl implements NodeFoundationService {
|
||||
nodeUpsertRepository.create(organizationalNode);
|
||||
|
||||
// 重新计算path、topNodeId等数据。 未来也可以添加workspaceId等信息
|
||||
organizationalNode.calcPath(parentNode);
|
||||
String path = organizationalNode.calcPath(parentNode);
|
||||
|
||||
//更新数据
|
||||
nodeUpsertRepository.update(organizationalNode);
|
||||
// 更新path数据
|
||||
nodeUpsertRepository.update(NodeUpsertRepository.UpdateReq.builder()
|
||||
.id(organizationalNode.getId())
|
||||
.path(path)
|
||||
.build());
|
||||
NodeQueryRepository.NodeResp saved = nodeQueryRepository.one(NodeQueryRepository.OneReq.builder().id(organizationalNode.getId()).build());
|
||||
|
||||
// 发送数据变更基础MQ
|
||||
@ -80,4 +84,9 @@ public class NodeFoundationServiceImpl implements NodeFoundationService {
|
||||
return nodeQueryRepository.one(NodeQueryRepository.OneReq.builder().id(organizationalNode.getId()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrganizationalNode update(NodeUpdate req) {
|
||||
NodeUpsertRepository.UpdateReq updateReq = BeanUtil.toBean(req, NodeUpsertRepository.UpdateReq.class);
|
||||
return nodeUpsertRepository.update(updateReq);
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ public interface NodeProcessor {
|
||||
|
||||
JSONObject params;
|
||||
|
||||
String processScene;
|
||||
String description;
|
||||
Long operatorId;
|
||||
String operatorName;
|
||||
}
|
||||
|
||||
@ -1,11 +1,18 @@
|
||||
package cn.axzo.orgmanax.server.node.service.processor.impl;
|
||||
|
||||
import cn.axzo.foundation.exception.Axssert;
|
||||
import cn.axzo.orgmanax.infra.dao.node.entity.OrganizationalNode;
|
||||
import cn.axzo.orgmanax.server.node.foundation.NodeFoundationService;
|
||||
import cn.axzo.orgmanax.server.node.foundation.req.NodeUpdate;
|
||||
import cn.axzo.orgmanax.server.node.service.processor.NodeProcessor;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -14,18 +21,26 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class UpdateNodeProcessor implements NodeProcessor {
|
||||
|
||||
private final NodeFoundationService nodeFoundationService;
|
||||
|
||||
@Override
|
||||
public ProcessResult process(ProcessContext context) {
|
||||
Axssert.checkNonNull(context.getParams(), "更新部门失败,参数不能为null");
|
||||
Axssert.checkNonNull(context.getNode(), "要更新的部门不存在");
|
||||
Param param = context.getParams().toJavaObject(Param.class);
|
||||
// check 不可编辑的内容 ()
|
||||
param.setId(context.getNode().getId());
|
||||
|
||||
// TODO
|
||||
return null;
|
||||
NodeUpdate update = param.toNodeUpdate();
|
||||
OrganizationalNode updated = nodeFoundationService.update(update);
|
||||
return ProcessResult.success((JSONObject) JSON.toJSON(updated));
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅接收允许直接被编辑的字段
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@ -37,5 +52,10 @@ public class UpdateNodeProcessor implements NodeProcessor {
|
||||
private Integer sort;
|
||||
private Integer syncState;
|
||||
private Integer extType;
|
||||
|
||||
public NodeUpdate toNodeUpdate() {
|
||||
NodeUpdate update = BeanUtil.toBean(this, NodeUpdate.class);
|
||||
return update;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,8 +6,9 @@ import cn.axzo.orgmanax.api.unit.req.CreateUnitReq;
|
||||
import cn.axzo.orgmanax.api.unit.req.ListUnitReq;
|
||||
import cn.axzo.orgmanax.api.unit.req.UpdateUnitReq;
|
||||
import cn.axzo.orgmanax.api.unit.resp.CreateUnitResp;
|
||||
import cn.axzo.orgmanax.api.unit.resp.ListUnitResp;
|
||||
import cn.axzo.orgmanax.api.unit.resp.OrgUnitDTO;
|
||||
import cn.axzo.orgmanax.api.unit.resp.UpdateUnitResp;
|
||||
import cn.axzo.orgmanax.server.unit.service.UnitService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@ -21,6 +22,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequiredArgsConstructor
|
||||
public class UnitController implements OrgUnitApi {
|
||||
|
||||
private final UnitService unitService;
|
||||
|
||||
@Override
|
||||
public ApiResult<CreateUnitResp> create(CreateUnitReq req) {
|
||||
return null;
|
||||
@ -32,7 +35,8 @@ public class UnitController implements OrgUnitApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<ListUnitResp> list(ListUnitReq req) {
|
||||
public ApiResult<OrgUnitDTO> list(ListUnitReq req) {
|
||||
//
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user