Commit c18f5baa4b35d45161439f6368f16c2c9a0df954

Authored by Wanwan
1 parent 81b6aebf

feat: 调整客户表的字段

Showing 15 changed files with 95 additions and 98 deletions
sql/mysql/crm.sql
... ... @@ -203,8 +203,6 @@ CREATE TABLE `crm_customer` (
203 203 `rw_user_ids` varchar(4096) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '读写权限的用户编号数组',
204 204 `area_id` bigint DEFAULT NULL COMMENT '地区编号',
205 205 `detail_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '详细地址',
206   - `longitude` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地理位置经度',
207   - `latitude` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地理位置维度',
208 206 `contact_last_time` datetime DEFAULT NULL COMMENT '最后跟进时间',
209 207 `contact_next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
210 208 `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
... ... @@ -19,7 +19,6 @@ import javax.annotation.Resource;
19 19 import javax.servlet.http.HttpServletResponse;
20 20 import javax.validation.Valid;
21 21 import java.io.IOException;
22   -import java.util.Collection;
23 22 import java.util.List;
24 23  
25 24 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java
... ... @@ -6,8 +6,10 @@ import io.swagger.v3.oas.annotations.media.Schema;
6 6 import lombok.Data;
7 7 import org.springframework.format.annotation.DateTimeFormat;
8 8  
  9 +import javax.validation.constraints.Email;
9 10 import javax.validation.constraints.NotEmpty;
10 11 import javax.validation.constraints.NotNull;
  12 +import javax.validation.constraints.Size;
11 13 import java.time.LocalDateTime;
12 14  
13 15 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
... ... @@ -23,16 +25,6 @@ public class CrmCustomerBaseVO {
23 25 @NotEmpty(message = "客户名称不能为空")
24 26 private String name;
25 27  
26   - // TODO wanwan:这个字段应该只有 RespVO 会有;创建和修改不传递;
27   - @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
28   - @NotNull(message = "跟进状态不能为空")
29   - private Boolean followUpStatus;
30   -
31   - // TODO wanwan:这个字段应该只有 RespVO 会有;创建和修改不传递;
32   - @Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
33   - @NotNull(message = "锁定状态不能为空")
34   - private Boolean lockStatus;
35   -
36 28 @Schema(description = "手机", example = "18000000000")
37 29 @Mobile
38 30 private String mobile;
... ... @@ -44,32 +36,32 @@ public class CrmCustomerBaseVO {
44 36 @Schema(description = "网址", example = "https://www.baidu.com")
45 37 private String website;
46 38  
  39 + @Schema(description = "QQ", example = "123456789")
  40 + @Size(max = 20, message = "QQ长度不能超过20个字符")
  41 + private String qq;
  42 +
  43 + @Schema(description = "wechat", example = "123456789")
  44 + @Size(max = 255, message = "微信长度不能超过255个字符")
  45 + private String wechat;
  46 +
  47 + @Schema(description = "email", example = "123456789@qq.com")
  48 + @Email(message = "邮箱格式不正确")
  49 + @Size(max = 255, message = "邮箱长度不能超过255个字符")
  50 + private String email;
  51 +
  52 + @Schema(description = "客户描述", example = "任意文字")
  53 + @Size(max = 4096, message = "客户描述长度不能超过255个字符")
  54 + private String description;
  55 +
47 56 @Schema(description = "备注", example = "随便")
48 57 private String remark;
49 58  
50   - // TODO wanwan:这个字段应该只有 RespVO 会有;创建和修改不传递;因为它会在“移交”里面做哈
51   - @Schema(description = "负责人的用户编号", example = "25682")
52   - @NotNull(message = "负责人不能为空")
53   - private Long ownerUserId;
54   -
55 59 @Schema(description = "地区编号", example = "20158")
56 60 private Long areaId;
57 61  
58 62 @Schema(description = "详细地址", example = "北京市海淀区")
59 63 private String detailAddress;
60 64  
61   - // TODO @芋艿:longitude、latitude 这两个字段删除;
62   - @Schema(description = "地理位置经度", example = "116.40341")
63   - private String longitude;
64   -
65   - @Schema(description = "地理位置维度", example = "39.92409")
66   - private String latitude;
67   -
68   - // TODO wanwan:这个字段应该只有 RespVO 会有;创建和修改不传递;
69   - @Schema(description = "最后跟进时间")
70   - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
71   - private LocalDateTime contactLastTime;
72   -
73 65 @Schema(description = "下次联系时间")
74 66 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
75 67 private LocalDateTime contactNextTime;
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java
... ... @@ -11,12 +11,4 @@ import lombok.ToString;
11 11 @ToString(callSuper = true)
12 12 public class CrmCustomerCreateReqVO extends CrmCustomerBaseVO {
13 13  
14   - // TODO @wanwan:类型应该是传递 List<Long>; 不过这个字段,默认新建的时候不传递,在“移交”功能里管理
15   - @Schema(description = "只读权限的用户编号数组")
16   - private String roUserIds;
17   -
18   - // TODO @wanwan:类型应该是传递 List<Long>; 不过这个字段,默认新建的时候不传递,在“移交”功能里管理
19   - @Schema(description = "读写权限的用户编号数组")
20   - private String rwUserIds;
21   -
22 14 }
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java
... ... @@ -44,6 +44,18 @@ public class CrmCustomerExcelVO {
44 44 @ExcelProperty("网址")
45 45 private String website;
46 46  
  47 + @ExcelProperty("QQ")
  48 + private String qq;
  49 +
  50 + @ExcelProperty("wechat")
  51 + private String wechat;
  52 +
  53 + @ExcelProperty("email")
  54 + private String email;
  55 +
  56 + @ExcelProperty("客户描述")
  57 + private String description;
  58 +
47 59 @ExcelProperty("备注")
48 60 private String remark;
49 61  
... ... @@ -56,12 +68,6 @@ public class CrmCustomerExcelVO {
56 68 @ExcelProperty("详细地址")
57 69 private String detailAddress;
58 70  
59   - @ExcelProperty("地理位置经度")
60   - private String longitude;
61   -
62   - @ExcelProperty("地理位置维度")
63   - private String latitude;
64   -
65 71 @ExcelProperty("最后跟进时间")
66 72 private LocalDateTime contactLastTime;
67 73  
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java
... ... @@ -14,10 +14,4 @@ public class CrmCustomerExportReqVO {
14 14 @Schema(description = "手机", example = "18000000000")
15 15 private String mobile;
16 16  
17   - @Schema(description = "电话", example = "18000000000")
18   - private String telephone;
19   -
20   - @Schema(description = "网址", example = "https://www.baidu.com")
21   - private String website;
22   -
23 17 }
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java
... ... @@ -18,13 +18,5 @@ public class CrmCustomerPageReqVO extends PageParam {
18 18 @Schema(description = "手机", example = "18000000000")
19 19 private String mobile;
20 20  
21   - // TODO @wanwan:这个字段不需要哈
22   - @Schema(description = "电话", example = "18000000000")
23   - private String telephone;
24   -
25   - // TODO @wanwan:这个字段不需要哈
26   - @Schema(description = "网址", example = "https://www.baidu.com")
27   - private String website;
28   -
29 21 // TODO @芋艿:场景;
30 22 }
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java
... ... @@ -4,9 +4,12 @@ import io.swagger.v3.oas.annotations.media.Schema;
4 4 import lombok.Data;
5 5 import lombok.EqualsAndHashCode;
6 6 import lombok.ToString;
  7 +import org.springframework.format.annotation.DateTimeFormat;
7 8  
8 9 import java.time.LocalDateTime;
9 10  
  11 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  12 +
10 13 @Schema(description = "管理后台 - 客户 Response VO")
11 14 @Data
12 15 @EqualsAndHashCode(callSuper = true)
... ... @@ -16,9 +19,22 @@ public class CrmCustomerRespVO extends CrmCustomerBaseVO {
16 19 @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
17 20 private Long id;
18 21  
  22 + @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
  23 + private Boolean followUpStatus;
  24 +
  25 + @Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
  26 + private Boolean lockStatus;
  27 +
19 28 @Schema(description = "成交状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
20 29 private Boolean dealStatus;
21 30  
  31 + @Schema(description = "负责人的用户编号", example = "25682")
  32 + private Long ownerUserId;
  33 +
  34 + @Schema(description = "最后跟进时间")
  35 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  36 + private LocalDateTime contactLastTime;
  37 +
22 38 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
23 39 private LocalDateTime createTime;
24 40  
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java
... ... @@ -17,11 +17,4 @@ public class CrmCustomerUpdateReqVO extends CrmCustomerBaseVO {
17 17 @NotNull(message = "编号不能为空")
18 18 private Long id;
19 19  
20   - // TODO @wanwan:下面两个字段,同 CrmCustomerCreateReqVO
21   - @Schema(description = "只读权限的用户编号数组")
22   - private String roUserIds;
23   -
24   - @Schema(description = "读写权限的用户编号数组")
25   - private String rwUserIds;
26   -
27 20 }
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java
1 1 package cn.iocoder.yudao.module.crm.dal.dataobject.customer;
2 2  
3 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
4 5 import com.baomidou.mybatisplus.annotation.KeySequence;
  6 +import com.baomidou.mybatisplus.annotation.TableField;
5 7 import com.baomidou.mybatisplus.annotation.TableId;
6 8 import com.baomidou.mybatisplus.annotation.TableName;
7 9 import lombok.*;
8 10  
9 11 import java.time.LocalDateTime;
  12 +import java.util.List;
10 13  
11 14 // TODO 芋艿:调整下字段
12 15 /**
... ... @@ -14,7 +17,7 @@ import java.time.LocalDateTime;
14 17 *
15 18 * @author Wanwan
16 19 */
17   -@TableName("crm_customer")
  20 +@TableName(value = "crm_customer", autoResultMap = true)
18 21 @KeySequence("crm_customer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
19 22 @Data
20 23 @EqualsAndHashCode(callSuper = true)
... ... @@ -58,6 +61,22 @@ public class CrmCustomerDO extends BaseDO {
58 61 */
59 62 private String website;
60 63 /**
  64 + * QQ
  65 + */
  66 + private String qq;
  67 + /**
  68 + * wechat
  69 + */
  70 + private String wechat;
  71 + /**
  72 + * email
  73 + */
  74 + private String email;
  75 + /**
  76 + * 客户描述
  77 + */
  78 + private String description;
  79 + /**
61 80 * 备注
62 81 */
63 82 private String remark;
... ... @@ -65,15 +84,16 @@ public class CrmCustomerDO extends BaseDO {
65 84 * 负责人的用户编号
66 85 */
67 86 private Long ownerUserId;
68   - // TODO @wanwan:下面两个字段,使用 List<Long>,然后使用 typeHandler = LongListTypeHandler 解决持久化的问题;注意类上需要加 autoResultMap = true
69 87 /**
70 88 * 只读权限的用户编号数组
71 89 */
72   - private String roUserIds;
  90 + @TableField(typeHandler = LongListTypeHandler.class)
  91 + private List<Long> roUserIds;
73 92 /**
74 93 * 读写权限的用户编号数组
75 94 */
76   - private String rwUserIds;
  95 + @TableField(typeHandler = LongListTypeHandler.class)
  96 + private List<Long> rwUserIds;
77 97 /**
78 98 * 地区编号
79 99 */
... ... @@ -82,15 +102,6 @@ public class CrmCustomerDO extends BaseDO {
82 102 * 详细地址
83 103 */
84 104 private String detailAddress;
85   - // TODO @wanwan:下面两个字段:删除
86   - /**
87   - * 地理位置经度
88   - */
89   - private String longitude;
90   - /**
91   - * 地理位置维度
92   - */
93   - private String latitude;
94 105 /**
95 106 * 最后跟进时间
96 107 */
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java
... ... @@ -22,8 +22,6 @@ public interface CrmCustomerMapper extends BaseMapperX&lt;CrmCustomerDO&gt; {
22 22 return selectPage(reqVO, new LambdaQueryWrapperX<CrmCustomerDO>()
23 23 .likeIfPresent(CrmCustomerDO::getName, reqVO.getName())
24 24 .eqIfPresent(CrmCustomerDO::getMobile, reqVO.getMobile())
25   - .eqIfPresent(CrmCustomerDO::getTelephone, reqVO.getTelephone())
26   - .likeIfPresent(CrmCustomerDO::getWebsite, reqVO.getWebsite())
27 25 .orderByDesc(CrmCustomerDO::getId));
28 26 }
29 27  
... ... @@ -31,8 +29,6 @@ public interface CrmCustomerMapper extends BaseMapperX&lt;CrmCustomerDO&gt; {
31 29 return selectList(new LambdaQueryWrapperX<CrmCustomerDO>()
32 30 .likeIfPresent(CrmCustomerDO::getName, reqVO.getName())
33 31 .eqIfPresent(CrmCustomerDO::getMobile, reqVO.getMobile())
34   - .eqIfPresent(CrmCustomerDO::getTelephone, reqVO.getTelephone())
35   - .likeIfPresent(CrmCustomerDO::getWebsite, reqVO.getWebsite())
36 32 .orderByDesc(CrmCustomerDO::getId));
37 33 }
38 34  
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java
... ... @@ -39,7 +39,7 @@ public class CrmClueServiceImpl implements CrmClueService {
39 39 @Override
40 40 public Long createClue(CrmClueCreateReqVO createReqVO) {
41 41 // 校验客户是否存在
42   - validateCustomerExists(createReqVO.getCustomerId());
  42 + customerService.validateCustomer(createReqVO.getCustomerId());
43 43 // 插入
44 44 CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO);
45 45 clueMapper.insert(clue);
... ... @@ -52,7 +52,7 @@ public class CrmClueServiceImpl implements CrmClueService {
52 52 // 校验存在
53 53 validateClueExists(updateReqVO.getId());
54 54 // 校验客户是否存在
55   - validateCustomerExists(updateReqVO.getCustomerId());
  55 + customerService.validateCustomer(updateReqVO.getCustomerId());
56 56  
57 57 // 更新
58 58 CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO);
... ... @@ -96,16 +96,4 @@ public class CrmClueServiceImpl implements CrmClueService {
96 96 return clueMapper.selectList(exportReqVO);
97 97 }
98 98  
99   - // TODO @wanwan:可以在 CrmClueServiceImpl 中,增加一个方法,用于校验客户是否存在;validateCustomer;然后其它方法可以调用它。不过要注意,需要把 CustomerDO 返回,因为其它模块可能要它的信息
100   - /**
101   - * 校验客户是否存在
102   - *
103   - * @param customerId 客户id
104   - */
105   - private void validateCustomerExists(Long customerId) {
106   - if (customerService.getCustomer(customerId) == null) {
107   - throw exception(CUSTOMER_NOT_EXISTS);
108   - }
109   - }
110   -
111 99 }
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java
... ... @@ -72,4 +72,12 @@ public interface CrmCustomerService {
72 72 */
73 73 List<CrmCustomerDO> getCustomerList(CrmCustomerExportReqVO exportReqVO);
74 74  
  75 + /**
  76 + * 校验客户是否存在
  77 + *
  78 + * @param customerId 客户id
  79 + * @return
  80 + */
  81 + CrmCustomerDO validateCustomer(Long customerId);
  82 +
75 83 }
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
... ... @@ -85,4 +85,18 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
85 85 return customerMapper.selectList(exportReqVO);
86 86 }
87 87  
  88 + /**
  89 + * 校验客户是否存在
  90 + *
  91 + * @param customerId 客户id
  92 + * @return
  93 + */
  94 + @Override
  95 + public CrmCustomerDO validateCustomer(Long customerId) {
  96 + CrmCustomerDO customer = getCustomer(customerId);
  97 + if (Objects.isNull(customer)) {
  98 + throw exception(CUSTOMER_NOT_EXISTS);
  99 + }
  100 + return customer;
  101 + }
88 102 }
... ...
yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql
... ... @@ -113,8 +113,6 @@ CREATE TABLE IF NOT EXISTS &quot;crm_customer&quot; (
113 113 "rw_user_ids" varchar,
114 114 "area_id" bigint,
115 115 "detail_address" varchar,
116   - "longitude" varchar,
117   - "latitude" varchar,
118 116 "contact_last_time" varchar,
119 117 "contact_next_time" varchar,
120 118 "creator" varchar DEFAULT '',
... ...