Browse Source

外部客户管理-列表分页、新增、修改接口返回的id改为customerId

master
wxz 5 years ago
parent
commit
16864081cd
  1. 2
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalCustomerResultDTO.java
  2. 15
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalCustomerController.java
  3. 4
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalCustomerService.java
  4. 16
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalCustomerServiceImpl.java
  5. 2
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalCustomerDao.xml

2
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalCustomerResultDTO.java

@ -36,7 +36,7 @@ public class ExternalCustomerResultDTO implements Serializable {
/**
* 客户ID
*/
private String id;
private String customerId;
/**
* 客户名称

15
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalCustomerController.java

@ -5,7 +5,6 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.ExternalCustomerFormDTO;
import com.epmet.dto.result.ExternalCustomerResultDTO;
import com.epmet.entity.ExternalCustomerEntity;
import com.epmet.service.ExternalCustomerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -15,8 +14,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotBlank;
/**
* 外部客户管理
*/
@ -48,11 +45,11 @@ public class ExternalCustomerController {
* @return
*/
@PostMapping("add")
public Result<ExternalCustomerEntity> add(@RequestBody ExternalCustomerFormDTO formDTO) {
public Result<ExternalCustomerResultDTO> add(@RequestBody ExternalCustomerFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, ExternalCustomerFormDTO.AddExternalCustomerGroup.class);
String customerName = formDTO.getCustomerName();
ExternalCustomerEntity result = externalCustomerService.add(customerName);
return new Result<ExternalCustomerEntity>().ok(result);
ExternalCustomerResultDTO result = externalCustomerService.add(customerName);
return new Result<ExternalCustomerResultDTO>().ok(result);
}
/**
@ -61,12 +58,12 @@ public class ExternalCustomerController {
* @return
*/
@PostMapping("update")
public Result<ExternalCustomerEntity> update(@RequestBody ExternalCustomerFormDTO formDTO) {
public Result<ExternalCustomerResultDTO> update(@RequestBody ExternalCustomerFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, ExternalCustomerFormDTO.UpdateExternalCustomerGroup.class);
String customerId = formDTO.getCustomerId();
String customerName = formDTO.getCustomerName();
ExternalCustomerEntity result = externalCustomerService.update(customerId, customerName);
return new Result<ExternalCustomerEntity>().ok(result);
ExternalCustomerResultDTO result = externalCustomerService.update(customerId, customerName);
return new Result<ExternalCustomerResultDTO>().ok(result);
}
}

4
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalCustomerService.java

@ -8,7 +8,7 @@ public interface ExternalCustomerService {
PageData<ExternalCustomerResultDTO> listPage(Integer pageNo, Integer pageSize);
ExternalCustomerEntity add(String customerName);
ExternalCustomerResultDTO add(String customerName);
ExternalCustomerEntity update(String customerId, String customerName);
ExternalCustomerResultDTO update(String customerId, String customerName);
}

16
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalCustomerServiceImpl.java

@ -31,7 +31,7 @@ public class ExternalCustomerServiceImpl implements ExternalCustomerService {
}
@Override
public ExternalCustomerEntity add(String customerName) {
public ExternalCustomerResultDTO add(String customerName) {
Integer exitsCustomerCount = externalCustomerDao.countByCustomerName(customerName);
if (exitsCustomerCount > 0) {
throw new RenException(EpmetErrorCode.OPER_CUSTOMER_EXISTS.getCode(), "客户已存在");
@ -39,11 +39,15 @@ public class ExternalCustomerServiceImpl implements ExternalCustomerService {
ExternalCustomerEntity entity = new ExternalCustomerEntity();
entity.setCustomerName(customerName);
externalCustomerDao.insert(entity);
return entity;
ExternalCustomerResultDTO resultDTO = new ExternalCustomerResultDTO();
resultDTO.setCustomerId(entity.getId());
resultDTO.setCustomerName(customerName);
return resultDTO;
}
@Override
public ExternalCustomerEntity update(String customerId, String customerName) {
public ExternalCustomerResultDTO update(String customerId, String customerName) {
ExternalCustomerEntity existsCustomer = externalCustomerDao.selectById(customerId);
if (existsCustomer == null) {
throw new RenException(EpmetErrorCode.OPER_EXTERNAL_CUSTOMER_NOT_EXISTS.getCode(),
@ -51,6 +55,10 @@ public class ExternalCustomerServiceImpl implements ExternalCustomerService {
}
existsCustomer.setCustomerName(customerName);
externalCustomerDao.updateById(existsCustomer);
return existsCustomer;
ExternalCustomerResultDTO resultDTO = new ExternalCustomerResultDTO();
resultDTO.setCustomerId(customerId);
resultDTO.setCustomerName(customerName);
return resultDTO;
}
}

2
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalCustomerDao.xml

@ -17,7 +17,7 @@
<!-- 列出客户基本信息-->
<select id="listBaseInfo" resultType="com.epmet.dto.result.ExternalCustomerResultDTO">
SELECT
id,
id customerId,
CUSTOMER_NAME
FROM
external_customer

Loading…
Cancel
Save