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 c19635b8d..3f73d675a 100755 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java @@ -2,6 +2,7 @@ package com.iformall.controller.invest; import com.iformall.annotation.SystemServiceLog; import com.iformall.common.InvestResultData; +import com.iformall.domain.dto.InvestDemandDto; import com.iformall.domain.po.InvestDemandEntity; import com.iformall.domain.vo.invest.InvestDemandVo; import com.iformall.domain.vo.invest.InvestPageQuery; @@ -63,7 +64,7 @@ public class InvestDemandController extends InvestBaseController { */ @SystemServiceLog @PostMapping("/save") - public InvestResultData save(InvestDemandVo investDemand) { + public InvestResultData save(@RequestBody InvestDemandDto investDemand) { return execute(investDemand, p -> investBizService.saveCustomerAndDemand(p)); } @@ -72,7 +73,7 @@ public class InvestDemandController extends InvestBaseController { */ @SystemServiceLog @PostMapping("/update") - public InvestResultData update(InvestDemandVo investDemand) { + public InvestResultData update(@RequestBody InvestDemandVo investDemand) { return execute(investDemand, p -> investBizService.updateCustomerAndDemand(p)); } @@ -80,7 +81,7 @@ public class InvestDemandController extends InvestBaseController { * 删除 */ //@GetMapping("/delete") - public InvestResultData delete(Long[] ids) { + public InvestResultData delete(@RequestBody Long[] ids) { return execute(ids, p -> investDemandService.removeByIds(Arrays.asList(p))); } diff --git a/mallinkService/src/main/java/com/iformall/domain/dto/InvestDemandDto.java b/mallinkService/src/main/java/com/iformall/domain/dto/InvestDemandDto.java new file mode 100644 index 000000000..1fe5bd370 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/dto/InvestDemandDto.java @@ -0,0 +1,13 @@ +package com.iformall.domain.dto; + +import com.iformall.domain.po.InvestCustomerEntity; +import com.iformall.domain.po.InvestDemandEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class InvestDemandDto extends InvestDemandEntity { + @io.swagger.annotations.ApiModelProperty(value = "customer", name = "customer",required = true) + private InvestCustomerEntity customer; +} diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandVo.java index 8b52db119..fc1988ac1 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandVo.java @@ -6,15 +6,20 @@ import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.WxBrand; import lombok.Builder; import lombok.Data; +import lombok.EqualsAndHashCode; @Data @Builder +@EqualsAndHashCode(callSuper = true) public class InvestDemandVo extends InvestDemandEntity { + @io.swagger.annotations.ApiModelProperty(value = "customer", name = "customer",required = true) private InvestCustomerEntity customer; + @io.swagger.annotations.ApiModelProperty(value = "brand", name = "brand") private WxBrand brand; + @io.swagger.annotations.ApiModelProperty(value = "ownerInfo", name = "ownerInfo") private MallUserInfo ownerInfo; private T targetInfo; diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestFollowRecordVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestFollowRecordVo.java index 3e5f5a9aa..fa1f0c118 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestFollowRecordVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestFollowRecordVo.java @@ -3,11 +3,13 @@ package com.iformall.domain.vo.invest; import com.iformall.domain.po.*; import lombok.Builder; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.List; @Data @Builder +@EqualsAndHashCode(callSuper = true) public class InvestFollowRecordVo extends InvestFollowRecordEntity { private InvestCustomerEntity customer; 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 080acfd03..2a02f51f4 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java @@ -1,5 +1,6 @@ package com.iformall.service.invest; +import com.iformall.domain.dto.InvestDemandDto; import com.iformall.domain.po.InvestDemandEntity; import com.iformall.domain.po.InvestFollowRecordEntity; import com.iformall.domain.po.InvestTaskEntity; @@ -18,7 +19,7 @@ public interface InvestBizService { List queryUserList() ; - boolean saveCustomerAndDemand(InvestDemandVo customerDemandVo) ; + boolean saveCustomerAndDemand(InvestDemandDto customerDemandDto) ; boolean updateCustomerAndDemand(InvestDemandVo customerDemandVo) ; 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 bb3519953..3206329e0 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 @@ -1,6 +1,7 @@ package com.iformall.service.invest.impl; import com.alibaba.fastjson.JSON; +import com.iformall.domain.dto.InvestDemandDto; import com.iformall.domain.po.*; import com.iformall.domain.vo.invest.*; import com.iformall.service.MallUserInfoService; @@ -128,13 +129,19 @@ public class InvestBizServiceImpl implements InvestBizService { @Transactional(rollbackFor = Exception.class) @Override - public boolean saveCustomerAndDemand(InvestDemandVo customerDemandVo) { - InvestHelper.allNotNull(customerDemandVo); - InvestHelper.allNotNull(customerDemandVo.getBrand(), customerDemandVo.getCustomer()); - InvestCustomerEntity customerEntity = customerDemandVo.getCustomer(); - customerService.save(customerEntity); + public boolean saveCustomerAndDemand(InvestDemandDto customerDemandDto) { + InvestHelper.allNotNull(customerDemandDto, customerDemandDto.getCustomerId()); + InvestCustomerEntity customerEntity = customerDemandDto.getCustomer(); + InvestCustomerEntity customerEntityDB = customerService.getById(customerDemandDto.getCustomerId()); + if (Objects.nonNull(customerEntity)) { + if (Objects.isNull(customerEntityDB)) { + customerService.save(customerEntity); + } else { + customerService.updateById(customerEntity); + } + } InvestDemandEntity demandEntity = new InvestDemandEntity(); - BeanUtils.copyProperties(customerDemandVo, demandEntity); + BeanUtils.copyProperties(customerDemandDto, demandEntity); return demandService.save(demandEntity); }