mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	feat: 客户表的 crud
This commit is contained in:
		| @@ -1,6 +1,7 @@ | |||||||
| package cn.iocoder.yudao.module.crm.dal.dataobject.clue; | package cn.iocoder.yudao.module.crm.dal.dataobject.clue; | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 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.KeySequence; | ||||||
| import com.baomidou.mybatisplus.annotation.TableId; | import com.baomidou.mybatisplus.annotation.TableId; | ||||||
| import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||||
| @@ -43,8 +44,7 @@ public class CrmClueDO extends BaseDO { | |||||||
|     private String name; |     private String name; | ||||||
|     /** |     /** | ||||||
|      * 客户 id |      * 客户 id | ||||||
|      * |      * 对应 {@link CrmCustomerDO#getId()} | ||||||
|      * // TODO @wanwan:要写下关联的实体,以及对应的属性哈 |  | ||||||
|      */ |      */ | ||||||
|     private Long customerId; |     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.convert.clue.CrmClueConvert; | ||||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; | 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.dal.mysql.clue.CrmClueMapper; | ||||||
|  | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
| import org.springframework.validation.annotation.Validated; | 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.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.CLUE_NOT_EXISTS; | ||||||
|  | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 线索 Service 实现类 |  * 线索 Service 实现类 | ||||||
| @@ -31,10 +33,13 @@ public class CrmClueServiceImpl implements CrmClueService { | |||||||
|  |  | ||||||
|     @Resource |     @Resource | ||||||
|     private CrmClueMapper clueMapper; |     private CrmClueMapper clueMapper; | ||||||
|  |     @Resource | ||||||
|  |     private CrmCustomerService customerService; | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public Long createClue(CrmClueCreateReqVO createReqVO) { |     public Long createClue(CrmClueCreateReqVO createReqVO) { | ||||||
|         // TODO @wanwan:校验客户是否存在;以及类似的逻辑哈;如果目前还缺对应的模块的 service,可以先给自己写 todo; |         // 校验客户是否存在 | ||||||
|  |         validateCustomerExists(createReqVO.getCustomerId()); | ||||||
|         // 插入 |         // 插入 | ||||||
|         CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO); |         CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO); | ||||||
|         clueMapper.insert(clue); |         clueMapper.insert(clue); | ||||||
| @@ -44,9 +49,10 @@ public class CrmClueServiceImpl implements CrmClueService { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void updateClue(CrmClueUpdateReqVO updateReqVO) { |     public void updateClue(CrmClueUpdateReqVO updateReqVO) { | ||||||
|         // TODO @wanwan:校验客户是否存在;以及类似的逻辑哈;如果目前还缺对应的模块的 service,可以先给自己写 todo; |  | ||||||
|         // 校验存在 |         // 校验存在 | ||||||
|         validateClueExists(updateReqVO.getId()); |         validateClueExists(updateReqVO.getId()); | ||||||
|  |         // 校验客户是否存在 | ||||||
|  |         validateCustomerExists(updateReqVO.getCustomerId()); | ||||||
|  |  | ||||||
|         // 更新 |         // 更新 | ||||||
|         CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO); |         CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO); | ||||||
| @@ -90,4 +96,15 @@ public class CrmClueServiceImpl implements CrmClueService { | |||||||
|         return clueMapper.selectList(exportReqVO); |         return clueMapper.selectList(exportReqVO); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 校验客户是否存在 | ||||||
|  |      * | ||||||
|  |      * @param customerId 客户id | ||||||
|  |      */ | ||||||
|  |     private void validateCustomerExists(Long customerId) { | ||||||
|  |         if (customerService.getCustomer(customerId) == null) { | ||||||
|  |             throw exception(CUSTOMER_NOT_EXISTS); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Wanwan
					Wanwan