|
|
|
@@ -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); |
|
|
|
|