init
parent
8a7a4e95ec
commit
81cf87b56c
|
|
@ -5,12 +5,14 @@ import io.swagger.annotations.ApiOperation;
|
|||
import io.swagger.annotations.ApiParam;
|
||||
import org.qinan.safetyeval.client.api.OrgInfoApi;
|
||||
import org.qinan.safetyeval.client.co.OrgInfoCO;
|
||||
import org.qinan.safetyeval.client.co.OrgInfoSelectCO;
|
||||
import org.qinan.safetyeval.client.dto.*;
|
||||
import org.qinan.safetyeval.infrastructure.dataobject.base.Req;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 机构信息适配层(Controller)
|
||||
|
|
@ -72,4 +74,10 @@ public class OrgInfoController {
|
|||
public PageResponse<OrgInfoCO> page(@Validated OrgInfoPageQuery query) {
|
||||
return orgInfoApi.page(query);
|
||||
}
|
||||
|
||||
@ApiOperation("机构下拉列表(仅id、单位名称)")
|
||||
@GetMapping("/select/list")
|
||||
public SingleResponse<List<OrgInfoSelectCO>> selectList() {
|
||||
return orgInfoApi.selectList();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package org.qinan.safetyeval.app.convertor;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.qinan.safetyeval.client.co.OrgInfoSelectCO;
|
||||
import org.qinan.safetyeval.domain.entity.OrgInfoEntity;
|
||||
|
||||
/**
|
||||
* 机构信息转换器(Entity/CO 互转)
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface OrgInfoConvertor {
|
||||
|
||||
/**
|
||||
* Entity 转 SelectCO(仅id、单位名称)
|
||||
*/
|
||||
OrgInfoSelectCO toSelectCO(OrgInfoEntity entity);
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import org.qinan.safetyeval.client.api.OrgInfoApi;
|
|||
import org.qinan.safetyeval.client.dto.PageResponse;
|
||||
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||
import org.qinan.safetyeval.client.co.OrgInfoCO;
|
||||
import org.qinan.safetyeval.client.co.OrgInfoSelectCO;
|
||||
import org.qinan.safetyeval.client.dto.OrgInfoAddCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgInfoModifyCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgInfoPageQuery;
|
||||
|
|
@ -15,11 +16,15 @@ import org.qinan.safetyeval.domain.exception.ErrorCode;
|
|||
import org.qinan.safetyeval.domain.query.OrgInfoQuery;
|
||||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.qinan.safetyeval.domain.service.OrgInfoDomainService;
|
||||
import org.qinan.safetyeval.app.convertor.OrgInfoConvertor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 机构信息执行器(App层)
|
||||
*
|
||||
|
|
@ -32,6 +37,9 @@ public class OrgInfoExecutor implements OrgInfoApi {
|
|||
@Autowired(required = false)
|
||||
private OrgInfoDomainService orgInfoDomainService;
|
||||
|
||||
@Autowired
|
||||
private OrgInfoConvertor orgInfoConvertor;
|
||||
|
||||
@Override
|
||||
public SingleResponse<OrgInfoCO> add(OrgInfoAddCmd cmd) {
|
||||
OrgInfoEntity entity = new OrgInfoEntity();
|
||||
|
|
@ -204,6 +212,15 @@ public class OrgInfoExecutor implements OrgInfoApi {
|
|||
return SingleResponse.success(toCO(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleResponse<List<OrgInfoSelectCO>> selectList() {
|
||||
List<OrgInfoEntity> entities = orgInfoDomainService.selectList();
|
||||
List<OrgInfoSelectCO> result = entities.stream()
|
||||
.map(orgInfoConvertor::toSelectCO)
|
||||
.collect(Collectors.toList());
|
||||
return SingleResponse.success(result);
|
||||
}
|
||||
|
||||
private OrgInfoCO toCO(OrgInfoEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.qinan.safetyeval.client.api;
|
||||
|
||||
import org.qinan.safetyeval.client.co.OrgInfoCO;
|
||||
import org.qinan.safetyeval.client.co.OrgInfoSelectCO;
|
||||
import org.qinan.safetyeval.client.dto.PageResponse;
|
||||
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||
import org.qinan.safetyeval.client.dto.OrgInfoAddCmd;
|
||||
|
|
@ -8,6 +9,8 @@ import org.qinan.safetyeval.client.dto.OrgInfoModifyCmd;
|
|||
import org.qinan.safetyeval.client.dto.OrgInfoPageQuery;
|
||||
import org.qinan.safetyeval.client.dto.OrgInfoUpdateStateCmd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 机构信息接口定义(Client层)
|
||||
*
|
||||
|
|
@ -32,4 +35,11 @@ public interface OrgInfoApi {
|
|||
SingleResponse<OrgInfoCO> getInfo();
|
||||
|
||||
SingleResponse<OrgInfoCO> getByAccount(String data);
|
||||
|
||||
/**
|
||||
* 机构下拉列表(仅id、单位名称)
|
||||
*
|
||||
* @return 机构列表
|
||||
*/
|
||||
SingleResponse<List<OrgInfoSelectCO>> selectList();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package org.qinan.safetyeval.client.co;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 机构下拉列表CO
|
||||
*
|
||||
* @author safety-eval
|
||||
*/
|
||||
@Data
|
||||
public class OrgInfoSelectCO {
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "单位名称")
|
||||
private String unitName;
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@ import org.qinan.safetyeval.domain.entity.OrgInfoEntity;
|
|||
import org.qinan.safetyeval.domain.query.OrgInfoQuery;
|
||||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 机构信息Gateway接口(Domain层定义)
|
||||
*
|
||||
|
|
@ -30,4 +32,11 @@ public interface OrgInfoGateway {
|
|||
void resetPassword(Long id);
|
||||
|
||||
OrgInfoEntity getByAccount(String data);
|
||||
|
||||
/**
|
||||
* 查询全部机构(仅id、单位名称),用于下拉列表
|
||||
*
|
||||
* @return 机构列表
|
||||
*/
|
||||
List<OrgInfoEntity> selectList();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import org.qinan.safetyeval.domain.query.PageResult;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 机构信息领域服务
|
||||
|
|
@ -68,4 +69,8 @@ public class OrgInfoDomainService {
|
|||
public OrgInfoEntity getByAccount(String data) {
|
||||
return orgInfoGateway.getByAccount(data);
|
||||
}
|
||||
|
||||
public List<OrgInfoEntity> selectList() {
|
||||
return orgInfoGateway.selectList();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
package org.qinan.safetyeval.infrastructure.convertor;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Named;
|
||||
import org.qinan.safetyeval.domain.entity.OrgInfoEntity;
|
||||
import org.qinan.safetyeval.infrastructure.dataobject.OrgInfoDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 机构信息DO对象转换
|
||||
*
|
||||
* @author safety-eval
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface OrgInfoDoConvertor {
|
||||
|
||||
/**
|
||||
* 领域对象转DO
|
||||
*
|
||||
* @param orgInfoEntity 领域对象
|
||||
* @return DO
|
||||
*/
|
||||
@Mapping(target = "safetyIndustryCategoryCode", source = "safetyIndustryCategoryCode", qualifiedByName = "listToJson")
|
||||
@Mapping(target = "deleteEnum", ignore = true)
|
||||
@Mapping(target = "remarks", ignore = true)
|
||||
@Mapping(target = "createName", ignore = true)
|
||||
@Mapping(target = "updateName", ignore = true)
|
||||
@Mapping(target = "version", ignore = true)
|
||||
@Mapping(target = "updateTime", ignore = true)
|
||||
@Mapping(target = "updateId", ignore = true)
|
||||
@Mapping(target = "env", ignore = true)
|
||||
OrgInfoDO convertEeToDo(OrgInfoEntity orgInfoEntity);
|
||||
|
||||
/**
|
||||
* DO转领域对象
|
||||
*
|
||||
* @param orgInfoDO DO
|
||||
* @return 领域对象
|
||||
*/
|
||||
@Mapping(target = "safetyIndustryCategoryCode", source = "safetyIndustryCategoryCode", qualifiedByName = "jsonToList")
|
||||
OrgInfoEntity converDoToEe(OrgInfoDO orgInfoDO);
|
||||
|
||||
/**
|
||||
* DOs转领域对象列表
|
||||
*
|
||||
* @param orgInfoDOs dos
|
||||
* @return 领域对象列表
|
||||
*/
|
||||
List<OrgInfoEntity> converDosToEes(List<OrgInfoDO> orgInfoDOs);
|
||||
|
||||
/**
|
||||
* List<String> 转 JSON 字符串
|
||||
*/
|
||||
@Named("listToJson")
|
||||
default String listToJson(List<String> list) {
|
||||
return list == null ? null : JSONUtil.toJsonStr(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON 字符串转 List<String>
|
||||
*/
|
||||
@Named("jsonToList")
|
||||
default List<String> jsonToList(String json) {
|
||||
return json == null ? null : JSONUtil.toList(json, String.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -59,6 +59,8 @@ public class OrgInfoGatewayImpl implements OrgInfoGateway {
|
|||
private OrgInfoCascadeDeleter orgInfoCascadeDeleter;
|
||||
@Autowired
|
||||
private GbsUserFacadeClient gbsUserFacadeClient;
|
||||
@Autowired
|
||||
private org.qinan.safetyeval.infrastructure.convertor.OrgInfoDoConvertor orgInfoDoConvertor;
|
||||
@Value("${def.password:a123456}")
|
||||
private String defPassword;
|
||||
@Value("${def.tenantId:2067161116369793024L}")
|
||||
|
|
@ -293,6 +295,17 @@ public class OrgInfoGatewayImpl implements OrgInfoGateway {
|
|||
return toEntity(dataObject.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrgInfoEntity> selectList() {
|
||||
LambdaQueryWrapper<OrgInfoDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.select(OrgInfoDO::getId, OrgInfoDO::getUnitName)
|
||||
.eq(OrgInfoDO::getDeleteEnum, "false")
|
||||
.orderByDesc(OrgInfoDO::getId);
|
||||
return orgInfoMapper.selectList(wrapper).stream()
|
||||
.map(orgInfoDoConvertor::converDoToEe)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void syncGbsUser(String action, Runnable runnable) {
|
||||
try {
|
||||
runnable.run();
|
||||
|
|
|
|||
Loading…
Reference in New Issue