From 16864081cd7756985ee62b50af668c995bdd0b35 Mon Sep 17 00:00:00 2001 From: wxz Date: Fri, 21 Aug 2020 15:50:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=96=E9=83=A8=E5=AE=A2=E6=88=B7=E7=AE=A1?= =?UTF-8?q?=E7=90=86-=E5=88=97=E8=A1=A8=E5=88=86=E9=A1=B5=E3=80=81?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E3=80=81=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=9A=84id=E6=94=B9=E4=B8=BAcustomerId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/result/ExternalCustomerResultDTO.java | 2 +- .../controller/ExternalCustomerController.java | 15 ++++++--------- .../epmet/service/ExternalCustomerService.java | 4 ++-- .../impl/ExternalCustomerServiceImpl.java | 16 ++++++++++++---- .../resources/mapper/ExternalCustomerDao.xml | 2 +- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalCustomerResultDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalCustomerResultDTO.java index 79e58686fe..177b49575b 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalCustomerResultDTO.java +++ b/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; /** * 客户名称 diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalCustomerController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalCustomerController.java index 2817a2fae5..becc72c341 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalCustomerController.java +++ b/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 add(@RequestBody ExternalCustomerFormDTO formDTO) { + public Result add(@RequestBody ExternalCustomerFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, ExternalCustomerFormDTO.AddExternalCustomerGroup.class); String customerName = formDTO.getCustomerName(); - ExternalCustomerEntity result = externalCustomerService.add(customerName); - return new Result().ok(result); + ExternalCustomerResultDTO result = externalCustomerService.add(customerName); + return new Result().ok(result); } /** @@ -61,12 +58,12 @@ public class ExternalCustomerController { * @return */ @PostMapping("update") - public Result update(@RequestBody ExternalCustomerFormDTO formDTO) { + public Result 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().ok(result); + ExternalCustomerResultDTO result = externalCustomerService.update(customerId, customerName); + return new Result().ok(result); } } diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalCustomerService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalCustomerService.java index 6af116be98..25645bea0b 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalCustomerService.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalCustomerService.java @@ -8,7 +8,7 @@ public interface ExternalCustomerService { PageData 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); } diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalCustomerServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalCustomerServiceImpl.java index 8cfe32cf96..728e588e80 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalCustomerServiceImpl.java +++ b/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; } } diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalCustomerDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalCustomerDao.xml index 0e4d03d0cc..3950f8d014 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalCustomerDao.xml +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalCustomerDao.xml @@ -17,7 +17,7 @@