feat:[REQ-3282] 暂时提交,编写单位相关代码
This commit is contained in:
parent
5984cfa6b6
commit
17f8efb7d7
@ -186,4 +186,9 @@ public class CreateUnitReq {
|
||||
*/
|
||||
private String cityName;
|
||||
|
||||
/**
|
||||
* 操作人
|
||||
*/
|
||||
private Long operatorId;
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
package cn.axzo.orgmanax.server.unit.service.impl;
|
||||
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.orgmanax.api.node.req.NodeProcessReq;
|
||||
import cn.axzo.orgmanax.api.unit.req.ListUnitReq;
|
||||
import cn.axzo.orgmanax.api.unit.resp.OrgUnitDTO;
|
||||
import cn.axzo.orgmanax.infra.dao.node.entity.OrganizationalNode;
|
||||
import cn.axzo.orgmanax.infra.dao.unit.entity.OrganizationalUnit;
|
||||
import cn.axzo.orgmanax.infra.dao.unit.repository.UnitQueryRepository;
|
||||
import cn.axzo.orgmanax.server.node.foundation.req.NodeCreate;
|
||||
import cn.axzo.orgmanax.server.node.service.NodeService;
|
||||
import cn.axzo.orgmanax.server.unit.foundation.UnitFoundationService;
|
||||
import cn.axzo.orgmanax.server.unit.foundation.dto.UnitCreator;
|
||||
import cn.axzo.orgmanax.server.unit.service.UnitService;
|
||||
@ -13,11 +17,11 @@ import cn.axzo.orgmanax.server.unit.service.dto.CreateUnitResp;
|
||||
import cn.axzo.orgmanax.server.unit.service.dto.UpdateUnitReq;
|
||||
import cn.axzo.orgmanax.server.unit.service.dto.UpdateUnitResp;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import static org.springframework.messaging.rsocket.RSocketStrategies.builder;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@ -25,19 +29,44 @@ import static org.springframework.messaging.rsocket.RSocketStrategies.builder;
|
||||
public class UnitServiceImpl implements UnitService {
|
||||
|
||||
private final UnitFoundationService unitFoundationService;
|
||||
private final NodeService nodeService;
|
||||
private final UnitQueryRepository unitQueryRepository;
|
||||
|
||||
private final TransactionTemplate transactionTemplate;
|
||||
@Override
|
||||
public CreateUnitResp create(CreateUnitReq req) {
|
||||
|
||||
// 构建单位创建者
|
||||
UnitCreator unitCreator = BeanUtil.copyProperties(req, UnitCreator.class);
|
||||
|
||||
// 创建单位
|
||||
OrganizationalUnit organizationalUnit = unitFoundationService.create(unitCreator);
|
||||
return transactionTemplate.execute(r -> {
|
||||
|
||||
// 创建单位
|
||||
OrganizationalUnit unit = unitFoundationService.create(unitCreator);
|
||||
NodeCreate nodeCreate = new NodeCreate();
|
||||
nodeCreate.setOrganizationalUnitId(unit.getId());
|
||||
nodeCreate.setNodeName(unit.getName());
|
||||
nodeCreate.setNodeType(OrganizationalNode.TypeEnum.DEPARTMENT.getValue());
|
||||
nodeCreate.setParentId(0L);
|
||||
nodeCreate.setRemark("");
|
||||
nodeCreate.setOperatorId(req.getOperatorId());
|
||||
nodeCreate.setTerminal("");
|
||||
nodeCreate.setPage("");
|
||||
nodeCreate.setExtra(null);
|
||||
nodeCreate.setProfile(null);
|
||||
|
||||
// 创建部门
|
||||
nodeService.process(NodeProcessReq
|
||||
.builder()
|
||||
.action(NodeProcessReq.Action.CREATE)
|
||||
.operatorId(req.getOperatorId())
|
||||
.param(new JSONObject(BeanUtil.beanToMap(nodeCreate)))
|
||||
.build()
|
||||
|
||||
|
||||
);
|
||||
return CreateUnitResp.builder().id(unit.getId()).build();
|
||||
});
|
||||
|
||||
// 返回
|
||||
return CreateUnitResp.builder().id(organizationalUnit.getId()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
Reference in New Issue
Block a user