mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	code review:crm 客户模块的实现
This commit is contained in:
		| @@ -10,7 +10,6 @@ import org.springframework.format.annotation.DateTimeFormat; | ||||
|  | ||||
| import javax.validation.constraints.Email; | ||||
| import javax.validation.constraints.NotEmpty; | ||||
| import javax.validation.constraints.NotNull; | ||||
| import javax.validation.constraints.Size; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| @@ -49,20 +48,20 @@ public class CrmCustomerBaseVO { | ||||
|     private String website; | ||||
|  | ||||
|     @Schema(description = "QQ", example = "123456789") | ||||
|     @Size(max = 20, message = "QQ长度不能超过20个字符") | ||||
|     @Size(max = 20, message = "QQ长度不能超过 20 个字符") | ||||
|     private String qq; | ||||
|  | ||||
|     @Schema(description = "wechat", example = "123456789") | ||||
|     @Size(max = 255, message = "微信长度不能超过255个字符") | ||||
|     @Size(max = 255, message = "微信长度不能超过 255 个字符") | ||||
|     private String wechat; | ||||
|  | ||||
|     @Schema(description = "email", example = "123456789@qq.com") | ||||
|     @Email(message = "邮箱格式不正确") | ||||
|     @Size(max = 255, message = "邮箱长度不能超过255个字符") | ||||
|     @Size(max = 255, message = "邮箱长度不能超过 255 个字符") | ||||
|     private String email; | ||||
|  | ||||
|     @Schema(description = "客户描述", example = "任意文字") | ||||
|     @Size(max = 4096, message = "客户描述长度不能超过255个字符") | ||||
|     @Size(max = 4096, message = "客户描述长度不能超过 4096 个字符") | ||||
|     private String description; | ||||
|  | ||||
|     @Schema(description = "备注", example = "随便") | ||||
|   | ||||
| @@ -11,4 +11,6 @@ import lombok.ToString; | ||||
| @ToString(callSuper = true) | ||||
| public class CrmCustomerCreateReqVO extends CrmCustomerBaseVO { | ||||
|  | ||||
|     // TODO @wanwan:负责人 | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -51,17 +51,20 @@ public class CrmCustomerDO extends BaseDO { | ||||
|     private Boolean dealStatus; | ||||
|     /** | ||||
|      * 所属行业 | ||||
|      * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY} | ||||
|      * | ||||
|      * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_CUSTOMER_INDUSTRY} | ||||
|      */ | ||||
|     private Integer industryId; | ||||
|     /** | ||||
|      * 客户等级 | ||||
|      * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL} | ||||
|      * | ||||
|      * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_CUSTOMER_LEVEL} | ||||
|      */ | ||||
|     private Integer level; | ||||
|     /** | ||||
|      * 客户来源 | ||||
|      * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE} | ||||
|      * | ||||
|      * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_CUSTOMER_SOURCE} | ||||
|      */ | ||||
|     private Integer source; | ||||
|     /** | ||||
|   | ||||
| @@ -19,7 +19,7 @@ import java.util.List; | ||||
| public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | ||||
|  | ||||
|     default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO reqVO) { | ||||
|         // TODO @Wanwan 填充负责人,所属部门字段 | ||||
|         // TODO @Wanwan 填充负责人,所属部门字段;这个可以在 controller 填哈; | ||||
|         return selectPage(reqVO, new LambdaQueryWrapperX<CrmCustomerDO>() | ||||
|                 .likeIfPresent(CrmCustomerDO::getName, reqVO.getName()) | ||||
|                 .eqIfPresent(CrmCustomerDO::getMobile, reqVO.getMobile()) | ||||
|   | ||||
| @@ -75,8 +75,8 @@ public interface CrmCustomerService { | ||||
|     /** | ||||
|      * 校验客户是否存在 | ||||
|      * | ||||
|      * @param customerId 客户id | ||||
|      * @return | ||||
|      * @param customerId 客户 id | ||||
|      * @return 客户 | ||||
|      */ | ||||
|     CrmCustomerDO validateCustomer(Long customerId); | ||||
|  | ||||
|   | ||||
| @@ -1,23 +1,26 @@ | ||||
| package cn.iocoder.yudao.module.crm.service.customer; | ||||
|  | ||||
| import cn.iocoder.yudao.module.system.api.dept.DeptApi; | ||||
| import org.springframework.stereotype.Service; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
|  | ||||
| import java.util.*; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
|  | ||||
| import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; | ||||
| import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | ||||
|  | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.collection.ListUtil; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerExportReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||||
| import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; | ||||
| import cn.iocoder.yudao.module.system.api.dept.DeptApi; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; | ||||
|  | ||||
| /** | ||||
|  * 客户 Service 实现类 | ||||
| @@ -31,7 +34,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||||
|     @Resource | ||||
|     private CrmCustomerMapper customerMapper; | ||||
|     @Resource | ||||
|     private DeptApi deptApi; | ||||
|     private DeptApi deptApi; // TODO @wanwan:拼接数据,可以放到 controller;所以这里的引入,可以考虑放到 controller 哈; | ||||
|  | ||||
|     @Override | ||||
|     public Long createCustomer(CrmCustomerCreateReqVO createReqVO) { | ||||
| @@ -46,6 +49,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||||
|     public void updateCustomer(CrmCustomerUpdateReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|         validateCustomerExists(updateReqVO.getId()); | ||||
|         // TODO 芋艿:数据权限,校验是否可以操作 | ||||
|  | ||||
|         // 更新 | ||||
|         CrmCustomerDO updateObj = CrmCustomerConvert.INSTANCE.convert(updateReqVO); | ||||
|         customerMapper.updateById(updateObj); | ||||
| @@ -55,6 +60,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||||
|     public void deleteCustomer(Long id) { | ||||
|         // 校验存在 | ||||
|         validateCustomerExists(id); | ||||
|         // TODO 芋艿:数据权限,校验是否可以操作 | ||||
|  | ||||
|         // 删除 | ||||
|         customerMapper.deleteById(id); | ||||
|     } | ||||
| @@ -80,6 +87,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||||
|  | ||||
|     @Override | ||||
|     public PageResult<CrmCustomerDO> getCustomerPage(CrmCustomerPageReqVO pageReqVO) { | ||||
|         // TODO 芋艿:数据权限,是否可以查询到; | ||||
|         return customerMapper.selectPage(pageReqVO); | ||||
|     } | ||||
|  | ||||
| @@ -88,6 +96,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||||
|         return customerMapper.selectList(exportReqVO); | ||||
|     } | ||||
|  | ||||
|     // TODO wanwan:service 接口已经注释,实现类就不需要了。 | ||||
|     /** | ||||
|      * 校验客户是否存在 | ||||
|      * | ||||
| @@ -102,4 +111,5 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||||
|         } | ||||
|         return customer; | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV