|
|
|
|
@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert;
|
|
|
|
|
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
|
|
|
|
import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
@ -19,6 +20,7 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXISTS;
|
|
|
|
|
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 线索 Service 实现类
|
|
|
|
|
@ -31,10 +33,13 @@ public class CrmClueServiceImpl implements CrmClueService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private CrmClueMapper clueMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private CrmCustomerService customerService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long createClue(CrmClueCreateReqVO createReqVO) {
|
|
|
|
|
// TODO @wanwan:校验客户是否存在;以及类似的逻辑哈;如果目前还缺对应的模块的 service,可以先给自己写 todo;
|
|
|
|
|
// 校验客户是否存在
|
|
|
|
|
validateCustomerExists(createReqVO.getCustomerId());
|
|
|
|
|
// 插入
|
|
|
|
|
CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO);
|
|
|
|
|
clueMapper.insert(clue);
|
|
|
|
|
@ -44,9 +49,10 @@ public class CrmClueServiceImpl implements CrmClueService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateClue(CrmClueUpdateReqVO updateReqVO) {
|
|
|
|
|
// TODO @wanwan:校验客户是否存在;以及类似的逻辑哈;如果目前还缺对应的模块的 service,可以先给自己写 todo;
|
|
|
|
|
// 校验存在
|
|
|
|
|
validateClueExists(updateReqVO.getId());
|
|
|
|
|
// 校验客户是否存在
|
|
|
|
|
validateCustomerExists(updateReqVO.getCustomerId());
|
|
|
|
|
|
|
|
|
|
// 更新
|
|
|
|
|
CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO);
|
|
|
|
|
@ -90,4 +96,15 @@ public class CrmClueServiceImpl implements CrmClueService {
|
|
|
|
|
return clueMapper.selectList(exportReqVO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验客户是否存在
|
|
|
|
|
*
|
|
|
|
|
* @param customerId 客户id
|
|
|
|
|
*/
|
|
|
|
|
private void validateCustomerExists(Long customerId) {
|
|
|
|
|
if (customerService.getCustomer(customerId) == null) {
|
|
|
|
|
throw exception(CUSTOMER_NOT_EXISTS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|