init
parent
0c25c742e1
commit
1061187a28
|
|
@ -13,6 +13,7 @@ import org.qinan.safetyeval.domain.query.PageResult;
|
||||||
import org.qinan.safetyeval.domain.service.OrgPersonnelCertDomainService;
|
import org.qinan.safetyeval.domain.service.OrgPersonnelCertDomainService;
|
||||||
import org.qinan.safetyeval.infrastructure.adapter.ThreadLocalUserInfoAdapter;
|
import org.qinan.safetyeval.infrastructure.adapter.ThreadLocalUserInfoAdapter;
|
||||||
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
||||||
|
import org.qinan.safetyeval.infrastructure.convertor.OrgPersonnelCertConvertor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -29,23 +30,12 @@ public class OrgPersonnelCertExecutor implements OrgPersonnelCertApi {
|
||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
private OrgPersonnelCertDomainService orgPersonnelCertDomainService;
|
private OrgPersonnelCertDomainService orgPersonnelCertDomainService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrgPersonnelCertConvertor orgPersonnelCertConvertor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SingleResponse<OrgPersonnelCertCO> add(OrgPersonnelCertAddCmd cmd) {
|
public SingleResponse<OrgPersonnelCertCO> add(OrgPersonnelCertAddCmd cmd) {
|
||||||
OrgPersonnelCertEntity entity = new OrgPersonnelCertEntity();
|
OrgPersonnelCertEntity entity = orgPersonnelCertConvertor.addCmdToEntity(cmd);
|
||||||
entity.setCertName(cmd.getCertName());
|
|
||||||
entity.setCertTypeCode(cmd.getCertTypeCode());
|
|
||||||
entity.setCertTypeName(cmd.getCertTypeName());
|
|
||||||
entity.setCertCategoryCode(cmd.getCertCategoryCode());
|
|
||||||
entity.setCertCategoryName(cmd.getCertCategoryName());
|
|
||||||
entity.setOperationCategoryCode(cmd.getOperationCategoryCode());
|
|
||||||
entity.setOperationCategoryName(cmd.getOperationCategoryName());
|
|
||||||
entity.setCertNo(cmd.getCertNo());
|
|
||||||
entity.setIssueOrg(cmd.getIssueOrg());
|
|
||||||
entity.setValidStartDate(cmd.getValidStartDate());
|
|
||||||
entity.setValidEndDate(cmd.getValidEndDate());
|
|
||||||
entity.setReviewDate(cmd.getReviewDate());
|
|
||||||
entity.setCertAttachmentUrl(cmd.getCertAttachmentUrl());
|
|
||||||
entity.setPersonnelId(cmd.getPersonnelId());
|
|
||||||
|
|
||||||
OrgPersonnelCertEntity result = orgPersonnelCertDomainService.add(entity);
|
OrgPersonnelCertEntity result = orgPersonnelCertDomainService.add(entity);
|
||||||
return SingleResponse.success(toCO(result));
|
return SingleResponse.success(toCO(result));
|
||||||
|
|
@ -59,22 +49,7 @@ public class OrgPersonnelCertExecutor implements OrgPersonnelCertApi {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SingleResponse<OrgPersonnelCertCO> modify(OrgPersonnelCertModifyCmd cmd) {
|
public SingleResponse<OrgPersonnelCertCO> modify(OrgPersonnelCertModifyCmd cmd) {
|
||||||
OrgPersonnelCertEntity entity = new OrgPersonnelCertEntity();
|
OrgPersonnelCertEntity entity = orgPersonnelCertConvertor.modifyCmdToEntity(cmd);
|
||||||
entity.setId(cmd.getId());
|
|
||||||
entity.setCertName(cmd.getCertName());
|
|
||||||
entity.setCertTypeCode(cmd.getCertTypeCode());
|
|
||||||
entity.setCertTypeName(cmd.getCertTypeName());
|
|
||||||
entity.setCertCategoryCode(cmd.getCertCategoryCode());
|
|
||||||
entity.setCertCategoryName(cmd.getCertCategoryName());
|
|
||||||
entity.setOperationCategoryCode(cmd.getOperationCategoryCode());
|
|
||||||
entity.setOperationCategoryName(cmd.getOperationCategoryName());
|
|
||||||
entity.setCertNo(cmd.getCertNo());
|
|
||||||
entity.setIssueOrg(cmd.getIssueOrg());
|
|
||||||
entity.setValidStartDate(cmd.getValidStartDate());
|
|
||||||
entity.setValidEndDate(cmd.getValidEndDate());
|
|
||||||
entity.setReviewDate(cmd.getReviewDate());
|
|
||||||
entity.setCertAttachmentUrl(cmd.getCertAttachmentUrl());
|
|
||||||
entity.setPersonnelId(cmd.getPersonnelId());
|
|
||||||
|
|
||||||
OrgPersonnelCertEntity result = orgPersonnelCertDomainService.modify(entity);
|
OrgPersonnelCertEntity result = orgPersonnelCertDomainService.modify(entity);
|
||||||
return SingleResponse.success(toCO(result));
|
return SingleResponse.success(toCO(result));
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.qinan.safetyeval.infrastructure.convertor;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
import org.qinan.safetyeval.client.co.OrgPersonnelCertCO;
|
||||||
|
import org.qinan.safetyeval.client.dto.OrgPersonnelCertAddCmd;
|
||||||
|
import org.qinan.safetyeval.client.dto.OrgPersonnelCertModifyCmd;
|
||||||
|
import org.qinan.safetyeval.domain.entity.OrgPersonnelCertEntity;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.OrgPersonnelCertDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人员证书 Cmd/Entity/CO/DO 转换器
|
||||||
|
*
|
||||||
|
* @author safety-eval
|
||||||
|
*/
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface OrgPersonnelCertConvertor {
|
||||||
|
|
||||||
|
OrgPersonnelCertConvertor INSTANCE = Mappers.getMapper(OrgPersonnelCertConvertor.class);
|
||||||
|
|
||||||
|
OrgPersonnelCertEntity addCmdToEntity(OrgPersonnelCertAddCmd cmd);
|
||||||
|
|
||||||
|
OrgPersonnelCertEntity modifyCmdToEntity(OrgPersonnelCertModifyCmd cmd);
|
||||||
|
|
||||||
|
OrgPersonnelCertCO entityToCO(OrgPersonnelCertEntity entity);
|
||||||
|
|
||||||
|
OrgPersonnelCertEntity doToEntity(OrgPersonnelCertDO dataObject);
|
||||||
|
|
||||||
|
@Mapping(target = "orgId", ignore = true)
|
||||||
|
OrgPersonnelCertDO entityToDO(OrgPersonnelCertEntity entity);
|
||||||
|
}
|
||||||
|
|
@ -7,6 +7,7 @@ import org.qinan.safetyeval.domain.entity.OrgPersonnelCertEntity;
|
||||||
import org.qinan.safetyeval.domain.gateway.OrgPersonnelCertGateway;
|
import org.qinan.safetyeval.domain.gateway.OrgPersonnelCertGateway;
|
||||||
import org.qinan.safetyeval.domain.query.OrgPersonnelCertQuery;
|
import org.qinan.safetyeval.domain.query.OrgPersonnelCertQuery;
|
||||||
import org.qinan.safetyeval.domain.query.PageResult;
|
import org.qinan.safetyeval.domain.query.PageResult;
|
||||||
|
import org.qinan.safetyeval.infrastructure.convertor.OrgPersonnelCertConvertor;
|
||||||
import org.qinan.safetyeval.infrastructure.dataobject.OrgPersonnelCertDO;
|
import org.qinan.safetyeval.infrastructure.dataobject.OrgPersonnelCertDO;
|
||||||
import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelCertMapper;
|
import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelCertMapper;
|
||||||
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||||
|
|
@ -32,6 +33,9 @@ public class OrgPersonnelCertGatewayImpl implements OrgPersonnelCertGateway {
|
||||||
@Resource
|
@Resource
|
||||||
private OrgContextResolver orgContextResolver;
|
private OrgContextResolver orgContextResolver;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrgPersonnelCertConvertor orgPersonnelCertConvertor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OrgPersonnelCertEntity save(OrgPersonnelCertEntity entity) {
|
public OrgPersonnelCertEntity save(OrgPersonnelCertEntity entity) {
|
||||||
OrgPersonnelCertDO dataObject = toDO(entity);
|
OrgPersonnelCertDO dataObject = toDO(entity);
|
||||||
|
|
@ -44,7 +48,7 @@ public class OrgPersonnelCertGatewayImpl implements OrgPersonnelCertGateway {
|
||||||
@Override
|
@Override
|
||||||
public OrgPersonnelCertEntity get(Long id) {
|
public OrgPersonnelCertEntity get(Long id) {
|
||||||
OrgPersonnelCertDO dataObject = orgPersonnelCertMapper.selectById(id);
|
OrgPersonnelCertDO dataObject = orgPersonnelCertMapper.selectById(id);
|
||||||
return toEntity(dataObject);
|
return orgPersonnelCertConvertor.doToEntity(dataObject);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public List<OrgPersonnelCertEntity> listByPersonnelId(Long personnelId) {
|
public List<OrgPersonnelCertEntity> listByPersonnelId(Long personnelId) {
|
||||||
|
|
@ -52,7 +56,7 @@ public class OrgPersonnelCertGatewayImpl implements OrgPersonnelCertGateway {
|
||||||
wrapper.eq(OrgPersonnelCertDO::getPersonnelId, personnelId);
|
wrapper.eq(OrgPersonnelCertDO::getPersonnelId, personnelId);
|
||||||
wrapper.eq(OrgPersonnelCertDO::getDeleteEnum, "false");
|
wrapper.eq(OrgPersonnelCertDO::getDeleteEnum, "false");
|
||||||
List<OrgPersonnelCertDO> dataObjects = orgPersonnelCertMapper.selectList(wrapper);
|
List<OrgPersonnelCertDO> dataObjects = orgPersonnelCertMapper.selectList(wrapper);
|
||||||
return dataObjects.stream().map(this::toEntity).collect(Collectors.toList());
|
return dataObjects.stream().map(orgPersonnelCertConvertor::doToEntity).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -61,7 +65,7 @@ public class OrgPersonnelCertGatewayImpl implements OrgPersonnelCertGateway {
|
||||||
wrapper.eq(OrgPersonnelCertDO::getOrgId, orgId);
|
wrapper.eq(OrgPersonnelCertDO::getOrgId, orgId);
|
||||||
wrapper.eq(OrgPersonnelCertDO::getDeleteEnum, "false");
|
wrapper.eq(OrgPersonnelCertDO::getDeleteEnum, "false");
|
||||||
List<OrgPersonnelCertDO> dataObjects = orgPersonnelCertMapper.selectList(wrapper);
|
List<OrgPersonnelCertDO> dataObjects = orgPersonnelCertMapper.selectList(wrapper);
|
||||||
return dataObjects.stream().map(this::toEntity).collect(Collectors.toList());
|
return dataObjects.stream().map(orgPersonnelCertConvertor::doToEntity).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -108,56 +112,15 @@ public class OrgPersonnelCertGatewayImpl implements OrgPersonnelCertGateway {
|
||||||
IPage<OrgPersonnelCertDO> result = orgPersonnelCertMapper.selectPage(page, wrapper);
|
IPage<OrgPersonnelCertDO> result = orgPersonnelCertMapper.selectPage(page, wrapper);
|
||||||
|
|
||||||
List<OrgPersonnelCertEntity> entities = result.getRecords().stream()
|
List<OrgPersonnelCertEntity> entities = result.getRecords().stream()
|
||||||
.map(this::toEntity)
|
.map(orgPersonnelCertConvertor::doToEntity)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
return PageResult.of(entities, result.getTotal(), result.getCurrent(), result.getSize());
|
return PageResult.of(entities, result.getTotal(), result.getCurrent(), result.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrgPersonnelCertDO toDO(OrgPersonnelCertEntity entity) {
|
private OrgPersonnelCertDO toDO(OrgPersonnelCertEntity entity) {
|
||||||
OrgPersonnelCertDO dataObject = new OrgPersonnelCertDO();
|
OrgPersonnelCertDO dataObject = orgPersonnelCertConvertor.entityToDO(entity);
|
||||||
dataObject.setOrgId(orgContextResolver.resolveOrgId(entity.getOrgId()));
|
dataObject.setOrgId(orgContextResolver.resolveOrgId(entity.getOrgId()));
|
||||||
dataObject.setPersonnelId(entity.getPersonnelId());
|
|
||||||
dataObject.setCertName(entity.getCertName());
|
|
||||||
dataObject.setCertTypeCode(entity.getCertTypeCode());
|
|
||||||
dataObject.setCertTypeName(entity.getCertTypeName());
|
|
||||||
dataObject.setCertCategoryCode(entity.getCertCategoryCode());
|
|
||||||
dataObject.setCertCategoryName(entity.getCertCategoryName());
|
|
||||||
dataObject.setOperationCategoryCode(entity.getOperationCategoryCode());
|
|
||||||
dataObject.setOperationCategoryName(entity.getOperationCategoryName());
|
|
||||||
dataObject.setCertNo(entity.getCertNo());
|
|
||||||
dataObject.setIssueOrg(entity.getIssueOrg());
|
|
||||||
dataObject.setValidStartDate(entity.getValidStartDate());
|
|
||||||
dataObject.setValidEndDate(entity.getValidEndDate());
|
|
||||||
dataObject.setReviewDate(entity.getReviewDate());
|
|
||||||
dataObject.setCertAttachmentUrl(entity.getCertAttachmentUrl());
|
|
||||||
dataObject.setBusinessScope(entity.getBusinessScope());
|
|
||||||
dataObject.setTenantId(entity.getTenantId());
|
|
||||||
return dataObject;
|
return dataObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrgPersonnelCertEntity toEntity(OrgPersonnelCertDO dataObject) {
|
|
||||||
if (dataObject == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
OrgPersonnelCertEntity entity = new OrgPersonnelCertEntity();
|
|
||||||
entity.setId(dataObject.getId());
|
|
||||||
entity.setPersonnelId(dataObject.getPersonnelId());
|
|
||||||
entity.setCertName(dataObject.getCertName());
|
|
||||||
entity.setCertTypeCode(dataObject.getCertTypeCode());
|
|
||||||
entity.setCertTypeName(dataObject.getCertTypeName());
|
|
||||||
entity.setCertCategoryCode(dataObject.getCertCategoryCode());
|
|
||||||
entity.setCertCategoryName(dataObject.getCertCategoryName());
|
|
||||||
entity.setOperationCategoryCode(dataObject.getOperationCategoryCode());
|
|
||||||
entity.setOperationCategoryName(dataObject.getOperationCategoryName());
|
|
||||||
entity.setCertNo(dataObject.getCertNo());
|
|
||||||
entity.setIssueOrg(dataObject.getIssueOrg());
|
|
||||||
entity.setValidStartDate(dataObject.getValidStartDate());
|
|
||||||
entity.setValidEndDate(dataObject.getValidEndDate());
|
|
||||||
entity.setReviewDate(dataObject.getReviewDate());
|
|
||||||
entity.setCertAttachmentUrl(dataObject.getCertAttachmentUrl());
|
|
||||||
entity.setBusinessScope(dataObject.getBusinessScope());
|
|
||||||
entity.setTenantId(dataObject.getTenantId());
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue