From 901cd43ade80d5b9d8ba7672f8c248f564603502 Mon Sep 17 00:00:00 2001 From: Burce Date: Thu, 10 Oct 2019 19:47:39 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=8B=9B=E5=95=86]adjust?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../invest/InvestDemandController.java | 4 +- .../domain/dto/InvestCustomerDto.java | 11 +++++ .../service/invest/InvestBizService.java | 2 +- .../invest/impl/InvestBizServiceImpl.java | 45 +++++++++++-------- 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java index 110a79bcd..6874569cb 100755 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java @@ -70,8 +70,8 @@ public class InvestDemandController extends InvestBaseController { */ @SystemServiceLog @PostMapping("/update") - public InvestResultData update(@RequestBody InvestCustomerDto investDemand) { - return execute(investDemand, p -> investBizService.updateCustomerAndDemand(p)); + public InvestResultData update(@RequestBody InvestCustomerDto customerDto) { + return execute(customerDto, p -> investBizService.updateCustomerAndDemand(p)); } /** diff --git a/mallinkService/src/main/java/com/iformall/domain/dto/InvestCustomerDto.java b/mallinkService/src/main/java/com/iformall/domain/dto/InvestCustomerDto.java index 2dd24b051..1bb9560c8 100644 --- a/mallinkService/src/main/java/com/iformall/domain/dto/InvestCustomerDto.java +++ b/mallinkService/src/main/java/com/iformall/domain/dto/InvestCustomerDto.java @@ -15,4 +15,15 @@ public class InvestCustomerDto extends InvestCustomerEntity { @io.swagger.annotations.ApiModelProperty(value = "招商负责人", name = "owner") @LogColumn private Long owner; + + @io.swagger.annotations.ApiModelProperty(value = "demandId", name = "demandId") + private Long demandId; + + /** + * 客户意向 + */ + @io.swagger.annotations.ApiModelProperty(value = "客户意向", name = "intent", + example = "\"{\"rent_area\":100,\"opening_time\": \"2019-09-03\"}\"") + @LogColumn(COLUMN_TYPE) + private String intent; } diff --git a/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java b/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java index f1090e76f..3b2e14b51 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java @@ -21,7 +21,7 @@ public interface InvestBizService { boolean saveCustomerAndDemand(InvestCustomerDto customerDemandDto) ; - boolean updateCustomerAndDemand(InvestCustomerDto demandDto) ; + boolean updateCustomerAndDemand(InvestCustomerDto customerDto) ; InvestDemandVo findDemandById(Long id) ; diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java index 7201b339b..cbfc01a0b 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java @@ -151,35 +151,44 @@ public class InvestBizServiceImpl implements InvestBizService { @Transactional(rollbackFor = Exception.class) @Override - public boolean saveCustomerAndDemand(InvestCustomerDto demandDto) { - InvestHelper.notNull(demandDto); - InvestCustomerEntity customerEntity = demandDto; - InvestCustomerEntity customerEntityDB = customerService.getById(demandDto.getId()); - if (Objects.nonNull(customerEntity)) { - if (Objects.isNull(customerEntityDB)) { - customerService.save(customerEntity); - } else { - customerService.updateById(customerEntity); - } + public boolean saveCustomerAndDemand(InvestCustomerDto customerDto) { + InvestHelper.notNull(customerDto); + InvestCustomerEntity customerEntityDB = customerService.getById(customerDto.getId()); + if (Objects.isNull(customerEntityDB)) { + customerService.save(customerDto); + } else { + customerService.updateById(customerDto); } InvestDemandEntity demandEntity = new InvestDemandEntity(); - BeanUtils.copyProperties(demandDto, demandEntity); - demandEntity.setCustomerId(customerEntity.getId()); + setValDmand(customerDto, demandEntity); return demandService.save(demandEntity); } @Transactional(rollbackFor = Exception.class) @Override - public boolean updateCustomerAndDemand(InvestCustomerDto demandDto) { - InvestHelper.notNull(demandDto, demandDto.getId()); - InvestCustomerEntity customerEntity = demandDto; - InvestHelper.notNull(customerEntity); + public boolean updateCustomerAndDemand(InvestCustomerDto customerDto) { + InvestHelper.notNull(customerDto, customerDto.getDemandId()); + InvestDemandEntity demandEntity = demandService.getByIdNotNull(customerDto.getDemandId()); + InvestCustomerEntity customerEntity = new InvestCustomerEntity(); + BeanUtils.copyProperties(customerDto, customerEntity); + customerEntity.setId(customerDto.getId()); customerService.updateById(customerEntity); - InvestDemandEntity demandEntity = new InvestDemandEntity(); - BeanUtils.copyProperties(demandDto, demandEntity); + setValDmand(customerDto, demandEntity); return demandService.updateById(demandEntity); } + private void setValDmand(InvestCustomerDto customerDto, InvestDemandEntity demandEntity) { + if (Objects.isNull(demandEntity)) { + demandEntity = new InvestDemandEntity(); + } + demandEntity.setCustomerId(customerDto.getId()); + demandEntity.setId(customerDto.getDemandId()); + demandEntity.setIntent(customerDto.getIntent()); + if (Objects.nonNull(customerDto.getOwner())) { + demandEntity.setOwner(customerDto.getOwner()); + } + } + @Override public InvestDemandVo findDemandById(Long id) { InvestDemandEntity demandEntity = demandService.getByIdNotNull(id);