mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-02-02 03:34:58 +08:00
feat: 客户表的 crud
This commit is contained in:
parent
04613af0cd
commit
866eaedfeb
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.dataobject.clue;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@ -43,8 +44,7 @@ public class CrmClueDO extends BaseDO {
|
||||
private String name;
|
||||
/**
|
||||
* 客户 id
|
||||
*
|
||||
* // TODO @wanwan:要写下关联的实体,以及对应的属性哈
|
||||
* 对应 {@link CrmCustomerDO#getId()}
|
||||
*/
|
||||
private Long customerId;
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user