Commit fa1aa51c960152b505768778cbb076b88a889fe8

Authored by 芋道源码
Committed by Gitee
2 parents bc6cdecb db03b10d

!771 同步最新的 CRM 代码

Merge pull request !771 from 芋道源码/feature/crm
Showing 156 changed files with 2221 additions and 2747 deletions
sql/mysql/crm.sql
1 SET NAMES utf8mb4; 1 SET NAMES utf8mb4;
  2 +-- `ruoyi-vue-pro`.crm_contact definition
  3 +
sql/mysql/crm_menu.sql
1 --- ----------------------------  
2 --- 客户公海配置  
3 --- ----------------------------  
4 --- 菜单 SQL  
5 -INSERT INTO system_menu(  
6 - name, permission, type, sort, parent_id,  
7 - path, icon, component, status, component_name  
8 -)  
9 -VALUES (  
10 - '客户公海配置', '', 2, 0, 2397,  
11 - 'customer-pool-config', 'ep:data-analysis', 'crm/customerPoolConf/index', 0, 'CustomerPoolConf'  
12 -);  
13 -  
14 --- 按钮父菜单ID  
15 --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码  
16 -SELECT @parentId := LAST_INSERT_ID();  
17 -  
18 --- 按钮 SQL  
19 -INSERT INTO system_menu(  
20 - name, permission, type, sort, parent_id,  
21 - path, icon, component, status  
22 -)  
23 -VALUES (  
24 - '客户公海配置保存', 'crm:customer-pool-config:update', 3, 1, @parentId,  
25 - '', '', '', 0  
26 -);  
27 -  
28 -  
29 -  
30 -  
31 --- ----------------------------  
32 --- 客户限制配置管理  
33 --- ----------------------------  
34 --- 菜单 SQL  
35 -INSERT INTO system_menu(  
36 - name, permission, type, sort, parent_id,  
37 - path, icon, component, status, component_name  
38 -)  
39 -VALUES (  
40 - '客户限制配置管理', '', 2, 0, 2397,  
41 - 'customer-limit-config', '', 'crm/customerLimitConfig/index', 0, 'CrmCustomerLimitConfig'  
42 -);  
43 -  
44 --- 按钮父菜单ID  
45 --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码  
46 -SELECT @parentId := LAST_INSERT_ID();  
47 -  
48 --- 按钮 SQL  
49 -INSERT INTO system_menu(  
50 - name, permission, type, sort, parent_id,  
51 - path, icon, component, status  
52 -)  
53 -VALUES (  
54 - '客户限制配置查询', 'crm:customer-limit-config:query', 3, 1, @parentId,  
55 - '', '', '', 0  
56 -);  
57 -INSERT INTO system_menu(  
58 - name, permission, type, sort, parent_id,  
59 - path, icon, component, status  
60 -)  
61 -VALUES (  
62 - '客户限制配置创建', 'crm:customer-limit-config:create', 3, 2, @parentId,  
63 - '', '', '', 0  
64 -);  
65 -INSERT INTO system_menu(  
66 - name, permission, type, sort, parent_id,  
67 - path, icon, component, status  
68 -)  
69 -VALUES (  
70 - '客户限制配置更新', 'crm:customer-limit-config:update', 3, 3, @parentId,  
71 - '', '', '', 0  
72 -);  
73 -INSERT INTO system_menu(  
74 - name, permission, type, sort, parent_id,  
75 - path, icon, component, status  
76 -)  
77 -VALUES (  
78 - '客户限制配置删除', 'crm:customer-limit-config:delete', 3, 4, @parentId,  
79 - '', '', '', 0  
80 -);  
81 -INSERT INTO system_menu(  
82 - name, permission, type, sort, parent_id,  
83 - path, icon, component, status  
84 -)  
85 -VALUES (  
86 - '客户限制配置导出', 'crm:customer-limit-config:export', 3, 5, @parentId,  
87 - '', '', '', 0  
88 -);  
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java
@@ -73,6 +73,23 @@ public class CollectionUtils { @@ -73,6 +73,23 @@ public class CollectionUtils {
73 return from.stream().filter(filter).map(func).filter(Objects::nonNull).collect(Collectors.toList()); 73 return from.stream().filter(filter).map(func).filter(Objects::nonNull).collect(Collectors.toList());
74 } 74 }
75 75
  76 + public static <T, U> List<U> convertListByFlatMap(Collection<T> from,
  77 + Function<T, ? extends Stream<? extends U>> func) {
  78 + if (CollUtil.isEmpty(from)) {
  79 + return new ArrayList<>();
  80 + }
  81 + return from.stream().flatMap(func).filter(Objects::nonNull).collect(Collectors.toList());
  82 + }
  83 +
  84 + public static <T, U, R> List<R> convertListByFlatMap(Collection<T> from,
  85 + Function<? super T, ? extends U> mapper,
  86 + Function<U, ? extends Stream<? extends R>> func) {
  87 + if (CollUtil.isEmpty(from)) {
  88 + return new ArrayList<>();
  89 + }
  90 + return from.stream().map(mapper).flatMap(func).filter(Objects::nonNull).collect(Collectors.toList());
  91 + }
  92 +
76 public static <K, V> List<V> mergeValuesFromMap(Map<K, List<V>> map) { 93 public static <K, V> List<V> mergeValuesFromMap(Map<K, List<V>> map) {
77 return map.values() 94 return map.values()
78 .stream() 95 .stream()
@@ -101,6 +118,23 @@ public class CollectionUtils { @@ -101,6 +118,23 @@ public class CollectionUtils {
101 return from.stream().filter(filter).collect(Collectors.toMap(keyFunc, v -> v)); 118 return from.stream().filter(filter).collect(Collectors.toMap(keyFunc, v -> v));
102 } 119 }
103 120
  121 + public static <T, U> Set<U> convertSetByFlatMap(Collection<T> from,
  122 + Function<T, ? extends Stream<? extends U>> func) {
  123 + if (CollUtil.isEmpty(from)) {
  124 + return new HashSet<>();
  125 + }
  126 + return from.stream().flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet());
  127 + }
  128 +
  129 + public static <T, U, R> Set<R> convertSetByFlatMap(Collection<T> from,
  130 + Function<? super T, ? extends U> mapper,
  131 + Function<U, ? extends Stream<? extends R>> func) {
  132 + if (CollUtil.isEmpty(from)) {
  133 + return new HashSet<>();
  134 + }
  135 + return from.stream().map(mapper).flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet());
  136 + }
  137 +
104 public static <T, K> Map<K, T> convertMap(Collection<T> from, Function<T, K> keyFunc) { 138 public static <T, K> Map<K, T> convertMap(Collection<T> from, Function<T, K> keyFunc) {
105 if (CollUtil.isEmpty(from)) { 139 if (CollUtil.isEmpty(from)) {
106 return new HashMap<>(); 140 return new HashMap<>();
@@ -272,38 +306,4 @@ public class CollectionUtils { @@ -272,38 +306,4 @@ public class CollectionUtils {
272 return deptId == null ? Collections.emptyList() : Collections.singleton(deptId); 306 return deptId == null ? Collections.emptyList() : Collections.singleton(deptId);
273 } 307 }
274 308
275 - public static <T, U> List<U> convertListByFlatMap(Collection<T> from,  
276 - Function<T, ? extends Stream<? extends U>> func) {  
277 - if (CollUtil.isEmpty(from)) {  
278 - return new ArrayList<>();  
279 - }  
280 - return from.stream().flatMap(func).filter(Objects::nonNull).collect(Collectors.toList());  
281 - }  
282 -  
283 - public static <T, U, R> List<R> convertListByFlatMap(Collection<T> from,  
284 - Function<? super T, ? extends U> mapper,  
285 - Function<U, ? extends Stream<? extends R>> func) {  
286 - if (CollUtil.isEmpty(from)) {  
287 - return new ArrayList<>();  
288 - }  
289 - return from.stream().map(mapper).flatMap(func).filter(Objects::nonNull).collect(Collectors.toList());  
290 - }  
291 -  
292 - public static <T, U> Set<U> convertSetByFlatMap(Collection<T> from,  
293 - Function<T, ? extends Stream<? extends U>> func) {  
294 - if (CollUtil.isEmpty(from)) {  
295 - return new HashSet<>();  
296 - }  
297 - return from.stream().flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet());  
298 - }  
299 -  
300 - public static <T, U, R> Set<R> convertSetByFlatMap(Collection<T> from,  
301 - Function<? super T, ? extends U> mapper,  
302 - Function<U, ? extends Stream<? extends R>> func) {  
303 - if (CollUtil.isEmpty(from)) {  
304 - return new HashSet<>();  
305 - }  
306 - return from.stream().map(mapper).flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet());  
307 - }  
308 -  
309 } 309 }
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/spring/SpringExpressionUtils.java
@@ -3,7 +3,7 @@ package cn.iocoder.yudao.framework.common.util.spring; @@ -3,7 +3,7 @@ package cn.iocoder.yudao.framework.common.util.spring;
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 import cn.hutool.core.map.MapUtil; 4 import cn.hutool.core.map.MapUtil;
5 import cn.hutool.core.util.ArrayUtil; 5 import cn.hutool.core.util.ArrayUtil;
6 -import org.aspectj.lang.ProceedingJoinPoint; 6 +import org.aspectj.lang.JoinPoint;
7 import org.aspectj.lang.reflect.MethodSignature; 7 import org.aspectj.lang.reflect.MethodSignature;
8 import org.springframework.core.DefaultParameterNameDiscoverer; 8 import org.springframework.core.DefaultParameterNameDiscoverer;
9 import org.springframework.core.ParameterNameDiscoverer; 9 import org.springframework.core.ParameterNameDiscoverer;
@@ -25,7 +25,7 @@ import java.util.Map; @@ -25,7 +25,7 @@ import java.util.Map;
25 public class SpringExpressionUtils { 25 public class SpringExpressionUtils {
26 26
27 /** 27 /**
28 - * spel表达式解析器 28 + * Spring EL 表达式解析器
29 */ 29 */
30 private static final ExpressionParser EXPRESSION_PARSER = new SpelExpressionParser(); 30 private static final ExpressionParser EXPRESSION_PARSER = new SpelExpressionParser();
31 /** 31 /**
@@ -43,7 +43,7 @@ public class SpringExpressionUtils { @@ -43,7 +43,7 @@ public class SpringExpressionUtils {
43 * @param expressionString EL 表达式数组 43 * @param expressionString EL 表达式数组
44 * @return 执行界面 44 * @return 执行界面
45 */ 45 */
46 - public static Object parseExpression(ProceedingJoinPoint joinPoint, String expressionString) { 46 + public static Object parseExpression(JoinPoint joinPoint, String expressionString) {
47 Map<String, Object> result = parseExpressions(joinPoint, Collections.singletonList(expressionString)); 47 Map<String, Object> result = parseExpressions(joinPoint, Collections.singletonList(expressionString));
48 return result.get(expressionString); 48 return result.get(expressionString);
49 } 49 }
@@ -55,7 +55,7 @@ public class SpringExpressionUtils { @@ -55,7 +55,7 @@ public class SpringExpressionUtils {
55 * @param expressionStrings EL 表达式数组 55 * @param expressionStrings EL 表达式数组
56 * @return 结果,key 为表达式,value 为对应值 56 * @return 结果,key 为表达式,value 为对应值
57 */ 57 */
58 - public static Map<String, Object> parseExpressions(ProceedingJoinPoint joinPoint, List<String> expressionStrings) { 58 + public static Map<String, Object> parseExpressions(JoinPoint joinPoint, List<String> expressionStrings) {
59 // 如果为空,则不进行解析 59 // 如果为空,则不进行解析
60 if (CollUtil.isEmpty(expressionStrings)) { 60 if (CollUtil.isEmpty(expressionStrings)) {
61 return MapUtil.newHashMap(); 61 return MapUtil.newHashMap();
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/AuditStatusEnum.java deleted
1 -package cn.iocoder.yudao.module.crm.enums;  
2 -  
3 -import cn.iocoder.yudao.framework.common.core.IntArrayValuable;  
4 -  
5 -import java.util.Arrays;  
6 -  
7 -// TODO @liuhongfeng:这个状态,还是搞成专属 CrmReceivableDO 专属的 status;  
8 -/**  
9 - * 流程审批状态枚举类  
10 - * 0 未审核 1 审核通过 2 审核拒绝 3 审核中 4 已撤回 TODO @liuhongfeng:这一行可以删除,因为已经有枚举属性了哈;  
11 - * @author 赤焰  
12 - */  
13 -// TODO @liuhongfeng:可以使用 @Getter、@AllArgsConstructor 简化 get、构造方法  
14 -public enum AuditStatusEnum implements IntArrayValuable {  
15 -  
16 - // TODO @liuhongfeng:草稿 0;10 审核中;20 审核通过;30 审核拒绝;40 已撤回;主要是留好间隙,万一每个地方要做点拓展; 然后,枚举字段的顺序调整下,审批中,一定要放两个审批通过、拒绝前面哈;  
17 - /**  
18 - * 未审批  
19 - */  
20 - AUDIT_NEW(0, "未审批"),  
21 - /**  
22 - * 审核通过  
23 - */  
24 - AUDIT_FINISH(1, "审核通过"),  
25 - /**  
26 - * 审核拒绝  
27 - */  
28 - AUDIT_REJECT(2, "审核拒绝"),  
29 - /**  
30 - * 审核中  
31 - */  
32 - AUDIT_DOING(3, "审核中"),  
33 - /**  
34 - * 已撤回  
35 - */  
36 - AUDIT_RETURN(4, "已撤回");  
37 -  
38 - // TODO liuhongfeng:value 改成 status;desc 改成 name;  
39 - private final Integer value;  
40 - private final String desc;  
41 -  
42 - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AuditStatusEnum::getValue).toArray();  
43 -  
44 - AuditStatusEnum(Integer value, String desc) {  
45 - this.value = value;  
46 - this.desc = desc;  
47 - }  
48 -  
49 - public Integer getValue() {  
50 - return value;  
51 - }  
52 -  
53 - public String getDesc() {  
54 - return desc;  
55 - }  
56 -  
57 - @Override  
58 - public int[] array() {  
59 - return ARRAYS;  
60 - }  
61 -}  
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java
@@ -11,6 +11,6 @@ public interface DictTypeConstants { @@ -11,6 +11,6 @@ public interface DictTypeConstants {
11 String CRM_CUSTOMER_INDUSTRY = "crm_customer_industry"; // CRM 客户所属行业 11 String CRM_CUSTOMER_INDUSTRY = "crm_customer_industry"; // CRM 客户所属行业
12 String CRM_CUSTOMER_LEVEL = "crm_customer_level"; // CRM 客户等级 12 String CRM_CUSTOMER_LEVEL = "crm_customer_level"; // CRM 客户等级
13 String CRM_CUSTOMER_SOURCE = "crm_customer_source"; // CRM 客户来源 13 String CRM_CUSTOMER_SOURCE = "crm_customer_source"; // CRM 客户来源
14 - String CRM_RECEIVABLE_CHECK_STATUS = "crm_receivable_check_status"; // CRM 审批状态 14 + String CRM_AUDIT_STATUS = "crm_audit_status"; // CRM 审批状态
15 15
16 } 16 }
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
@@ -20,8 +20,6 @@ public interface ErrorCodeConstants { @@ -20,8 +20,6 @@ public interface ErrorCodeConstants {
20 20
21 // TODO @lilleo:商机状态、商机类型,都单独错误码段 21 // TODO @lilleo:商机状态、商机类型,都单独错误码段
22 22
23 - ErrorCode BUSINESS_STATUS_TYPE_NOT_EXISTS = new ErrorCode(1_020_002_001, "商机状态类型不存在");  
24 - ErrorCode BUSINESS_STATUS_NOT_EXISTS = new ErrorCode(1_020_002_002, "商机状态不存在");  
25 23
26 // ========== 联系人管理 1-020-003-000 ========== 24 // ========== 联系人管理 1-020-003-000 ==========
27 ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); 25 ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在");
@@ -34,18 +32,22 @@ public interface ErrorCodeConstants { @@ -34,18 +32,22 @@ public interface ErrorCodeConstants {
34 32
35 // ========== 客户管理 1_020_006_000 ========== 33 // ========== 客户管理 1_020_006_000 ==========
36 ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_006_000, "客户不存在"); 34 ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_006_000, "客户不存在");
37 - ErrorCode CUSTOMER_OWNER_EXISTS = new ErrorCode(1_020_006_001, "客户已存在所属负责人");  
38 - ErrorCode CUSTOMER_LOCKED = new ErrorCode(1_020_006_002, "客户状态已锁定"); 35 + ErrorCode CUSTOMER_OWNER_EXISTS = new ErrorCode(1_020_006_001, "客户【{}】已存在所属负责人");
  36 + ErrorCode CUSTOMER_LOCKED = new ErrorCode(1_020_006_002, "客户【{}】状态已锁定");
39 ErrorCode CUSTOMER_ALREADY_DEAL = new ErrorCode(1_020_006_003, "客户已交易"); 37 ErrorCode CUSTOMER_ALREADY_DEAL = new ErrorCode(1_020_006_003, "客户已交易");
40 - // TODO @wanwan:这 2 个单独配置段噢  
41 - ErrorCode CUSTOMER_POOL_CONFIG_ERROR = new ErrorCode(1_020_006_001, "客户公海规则设置不正确");  
42 - ErrorCode CUSTOMER_LIMIT_CONFIG_NOT_EXISTS = new ErrorCode(1_020_006_002, "客户限制配置不存在"); 38 + ErrorCode CUSTOMER_IN_POOL = new ErrorCode(1_020_006_004, "客户【{}】放入公海失败,原因:已经是公海客户");
  39 + ErrorCode CUSTOMER_LOCKED_PUT_POOL_FAIL = new ErrorCode(1_020_006_005, "客户【{}】放入公海失败,原因:客户已锁定");
  40 + ErrorCode CUSTOMER_UPDATE_OWNER_USER_FAIL = new ErrorCode(1_020_006_006, "更新客户【{}】负责人失败, 原因:系统异常");
43 41
44 // ========== 权限管理 1_020_007_000 ========== 42 // ========== 权限管理 1_020_007_000 ==========
45 ErrorCode CRM_PERMISSION_NOT_EXISTS = new ErrorCode(1_020_007_000, "数据权限不存在"); 43 ErrorCode CRM_PERMISSION_NOT_EXISTS = new ErrorCode(1_020_007_000, "数据权限不存在");
46 ErrorCode CRM_PERMISSION_DENIED = new ErrorCode(1_020_007_001, "{}操作失败,原因:没有权限"); 44 ErrorCode CRM_PERMISSION_DENIED = new ErrorCode(1_020_007_001, "{}操作失败,原因:没有权限");
47 ErrorCode CRM_PERMISSION_MODEL_NOT_EXISTS = new ErrorCode(1_020_007_002, "{}不存在"); 45 ErrorCode CRM_PERMISSION_MODEL_NOT_EXISTS = new ErrorCode(1_020_007_002, "{}不存在");
48 ErrorCode CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS = new ErrorCode(1_020_007_003, "{}操作失败,原因:转移对象已经是该负责人"); 46 ErrorCode CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS = new ErrorCode(1_020_007_003, "{}操作失败,原因:转移对象已经是该负责人");
  47 + ErrorCode CRM_PERMISSION_DELETE_FAIL = new ErrorCode(1_020_007_004, "删除数据权限失败,原因:批量删除权限的时候,只能属于同一个 bizId 下");
  48 + ErrorCode CRM_PERMISSION_DELETE_FAIL_EXIST_OWNER = new ErrorCode(1_020_007_005, "删除数据权限失败,原因:存在负责人");
  49 + ErrorCode CRM_PERMISSION_DELETE_DENIED = new ErrorCode(1_020_007_006, "删除数据权限失败,原因:没有权限");
  50 + ErrorCode CRM_PERMISSION_DELETE_SELF_PERMISSION_FAIL_EXIST_OWNER = new ErrorCode(1_020_007_007, "删除数据权限失败,原因:不能删除负责人");
49 51
50 // ========== 产品 1_020_008_000 ========== 52 // ========== 产品 1_020_008_000 ==========
51 ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_020_008_000, "产品不存在"); 53 ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_020_008_000, "产品不存在");
@@ -54,4 +56,14 @@ public interface ErrorCodeConstants { @@ -54,4 +56,14 @@ public interface ErrorCodeConstants {
54 // ========== 产品分类 1_020_009_000 ========== 56 // ========== 产品分类 1_020_009_000 ==========
55 ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_020_009_000, "产品分类不存在"); 57 ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_020_009_000, "产品分类不存在");
56 58
  59 + // ========== 商机状态类型 1_020_010_000 ==========
  60 + ErrorCode BUSINESS_STATUS_TYPE_NOT_EXISTS = new ErrorCode(1_020_010_000, "商机状态类型不存在");
  61 + ErrorCode BUSINESS_STATUS_TYPE_NAME_EXISTS = new ErrorCode(1_020_010_001, "商机状态类型名称已存在");
  62 +
  63 + // ========== 商机状态 1_020_011_000 ==========
  64 + ErrorCode BUSINESS_STATUS_NOT_EXISTS = new ErrorCode(1_020_011_000, "商机状态不存在");
  65 +
  66 + // ========== 客户公海规则设置 1_020_011_000 ==========
  67 + ErrorCode CUSTOMER_LIMIT_CONFIG_NOT_EXISTS = new ErrorCode(1_020_012_000, "客户限制配置不存在");
  68 +
57 } 69 }
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ReturnTypeEnum.java deleted
1 -package cn.iocoder.yudao.module.crm.enums;  
2 -  
3 -// TODO @liuhongfeng:这个的作用是?  
4 -/**  
5 - * @author 赤焰  
6 - */  
7 -public enum ReturnTypeEnum {  
8 -}  
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmAuditStatusEnum.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.enums.common;
  2 +
  3 +import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
  4 +import lombok.Getter;
  5 +import lombok.RequiredArgsConstructor;
  6 +
  7 +import java.util.Arrays;
  8 +
  9 +/**
  10 + * CRM 的审批状态
  11 + *
  12 + * @author 赤焰
  13 + */
  14 +@RequiredArgsConstructor
  15 +@Getter
  16 +public enum CrmAuditStatusEnum implements IntArrayValuable {
  17 +
  18 + DRAFT(0, "未提交"),
  19 + PROCESS(10, "审批中"),
  20 + APPROVE(20, "审核通过"),
  21 + REJECT(30, "审核不通过"),
  22 + CANCEL(40, "已取消");
  23 +
  24 + private final Integer status;
  25 + private final String name;
  26 +
  27 + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmAuditStatusEnum::getStatus).toArray();
  28 +
  29 + @Override
  30 + public int[] array() {
  31 + return ARRAYS;
  32 + }
  33 +
  34 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/CrmBizTypeEnum.java renamed to yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java
1 -package cn.iocoder.yudao.module.crm.framework.enums; 1 +package cn.iocoder.yudao.module.crm.enums.common;
2 2
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 import cn.hutool.core.util.ObjUtil; 4 import cn.hutool.core.util.ObjUtil;
@@ -9,7 +9,7 @@ import lombok.RequiredArgsConstructor; @@ -9,7 +9,7 @@ import lombok.RequiredArgsConstructor;
9 import java.util.Arrays; 9 import java.util.Arrays;
10 10
11 /** 11 /**
12 - * Crm 类型枚举 12 + * CRM 业务类型枚举
13 * 13 *
14 * @author HUIHUI 14 * @author HUIHUI
15 */ 15 */
@@ -17,15 +17,14 @@ import java.util.Arrays; @@ -17,15 +17,14 @@ import java.util.Arrays;
17 @Getter 17 @Getter
18 public enum CrmBizTypeEnum implements IntArrayValuable { 18 public enum CrmBizTypeEnum implements IntArrayValuable {
19 19
20 - // TODO @puhui999:如果类似 CrmBizPermission 的 bizType 需要为空,可以设置它是数组,参考 Telephone 的 payload  
21 - CRM_PERMISSION(0, "团队"), // CrmPermissionController 中使用  
22 CRM_LEADS(1, "线索"), 20 CRM_LEADS(1, "线索"),
23 CRM_CUSTOMER(2, "客户"), 21 CRM_CUSTOMER(2, "客户"),
24 - CRM_CONTACTS(3, "联系人"),  
25 - CRM_BUSINESS(5, "商机"),  
26 - CRM_CONTRACT(6, "合同"); 22 + CRM_CONTACT(3, "联系人"),
  23 + CRM_BUSINESS(4, "商机"),
  24 + CRM_CONTRACT(5, "合同");
27 25
28 public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBizTypeEnum::getType).toArray(); 26 public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBizTypeEnum::getType).toArray();
  27 +
29 /** 28 /**
30 * 类型 29 * 类型
31 */ 30 */
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerSceneEnum.java renamed to yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmSceneEnum.java
1 -package cn.iocoder.yudao.module.crm.enums.customer; 1 +package cn.iocoder.yudao.module.crm.enums.common;
2 2
3 import cn.hutool.core.util.ObjUtil; 3 import cn.hutool.core.util.ObjUtil;
4 import cn.iocoder.yudao.framework.common.core.IntArrayValuable; 4 import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
@@ -7,20 +7,19 @@ import lombok.Getter; @@ -7,20 +7,19 @@ import lombok.Getter;
7 7
8 import java.util.Arrays; 8 import java.util.Arrays;
9 9
10 -// TODO @puhui999:这个应该是 crm 全局的,不仅仅属于 customer 客户哈;  
11 /** 10 /**
12 - * CRM 客户等级 11 + * CRM 列表检索场景
13 * 12 *
14 - * @author Wanwan 13 + * @author HUIHUI
15 */ 14 */
16 @Getter 15 @Getter
17 @AllArgsConstructor 16 @AllArgsConstructor
18 -public enum CrmCustomerSceneEnum implements IntArrayValuable { 17 +public enum CrmSceneEnum implements IntArrayValuable {
19 18
20 - OWNER(1, "我负责的客户"),  
21 - FOLLOW(2, "我关注的客户"); 19 + OWNER(1, "我负责的"),
  20 + FOLLOW(2, "我关注的");
22 21
23 - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerSceneEnum::getType).toArray(); 22 + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneEnum::getType).toArray();
24 23
25 /** 24 /**
26 * 场景类型 25 * 场景类型
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLimitConfigTypeEnum.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.enums.customer;
  2 +
  3 +import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
  4 +import lombok.AllArgsConstructor;
  5 +import lombok.Getter;
  6 +
  7 +import java.util.Arrays;
  8 +
  9 +/**
  10 + * CRM 客户限制配置规则类型
  11 + *
  12 + * @author Wanwan
  13 + */
  14 +@Getter
  15 +@AllArgsConstructor
  16 +public enum CrmCustomerLimitConfigTypeEnum implements IntArrayValuable {
  17 +
  18 + /**
  19 + * 拥有客户数限制
  20 + */
  21 + CUSTOMER_QUANTITY_LIMIT(1, "拥有客户数限制"),
  22 + /**
  23 + * 锁定客户数限制
  24 + */
  25 + CUSTOMER_LOCK_LIMIT(2, "锁定客户数限制"),
  26 + ;
  27 +
  28 + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerLimitConfigTypeEnum::getCode).toArray();
  29 +
  30 + /**
  31 + * 状态
  32 + */
  33 + private final Integer code;
  34 + /**
  35 + * 状态名
  36 + */
  37 + private final String name;
  38 +
  39 + @Override
  40 + public int[] array() {
  41 + return ARRAYS;
  42 + }
  43 +
  44 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/CrmPermissionLevelEnum.java renamed to yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/permission/CrmPermissionLevelEnum.java
1 -package cn.iocoder.yudao.module.crm.framework.enums; 1 +package cn.iocoder.yudao.module.crm.enums.permission;
2 2
3 import cn.hutool.core.util.ObjUtil; 3 import cn.hutool.core.util.ObjUtil;
4 import cn.iocoder.yudao.framework.common.core.IntArrayValuable; 4 import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
@@ -8,7 +8,7 @@ import lombok.Getter; @@ -8,7 +8,7 @@ import lombok.Getter;
8 import java.util.Arrays; 8 import java.util.Arrays;
9 9
10 /** 10 /**
11 - * Crm 数据权限级别枚举 11 + * CRM 数据权限级别枚举
12 * 12 *
13 * @author HUIHUI 13 * @author HUIHUI
14 */ 14 */
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java
1 package cn.iocoder.yudao.module.crm.controller.admin.business; 1 package cn.iocoder.yudao.module.crm.controller.admin.business;
2 2
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.lang.Assert;
3 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 5 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 import cn.iocoder.yudao.framework.common.pojo.PageResult; 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; 7 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
6 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; 8 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
7 -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; 9 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
  10 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
  11 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
  12 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
8 import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; 13 import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
9 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; 14 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
10 -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; 15 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
  16 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
  17 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
11 import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; 18 import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
  19 +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService;
  20 +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusTypeService;
  21 +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
12 import io.swagger.v3.oas.annotations.Operation; 22 import io.swagger.v3.oas.annotations.Operation;
13 import io.swagger.v3.oas.annotations.Parameter; 23 import io.swagger.v3.oas.annotations.Parameter;
14 import io.swagger.v3.oas.annotations.tags.Tag; 24 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -21,6 +31,9 @@ import javax.servlet.http.HttpServletResponse; @@ -21,6 +31,9 @@ import javax.servlet.http.HttpServletResponse;
21 import javax.validation.Valid; 31 import javax.validation.Valid;
22 import java.io.IOException; 32 import java.io.IOException;
23 import java.util.List; 33 import java.util.List;
  34 +import java.util.Objects;
  35 +import java.util.Set;
  36 +import java.util.stream.Collectors;
24 37
25 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 38 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
26 import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; 39 import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@@ -35,6 +48,15 @@ public class CrmBusinessController { @@ -35,6 +48,15 @@ public class CrmBusinessController {
35 @Resource 48 @Resource
36 private CrmBusinessService businessService; 49 private CrmBusinessService businessService;
37 50
  51 + @Resource
  52 + private CrmCustomerService customerService;
  53 +
  54 + @Resource
  55 + private CrmBusinessStatusTypeService businessStatusTypeService;
  56 +
  57 + @Resource
  58 + private CrmBusinessStatusService businessStatusService;
  59 +
38 @PostMapping("/create") 60 @PostMapping("/create")
39 @Operation(summary = "创建商机") 61 @Operation(summary = "创建商机")
40 @PreAuthorize("@ss.hasPermission('crm:business:create')") 62 @PreAuthorize("@ss.hasPermission('crm:business:create')")
@@ -73,27 +95,72 @@ public class CrmBusinessController { @@ -73,27 +95,72 @@ public class CrmBusinessController {
73 @PreAuthorize("@ss.hasPermission('crm:business:query')") 95 @PreAuthorize("@ss.hasPermission('crm:business:query')")
74 public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) { 96 public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) {
75 PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(pageVO, getLoginUserId()); 97 PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(pageVO, getLoginUserId());
76 - return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult)); 98 + if (CollUtil.isEmpty(pageResult.getList())) {
  99 + return success(PageResult.empty(pageResult.getTotal()));
  100 + }
  101 + // 处理客户名称回显
  102 + // TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
  103 + Set<Long> customerIds = pageResult.getList().stream()
  104 + .map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
  105 + List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds);
  106 + // 处理商机状态类型名称回显
  107 + Set<Long> statusTypeIds = pageResult.getList().stream()
  108 + .map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet());
  109 + CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO();
  110 + queryStatusTypeVO.setIdList(statusTypeIds);
  111 + List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO);
  112 + // 处理商机状态名称回显
  113 + Set<Long> statusIds = pageResult.getList().stream()
  114 + .map(CrmBusinessDO::getStatusId).filter(Objects::nonNull).collect(Collectors.toSet());
  115 + CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
  116 + queryVO.setIdList(statusIds);
  117 + List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
  118 + return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList));
  119 + }
  120 +
  121 + @GetMapping("/page-by-customer")
  122 + @Operation(summary = "获得商机分页,基于指定客户")
  123 + public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmContractPageReqVO pageReqVO) {
  124 + Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空");
  125 + PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomer(pageReqVO);
  126 + // 处理客户名称回显
  127 + // TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
  128 + Set<Long> customerIds = pageResult.getList().stream()
  129 + .map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
  130 + List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds);
  131 + // 处理商机状态类型名称回显
  132 + Set<Long> statusTypeIds = pageResult.getList().stream()
  133 + .map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet());
  134 + CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO();
  135 + queryStatusTypeVO.setIdList(statusTypeIds);
  136 + List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO);
  137 + // 处理商机状态名称回显
  138 + Set<Long> statusIds = pageResult.getList().stream()
  139 + .map(CrmBusinessDO::getStatusId).filter(Objects::nonNull).collect(Collectors.toSet());
  140 + CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
  141 + queryVO.setIdList(statusIds);
  142 + List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
  143 + return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList));
77 } 144 }
78 145
79 @GetMapping("/pool-page") 146 @GetMapping("/pool-page")
80 @Operation(summary = "获得商机公海分页") 147 @Operation(summary = "获得商机公海分页")
81 @PreAuthorize("@ss.hasPermission('crm:business:query')") 148 @PreAuthorize("@ss.hasPermission('crm:business:query')")
82 public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPoolPage(@Valid CrmBusinessPageReqVO pageVO) { 149 public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPoolPage(@Valid CrmBusinessPageReqVO pageVO) {
83 - PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(pageVO, CrmPermissionDO.POOL_USER_ID);  
84 - return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult)); 150 + // TODO puhui999: 等数据权限完善后再实现
  151 + return null;
85 } 152 }
86 153
87 @GetMapping("/export-excel") 154 @GetMapping("/export-excel")
88 @Operation(summary = "导出商机 Excel") 155 @Operation(summary = "导出商机 Excel")
89 @PreAuthorize("@ss.hasPermission('crm:business:export')") 156 @PreAuthorize("@ss.hasPermission('crm:business:export')")
90 @OperateLog(type = EXPORT) 157 @OperateLog(type = EXPORT)
91 - public void exportBusinessExcel(@Valid CrmBusinessExportReqVO exportReqVO, 158 + public void exportBusinessExcel(@Valid CrmBusinessPageReqVO exportReqVO,
92 HttpServletResponse response) throws IOException { 159 HttpServletResponse response) throws IOException {
93 - List<CrmBusinessDO> list = businessService.getBusinessList(exportReqVO); 160 + PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(exportReqVO, getLoginUserId());
94 // 导出 Excel 161 // 导出 Excel
95 - List<CrmBusinessExcelVO> datas = CrmBusinessConvert.INSTANCE.convertList02(list);  
96 - ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class, datas); 162 + ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class,
  163 + CrmBusinessConvert.INSTANCE.convertList02(pageResult.getList()));
97 } 164 }
98 165
99 @PutMapping("/transfer") 166 @PutMapping("/transfer")
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/CrmBusinessStatusTypeController.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusTypeController.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype; 1 +package cn.iocoder.yudao.module.crm.controller.admin.business;
2 2
3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; 3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 4 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  7 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
6 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; 8 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
7 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; 9 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
8 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.*; 10 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
  11 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusRespVO;
  12 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO;
  13 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
  14 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeRespVO;
  15 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO;
  16 +import cn.iocoder.yudao.module.crm.convert.businessstatus.CrmBusinessStatusConvert;
9 import cn.iocoder.yudao.module.crm.convert.businessstatustype.CrmBusinessStatusTypeConvert; 17 import cn.iocoder.yudao.module.crm.convert.businessstatustype.CrmBusinessStatusTypeConvert;
10 -import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO;  
11 -import cn.iocoder.yudao.module.crm.service.businessstatustype.CrmBusinessStatusTypeService; 18 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
  19 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
  20 +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService;
  21 +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusTypeService;
  22 +import cn.iocoder.yudao.module.system.api.dept.DeptApi;
  23 +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
12 import io.swagger.v3.oas.annotations.Operation; 24 import io.swagger.v3.oas.annotations.Operation;
13 import io.swagger.v3.oas.annotations.Parameter; 25 import io.swagger.v3.oas.annotations.Parameter;
14 import io.swagger.v3.oas.annotations.tags.Tag; 26 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -22,11 +34,13 @@ import javax.validation.Valid; @@ -22,11 +34,13 @@ import javax.validation.Valid;
22 import java.io.IOException; 34 import java.io.IOException;
23 import java.util.Collection; 35 import java.util.Collection;
24 import java.util.List; 36 import java.util.List;
  37 +import java.util.Objects;
  38 +import java.util.Set;
  39 +import java.util.stream.Collectors;
25 40
26 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 41 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
27 import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; 42 import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
28 43
29 -// TODO @lilleo:这个模块,可以挪到 business 下;这样我打开 business 包下,就知道,噢~原来里面有 business 商机、有 type 状态类型、status 具体状态;  
30 @Tag(name = "管理后台 - 商机状态类型") 44 @Tag(name = "管理后台 - 商机状态类型")
31 @RestController 45 @RestController
32 @RequestMapping("/crm/business-status-type") 46 @RequestMapping("/crm/business-status-type")
@@ -36,17 +50,23 @@ public class CrmBusinessStatusTypeController { @@ -36,17 +50,23 @@ public class CrmBusinessStatusTypeController {
36 @Resource 50 @Resource
37 private CrmBusinessStatusTypeService businessStatusTypeService; 51 private CrmBusinessStatusTypeService businessStatusTypeService;
38 52
  53 + @Resource
  54 + private CrmBusinessStatusService businessStatusService;
  55 +
  56 + @Resource
  57 + private DeptApi deptApi;
  58 +
39 @PostMapping("/create") 59 @PostMapping("/create")
40 @Operation(summary = "创建商机状态类型") 60 @Operation(summary = "创建商机状态类型")
41 @PreAuthorize("@ss.hasPermission('crm:business-status-type:create')") 61 @PreAuthorize("@ss.hasPermission('crm:business-status-type:create')")
42 - public CommonResult<Long> createBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeCreateReqVO createReqVO) { 62 + public CommonResult<Long> createBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeSaveReqVO createReqVO) {
43 return success(businessStatusTypeService.createBusinessStatusType(createReqVO)); 63 return success(businessStatusTypeService.createBusinessStatusType(createReqVO));
44 } 64 }
45 65
46 @PutMapping("/update") 66 @PutMapping("/update")
47 @Operation(summary = "更新商机状态类型") 67 @Operation(summary = "更新商机状态类型")
48 @PreAuthorize("@ss.hasPermission('crm:business-status-type:update')") 68 @PreAuthorize("@ss.hasPermission('crm:business-status-type:update')")
49 - public CommonResult<Boolean> updateBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeUpdateReqVO updateReqVO) { 69 + public CommonResult<Boolean> updateBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeSaveReqVO updateReqVO) {
50 businessStatusTypeService.updateBusinessStatusType(updateReqVO); 70 businessStatusTypeService.updateBusinessStatusType(updateReqVO);
51 return success(true); 71 return success(true);
52 } 72 }
@@ -66,45 +86,62 @@ public class CrmBusinessStatusTypeController { @@ -66,45 +86,62 @@ public class CrmBusinessStatusTypeController {
66 @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") 86 @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
67 public CommonResult<CrmBusinessStatusTypeRespVO> getBusinessStatusType(@RequestParam("id") Long id) { 87 public CommonResult<CrmBusinessStatusTypeRespVO> getBusinessStatusType(@RequestParam("id") Long id) {
68 CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeService.getBusinessStatusType(id); 88 CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeService.getBusinessStatusType(id);
69 - return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(businessStatusType));  
70 - }  
71 -  
72 - // TODO @lilleo:这个接口,暂时用不到,可以考虑先删除掉  
73 - @GetMapping("/list")  
74 - @Operation(summary = "获得商机状态类型列表")  
75 - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")  
76 - @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")  
77 - public CommonResult<List<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypeList(@RequestParam("ids") Collection<Long> ids) {  
78 - List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeList(ids);  
79 - return success(CrmBusinessStatusTypeConvert.INSTANCE.convertList(list)); 89 + // 处理状态回显
  90 + // TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
  91 + CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
  92 + queryVO.setTypeId(id);
  93 + List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
  94 + return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(businessStatusType, statusList));
80 } 95 }
81 96
82 @GetMapping("/page") 97 @GetMapping("/page")
83 @Operation(summary = "获得商机状态类型分页") 98 @Operation(summary = "获得商机状态类型分页")
84 @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") 99 @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
85 - public CommonResult<PageResult<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageVO) {  
86 - PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageVO);  
87 - return success(CrmBusinessStatusTypeConvert.INSTANCE.convertPage(pageResult)); 100 + public CommonResult<PageResult<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageReqVO) {
  101 + PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO);
  102 + // 处理部门回显
  103 + // TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
  104 + Set<Long> deptIds = pageResult.getList().stream()
  105 + .map(CrmBusinessStatusTypeDO::getDeptIds)
  106 + .filter(Objects::nonNull)
  107 + .flatMap(Collection::stream)
  108 + .collect(Collectors.toSet());
  109 + List<DeptRespDTO> deptList = deptApi.getDeptList(deptIds);
  110 + return success(CrmBusinessStatusTypeConvert.INSTANCE.convertPage(pageResult, deptList));
88 } 111 }
89 112
90 @GetMapping("/export-excel") 113 @GetMapping("/export-excel")
91 @Operation(summary = "导出商机状态类型 Excel") 114 @Operation(summary = "导出商机状态类型 Excel")
92 @PreAuthorize("@ss.hasPermission('crm:business-status-type:export')") 115 @PreAuthorize("@ss.hasPermission('crm:business-status-type:export')")
93 @OperateLog(type = EXPORT) 116 @OperateLog(type = EXPORT)
94 - public void exportBusinessStatusTypeExcel(@Valid CrmBusinessStatusTypeExportReqVO exportReqVO, 117 + public void exportBusinessStatusTypeExcel(@Valid CrmBusinessStatusTypePageReqVO pageReqVO,
95 HttpServletResponse response) throws IOException { 118 HttpServletResponse response) throws IOException {
96 - List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeList(exportReqVO); 119 + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
  120 + List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO).getList();
97 // 导出 Excel 121 // 导出 Excel
98 - List<CrmBusinessStatusTypeExcelVO> datas = CrmBusinessStatusTypeConvert.INSTANCE.convertList02(list);  
99 - ExcelUtils.write(response, "商机状态类型.xls", "数据", CrmBusinessStatusTypeExcelVO.class, datas); 122 + ExcelUtils.write(response, "商机状态类型.xls", "数据", CrmBusinessStatusTypeRespVO.class,
  123 + BeanUtils.toBean(list, CrmBusinessStatusTypeRespVO.class));
100 } 124 }
101 125
102 @GetMapping("/get-simple-list") 126 @GetMapping("/get-simple-list")
103 @Operation(summary = "获得商机状态类型列表") 127 @Operation(summary = "获得商机状态类型列表")
104 @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") 128 @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
105 public CommonResult<List<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypeList() { 129 public CommonResult<List<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypeList() {
106 - List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeListByStatus(CommonStatusEnum.ENABLE.getStatus());  
107 - return success(CrmBusinessStatusTypeConvert.INSTANCE.convertList(list)); 130 + CrmBusinessStatusTypeQueryVO queryVO = new CrmBusinessStatusTypeQueryVO();
  131 + queryVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
  132 + List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.selectList(queryVO);
  133 + return success(BeanUtils.toBean(list, CrmBusinessStatusTypeRespVO.class));
  134 + }
  135 +
  136 + // TODO @ljlleo 这个接口,是不是可以和 getBusinessStatusTypeList 合并成一个?
  137 + @GetMapping("/get-status-list")
  138 + @Operation(summary = "获得商机状态列表")
  139 + @PreAuthorize("@ss.hasPermission('crm:business-status:query')")
  140 + public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusListByTypeId(@RequestParam("typeId") Long typeId) {
  141 + CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
  142 + queryVO.setTypeId(typeId);
  143 + List<CrmBusinessStatusDO> list = businessStatusService.selectList(queryVO);
  144 + return success(CrmBusinessStatusConvert.INSTANCE.convertList(list));
108 } 145 }
109 146
110 } 147 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/package-info.java deleted
1 -/**  
2 - * 商机(销售机会)  
3 - */  
4 -package cn.iocoder.yudao.module.crm.controller.admin.business;  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExportReqVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.business.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import org.springframework.format.annotation.DateTimeFormat;  
6 -  
7 -import java.math.BigDecimal;  
8 -import java.time.LocalDateTime;  
9 -  
10 -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;  
11 -  
12 -@Schema(description = "管理后台 - 商机 Excel 导出 Request VO,参数和 CrmBusinessPageReqVO 是一致的")  
13 -@Data  
14 -public class CrmBusinessExportReqVO {  
15 -  
16 - @Schema(description = "商机名称", example = "李四")  
17 - private String name;  
18 -  
19 - @Schema(description = "商机状态类型编号", example = "25714")  
20 - private Long statusTypeId;  
21 -  
22 - @Schema(description = "商机状态编号", example = "30320")  
23 - private Long statusId;  
24 -  
25 - @Schema(description = "下次联系时间")  
26 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
27 - private LocalDateTime[] contactNextTime;  
28 -  
29 - @Schema(description = "客户编号", example = "10299")  
30 - private Long customerId;  
31 -  
32 - @Schema(description = "预计成交日期")  
33 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
34 - private LocalDateTime[] dealTime;  
35 -  
36 - @Schema(description = "商机金额", example = "12371")  
37 - private BigDecimal price;  
38 -  
39 - @Schema(description = "整单折扣")  
40 - private BigDecimal discountPercent;  
41 -  
42 - @Schema(description = "产品总金额", example = "12025")  
43 - private BigDecimal productPrice;  
44 -  
45 - @Schema(description = "备注", example = "随便")  
46 - private String remark;  
47 -  
48 - @Schema(description = "负责人的用户编号", example = "25562")  
49 - private Long ownerUserId;  
50 -  
51 - @Schema(description = "创建时间")  
52 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
53 - private LocalDateTime[] createTime;  
54 -  
55 - @Schema(description = "只读权限的用户编号数组")  
56 - private String roUserIds;  
57 -  
58 - @Schema(description = "读写权限的用户编号数组")  
59 - private String rwUserIds;  
60 -  
61 - @Schema(description = "1赢单2输单3无效", example = "1")  
62 - private Integer endStatus;  
63 -  
64 - @Schema(description = "结束时的备注", example = "你说的对")  
65 - private String endRemark;  
66 -  
67 - @Schema(description = "最后跟进时间")  
68 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
69 - private LocalDateTime[] contactLastTime;  
70 -  
71 - @Schema(description = "跟进状态", example = "1")  
72 - private Integer followUpStatus;  
73 -  
74 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessBaseVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessBaseVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.business.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 4 import lombok.Data;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessCreateReqVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.business.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 4 import lombok.Data;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExcelVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessExcelVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.business.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
2 2
3 import com.alibaba.excel.annotation.ExcelProperty; 3 import com.alibaba.excel.annotation.ExcelProperty;
4 import lombok.Data; 4 import lombok.Data;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessPageReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessPageReqVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.business.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageParam; 3 import cn.iocoder.yudao.framework.common.pojo.PageParam;
4 import io.swagger.v3.oas.annotations.media.Schema; 4 import io.swagger.v3.oas.annotations.media.Schema;
@@ -15,4 +15,7 @@ public class CrmBusinessPageReqVO extends PageParam { @@ -15,4 +15,7 @@ public class CrmBusinessPageReqVO extends PageParam {
15 @Schema(description = "商机名称", example = "李四") 15 @Schema(description = "商机名称", example = "李四")
16 private String name; 16 private String name;
17 17
  18 + @Schema(description = "客户编号", example = "10795")
  19 + private Long customerId;
  20 +
18 } 21 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessRespVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessRespVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.business.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.*; 4 import lombok.*;
@@ -16,4 +16,13 @@ public class CrmBusinessRespVO extends CrmBusinessBaseVO { @@ -16,4 +16,13 @@ public class CrmBusinessRespVO extends CrmBusinessBaseVO {
16 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) 16 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
17 private LocalDateTime createTime; 17 private LocalDateTime createTime;
18 18
  19 + @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
  20 + private String customerName;
  21 +
  22 + @Schema(description = "状态类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "进行中")
  23 + private String statusTypeName;
  24 +
  25 + @Schema(description = "状态名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "跟进中")
  26 + private String statusName;
  27 +
19 } 28 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessTransferReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessTransferReqVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.business.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
2 2
3 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 3 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
4 import io.swagger.v3.oas.annotations.media.Schema; 4 import io.swagger.v3.oas.annotations.media.Schema;
5 import lombok.Data; 5 import lombok.Data;
6 6
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessUpdateReqVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.business.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
2 2
  3 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessBaseVO;
3 import io.swagger.v3.oas.annotations.media.Schema; 4 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 5 import lombok.Data;
5 import lombok.EqualsAndHashCode; 6 import lombok.EqualsAndHashCode;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusPageReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusPageReqVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageParam; 3 import cn.iocoder.yudao.framework.common.pojo.PageParam;
4 import io.swagger.v3.oas.annotations.media.Schema; 4 import io.swagger.v3.oas.annotations.media.Schema;
@@ -12,7 +12,4 @@ import lombok.ToString; @@ -12,7 +12,4 @@ import lombok.ToString;
12 @ToString(callSuper = true) 12 @ToString(callSuper = true)
13 public class CrmBusinessStatusPageReqVO extends PageParam { 13 public class CrmBusinessStatusPageReqVO extends PageParam {
14 14
15 - @Schema(description = "状态类型编号", example = "22882")  
16 - private Long typeId;  
17 -  
18 } 15 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusQueryVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +import lombok.ToString;
  6 +
  7 +import java.util.Collection;
  8 +
  9 +@Schema(description = "管理后台 - 商机状态 Query VO")
  10 +@Data
  11 +@ToString(callSuper = true)
  12 +public class CrmBusinessStatusQueryVO {
  13 +
  14 + @Schema(description = "主键集合")
  15 + private Collection<Long> idList;
  16 +
  17 + @Schema(description = "状态类型编号")
  18 + private Long typeId;
  19 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExcelVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusRespVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status;
2 2
  3 +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
3 import com.alibaba.excel.annotation.ExcelProperty; 4 import com.alibaba.excel.annotation.ExcelProperty;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 6 import lombok.Data;
5 7
6 -// TODO @lilleo:这个暂时不需要;嘿嘿~不是每个模块都需要导出哈  
7 -/**  
8 - * 商机状态 Excel VO  
9 - *  
10 - * @author ljlleo  
11 - */ 8 +@Schema(description = "管理后台 - 商机状态 Response VO")
12 @Data 9 @Data
13 -public class CrmBusinessStatusExcelVO { 10 +@ExcelIgnoreUnannotated
  11 +public class CrmBusinessStatusRespVO {
14 12
  13 + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "23899")
15 @ExcelProperty("主键") 14 @ExcelProperty("主键")
16 private Long id; 15 private Long id;
17 16
  17 + @Schema(description = "状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7139")
18 @ExcelProperty("状态类型编号") 18 @ExcelProperty("状态类型编号")
19 private Long typeId; 19 private Long typeId;
20 20
  21 + @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
21 @ExcelProperty("状态名") 22 @ExcelProperty("状态名")
22 private String name; 23 private String name;
23 24
  25 + @Schema(description = "赢单率")
24 @ExcelProperty("赢单率") 26 @ExcelProperty("赢单率")
25 private String percent; 27 private String percent;
26 28
  29 + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
27 @ExcelProperty("排序") 30 @ExcelProperty("排序")
28 private Integer sort; 31 private Integer sort;
29 32
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusBaseVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusSaveReqVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status;
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 4 import lombok.Data;
5 5
  6 +import javax.validation.constraints.NotEmpty;
6 import javax.validation.constraints.NotNull; 7 import javax.validation.constraints.NotNull;
7 8
8 -/**  
9 - * 商机状态 Base VO,提供给添加、修改、详细的子 VO 使用  
10 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成  
11 - */ 9 +@Schema(description = "管理后台 - 商机状态新增/修改 Request VO")
12 @Data 10 @Data
13 -public class CrmBusinessStatusBaseVO { 11 +public class CrmBusinessStatusSaveReqVO {
14 12
15 - // TODO @lilleo:example 要写下 13 + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "23899")
  14 + private Long id;
16 15
17 - @Schema(description = "状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22882") 16 + @Schema(description = "状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7139")
18 @NotNull(message = "状态类型编号不能为空") 17 @NotNull(message = "状态类型编号不能为空")
19 private Long typeId; 18 private Long typeId;
20 19
21 - @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")  
22 - @NotNull(message = "状态名不能为空") 20 + @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
  21 + @NotEmpty(message = "状态名不能为空")
23 private String name; 22 private String name;
24 23
25 // TODO @lilleo:percent 应该是 Integer; 24 // TODO @lilleo:percent 应该是 Integer;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypePageReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypePageReqVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageParam; 3 import cn.iocoder.yudao.framework.common.pojo.PageParam;
4 import io.swagger.v3.oas.annotations.media.Schema; 4 import io.swagger.v3.oas.annotations.media.Schema;
@@ -12,10 +12,4 @@ import lombok.ToString; @@ -12,10 +12,4 @@ import lombok.ToString;
12 @ToString(callSuper = true) 12 @ToString(callSuper = true)
13 public class CrmBusinessStatusTypePageReqVO extends PageParam { 13 public class CrmBusinessStatusTypePageReqVO extends PageParam {
14 14
15 - @Schema(description = "状态类型名", example = "芋艿")  
16 - private String name;  
17 -  
18 - @Schema(description = "开启状态", example = "1")  
19 - private Boolean status;  
20 -  
21 } 15 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeQueryVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +import lombok.ToString;
  6 +
  7 +import java.util.Collection;
  8 +
  9 +@Schema(description = "管理后台 - 商机状态类型 Query VO")
  10 +@Data
  11 +@ToString(callSuper = true)
  12 +public class CrmBusinessStatusTypeQueryVO {
  13 +
  14 + @Schema(description = "主键集合")
  15 + private Collection<Long> idList;
  16 +
  17 + @Schema(description = "状态")
  18 + private Integer status;
  19 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type;
  2 +
  3 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
  4 +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
  5 +import com.alibaba.excel.annotation.ExcelProperty;
  6 +import io.swagger.v3.oas.annotations.media.Schema;
  7 +import lombok.Data;
  8 +
  9 +import java.time.LocalDateTime;
  10 +import java.util.List;
  11 +
  12 +@Schema(description = "管理后台 - 商机状态类型 Response VO")
  13 +@Data
  14 +@ExcelIgnoreUnannotated
  15 +public class CrmBusinessStatusTypeRespVO {
  16 +
  17 + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934")
  18 + @ExcelProperty("主键")
  19 + private Long id;
  20 +
  21 + @Schema(description = "状态类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
  22 + @ExcelProperty("状态类型名")
  23 + private String name;
  24 +
  25 + @Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED)
  26 + @ExcelProperty("使用的部门编号")
  27 + private List<Long> deptIds;
  28 + @Schema(description = "使用的部门名称", requiredMode = Schema.RequiredMode.REQUIRED)
  29 + @ExcelProperty("使用的部门名称")
  30 + private List<String> deptNames;
  31 +
  32 + @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED)
  33 + @ExcelProperty("创建人")
  34 + private String creator;
  35 +
  36 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  37 + @ExcelProperty("创建时间")
  38 + private LocalDateTime createTime;
  39 +
  40 + // TODO @ljlleo 字段后缀改成 statuses,保持和 deptIds 风格一致;CrmBusinessStatusDO 改成 VO 哈;一般不使用 do 直接返回
  41 + @Schema(description = "状态集合", requiredMode = Schema.RequiredMode.REQUIRED)
  42 + private List<CrmBusinessStatusDO> statusList;
  43 +
  44 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeSaveReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type;
  2 +
  3 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO;
  4 +import com.google.common.collect.Lists;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import lombok.Data;
  7 +
  8 +import javax.validation.constraints.NotEmpty;
  9 +import java.util.List;
  10 +
  11 +@Schema(description = "管理后台 - 商机状态类型新增/修改 Request VO")
  12 +@Data
  13 +public class CrmBusinessStatusTypeSaveReqVO {
  14 +
  15 + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934")
  16 + private Long id;
  17 +
  18 + @Schema(description = "状态类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
  19 + @NotEmpty(message = "状态类型名不能为空")
  20 + private String name;
  21 +
  22 + @Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED)
  23 + private List<Long> deptIds = Lists.newArrayList();
  24 +
  25 + // TODO @ljlleo VO 里面,我们不使用默认值哈。这里 Lists.newArrayList() 看看怎么去掉。上面 deptIds 也是类似噢
  26 + @Schema(description = "商机状态集合", requiredMode = Schema.RequiredMode.REQUIRED)
  27 + private List<CrmBusinessStatusSaveReqVO> statusList = Lists.newArrayList();
  28 +
  29 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/CrmBusinessStatusController.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatus;  
2 -  
3 -import cn.iocoder.yudao.framework.common.pojo.CommonResult;  
4 -import cn.iocoder.yudao.framework.common.pojo.PageResult;  
5 -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;  
6 -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.*;  
8 -import cn.iocoder.yudao.module.crm.convert.businessstatus.CrmBusinessStatusConvert;  
9 -import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO;  
10 -import cn.iocoder.yudao.module.crm.service.businessstatus.CrmBusinessStatusService;  
11 -import io.swagger.v3.oas.annotations.Operation;  
12 -import io.swagger.v3.oas.annotations.Parameter;  
13 -import io.swagger.v3.oas.annotations.tags.Tag;  
14 -import org.springframework.security.access.prepost.PreAuthorize;  
15 -import org.springframework.validation.annotation.Validated;  
16 -import org.springframework.web.bind.annotation.*;  
17 -  
18 -import javax.annotation.Resource;  
19 -import javax.servlet.http.HttpServletResponse;  
20 -import javax.validation.Valid;  
21 -import java.io.IOException;  
22 -import java.util.Collection;  
23 -import java.util.List;  
24 -  
25 -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;  
26 -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;  
27 -  
28 -// TODO @lilleo:这个模块,可以挪到 business 下;这样我打开 business 包下,就知道,噢~原来里面有 business 商机、有 type 状态类型、status 具体状态;  
29 -@Tag(name = "管理后台 - 商机状态")  
30 -@RestController  
31 -@RequestMapping("/crm/business-status")  
32 -@Validated  
33 -public class CrmBusinessStatusController {  
34 -  
35 - @Resource  
36 - private CrmBusinessStatusService businessStatusService;  
37 -  
38 - @PostMapping("/create")  
39 - @Operation(summary = "创建商机状态")  
40 - @PreAuthorize("@ss.hasPermission('crm:business-status:create')")  
41 - public CommonResult<Long> createBusinessStatus(@Valid @RequestBody CrmBusinessStatusCreateReqVO createReqVO) {  
42 - return success(businessStatusService.createBusinessStatus(createReqVO));  
43 - }  
44 -  
45 - @PutMapping("/update")  
46 - @Operation(summary = "更新商机状态")  
47 - @PreAuthorize("@ss.hasPermission('crm:business-status:update')")  
48 - public CommonResult<Boolean> updateBusinessStatus(@Valid @RequestBody CrmBusinessStatusUpdateReqVO updateReqVO) {  
49 - businessStatusService.updateBusinessStatus(updateReqVO);  
50 - return success(true);  
51 - }  
52 -  
53 - @DeleteMapping("/delete")  
54 - @Operation(summary = "删除商机状态")  
55 - @Parameter(name = "id", description = "编号", required = true)  
56 - @PreAuthorize("@ss.hasPermission('crm:business-status:delete')")  
57 - public CommonResult<Boolean> deleteBusinessStatus(@RequestParam("id") Long id) {  
58 - businessStatusService.deleteBusinessStatus(id);  
59 - return success(true);  
60 - }  
61 -  
62 - @GetMapping("/get")  
63 - @Operation(summary = "获得商机状态")  
64 - @Parameter(name = "id", description = "编号", required = true, example = "1024")  
65 - @PreAuthorize("@ss.hasPermission('crm:business-status:query')")  
66 - public CommonResult<CrmBusinessStatusRespVO> getBusinessStatus(@RequestParam("id") Long id) {  
67 - CrmBusinessStatusDO businessStatus = businessStatusService.getBusinessStatus(id);  
68 - return success(CrmBusinessStatusConvert.INSTANCE.convert(businessStatus));  
69 - }  
70 -  
71 - // TODO @lilleo:这个接口,暂时用不到,可以考虑先删除掉  
72 - @GetMapping("/list")  
73 - @Operation(summary = "获得商机状态列表")  
74 - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")  
75 - @PreAuthorize("@ss.hasPermission('crm:business-status:query')")  
76 - public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusList(@RequestParam("ids") Collection<Long> ids) {  
77 - List<CrmBusinessStatusDO> list = businessStatusService.getBusinessStatusList(ids);  
78 - return success(CrmBusinessStatusConvert.INSTANCE.convertList(list));  
79 - }  
80 -  
81 - @GetMapping("/page")  
82 - @Operation(summary = "获得商机状态分页")  
83 - @PreAuthorize("@ss.hasPermission('crm:business-status:query')")  
84 - public CommonResult<PageResult<CrmBusinessStatusRespVO>> getBusinessStatusPage(@Valid CrmBusinessStatusPageReqVO pageVO) {  
85 - PageResult<CrmBusinessStatusDO> pageResult = businessStatusService.getBusinessStatusPage(pageVO);  
86 - return success(CrmBusinessStatusConvert.INSTANCE.convertPage(pageResult));  
87 - }  
88 -  
89 - @GetMapping("/export-excel")  
90 - @Operation(summary = "导出商机状态 Excel")  
91 - @PreAuthorize("@ss.hasPermission('crm:business-status:export')")  
92 - @OperateLog(type = EXPORT)  
93 - public void exportBusinessStatusExcel(@Valid CrmBusinessStatusExportReqVO exportReqVO,  
94 - HttpServletResponse response) throws IOException {  
95 - List<CrmBusinessStatusDO> list = businessStatusService.getBusinessStatusList(exportReqVO);  
96 - // 导出 Excel  
97 - List<CrmBusinessStatusExcelVO> datas = CrmBusinessStatusConvert.INSTANCE.convertList02(list);  
98 - ExcelUtils.write(response, "商机状态.xls", "数据", CrmBusinessStatusExcelVO.class, datas);  
99 - }  
100 -  
101 - // TODO 芋艿:后续再看看  
102 - @GetMapping("/get-simple-list")  
103 - @Operation(summary = "获得商机状态列表")  
104 - @PreAuthorize("@ss.hasPermission('crm:business-status:query')")  
105 - public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusListByTypeId(@RequestParam("typeId") Integer typeId) {  
106 - List<CrmBusinessStatusDO> list = businessStatusService.getBusinessStatusListByTypeId(typeId);  
107 - return success(CrmBusinessStatusConvert.INSTANCE.convertList(list));  
108 - }  
109 -  
110 - // TODO 芋艿:后续再看看  
111 - @GetMapping("/get-all-list")  
112 - @Operation(summary = "获得商机状态列表")  
113 - @PreAuthorize("@ss.hasPermission('crm:business-status:query')")  
114 - public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusList() {  
115 - List<CrmBusinessStatusDO> list = businessStatusService.getBusinessStatusList();  
116 - return success(CrmBusinessStatusConvert.INSTANCE.convertList(list));  
117 - }  
118 -  
119 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusCreateReqVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;  
2 -  
3 -import lombok.*;  
4 -import java.util.*;  
5 -import io.swagger.v3.oas.annotations.media.Schema;  
6 -import javax.validation.constraints.*;  
7 -  
8 -@Schema(description = "管理后台 - 商机状态创建 Request VO")  
9 -@Data  
10 -@EqualsAndHashCode(callSuper = true)  
11 -@ToString(callSuper = true)  
12 -public class CrmBusinessStatusCreateReqVO extends CrmBusinessStatusBaseVO {  
13 -  
14 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExportReqVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -  
6 -// TODO @lilleo:这个暂时不需要;嘿嘿~不是每个模块都需要导出哈  
7 -@Schema(description = "管理后台 - 商机状态 Excel 导出 Request VO,参数和 CrmBusinessStatusPageReqVO 是一致的")  
8 -@Data  
9 -public class CrmBusinessStatusExportReqVO {  
10 -  
11 - @Schema(description = "状态类型编号", example = "22882")  
12 - private Long typeId;  
13 -  
14 - @Schema(description = "状态名", example = "李四")  
15 - private String name;  
16 -  
17 - @Schema(description = "赢单率")  
18 - private String percent;  
19 -  
20 - @Schema(description = "排序")  
21 - private Integer sort;  
22 -  
23 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusRespVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.*;  
5 -  
6 -@Schema(description = "管理后台 - 商机状态 Response VO")  
7 -@Data  
8 -@EqualsAndHashCode(callSuper = true)  
9 -@ToString(callSuper = true)  
10 -public class CrmBusinessStatusRespVO extends CrmBusinessStatusBaseVO {  
11 -  
12 - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6802")  
13 - private Long id;  
14 -  
15 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusUpdateReqVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString;  
7 -  
8 -import javax.validation.constraints.NotNull;  
9 -  
10 -@Schema(description = "管理后台 - 商机状态更新 Request VO")  
11 -@Data  
12 -@EqualsAndHashCode(callSuper = true)  
13 -@ToString(callSuper = true)  
14 -public class CrmBusinessStatusUpdateReqVO extends CrmBusinessStatusBaseVO {  
15 -  
16 - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6802")  
17 - @NotNull(message = "编号不能为空")  
18 - private Long id;  
19 -  
20 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeBaseVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -  
6 -import javax.validation.constraints.NotNull;  
7 -  
8 -/**  
9 - * 商机状态类型 Base VO,提供给添加、修改、详细的子 VO 使用  
10 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成  
11 - */  
12 -@Data  
13 -public class CrmBusinessStatusTypeBaseVO {  
14 -  
15 - @Schema(description = "状态类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")  
16 - @NotNull(message = "状态类型名不能为空")  
17 - private String name;  
18 -  
19 - @Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED)  
20 - @NotNull(message = "使用的部门编号不能为空")  
21 - private String deptIds;  
22 -  
23 - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")  
24 - @NotNull(message = "开启状态不能为空")  
25 - private Boolean status;  
26 -  
27 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeCreateReqVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString;  
7 -  
8 -// TODO 状态类型和状态添加,是在一个请求里,所以需要把 CrmBusinessStatusCreateReqVO 融合进来;  
9 -@Schema(description = "管理后台 - 商机状态类型创建 Request VO")  
10 -@Data  
11 -@EqualsAndHashCode(callSuper = true)  
12 -@ToString(callSuper = true)  
13 -public class CrmBusinessStatusTypeCreateReqVO extends CrmBusinessStatusTypeBaseVO {  
14 -  
15 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExcelVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;  
2 -  
3 -import com.alibaba.excel.annotation.ExcelProperty;  
4 -import lombok.Data;  
5 -  
6 -import java.time.LocalDateTime;  
7 -  
8 -// TODO @lilleo:这个暂时不需要;嘿嘿~不是每个模块都需要导出哈  
9 -/**  
10 - * 商机状态类型 Excel VO  
11 - *  
12 - * @author ljlleo  
13 - */  
14 -@Data  
15 -public class CrmBusinessStatusTypeExcelVO {  
16 -  
17 - @ExcelProperty("主键")  
18 - private Long id;  
19 -  
20 - @ExcelProperty("状态类型名")  
21 - private String name;  
22 -  
23 - @ExcelProperty("使用的部门编号")  
24 - private String deptIds;  
25 -  
26 - @ExcelProperty("开启状态")  
27 - private Boolean status;  
28 -  
29 - @ExcelProperty("创建时间")  
30 - private LocalDateTime createTime;  
31 -  
32 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExportReqVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import org.springframework.format.annotation.DateTimeFormat;  
6 -  
7 -import java.time.LocalDateTime;  
8 -  
9 -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;  
10 -  
11 -// TODO @lilleo:这个暂时不需要;嘿嘿~不是每个模块都需要导出哈  
12 -@Schema(description = "管理后台 - 商机状态类型 Excel 导出 Request VO,参数和 CrmBusinessStatusTypePageReqVO 是一致的")  
13 -@Data  
14 -public class CrmBusinessStatusTypeExportReqVO {  
15 -  
16 - @Schema(description = "状态类型名", example = "芋艿")  
17 - private String name;  
18 -  
19 - @Schema(description = "使用的部门编号")  
20 - private String deptIds;  
21 -  
22 - @Schema(description = "开启状态", example = "1")  
23 - private Boolean status;  
24 -  
25 - @Schema(description = "创建时间")  
26 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
27 - private LocalDateTime[] createTime;  
28 -  
29 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeRespVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.*;  
5 -import java.time.LocalDateTime;  
6 -  
7 -@Schema(description = "管理后台 - 商机状态类型 Response VO")  
8 -@Data  
9 -@EqualsAndHashCode(callSuper = true)  
10 -@ToString(callSuper = true)  
11 -public class CrmBusinessStatusTypeRespVO extends CrmBusinessStatusTypeBaseVO {  
12 -  
13 - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "24019")  
14 - private Long id;  
15 -  
16 - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)  
17 - private LocalDateTime createTime;  
18 -  
19 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeUpdateReqVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString;  
7 -  
8 -import javax.validation.constraints.NotNull;  
9 -  
10 -// TODO 状态类型和状态添加,是在一个请求里,所以需要把 CrmBusinessStatusUpdateReqVO 融合进来;  
11 -@Schema(description = "管理后台 - 商机状态类型更新 Request VO")  
12 -@Data  
13 -@EqualsAndHashCode(callSuper = true)  
14 -@ToString(callSuper = true)  
15 -public class CrmBusinessStatusTypeUpdateReqVO extends CrmBusinessStatusTypeBaseVO {  
16 -  
17 - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "24019")  
18 - @NotNull(message = "主键不能为空")  
19 - private Long id;  
20 -  
21 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java
1 package cn.iocoder.yudao.module.crm.controller.admin.contact; 1 package cn.iocoder.yudao.module.crm.controller.admin.contact;
2 2
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.lang.Assert;
4 import cn.hutool.core.util.NumberUtil; 5 import cn.hutool.core.util.NumberUtil;
5 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 6 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  7 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
6 import cn.iocoder.yudao.framework.common.pojo.PageResult; 8 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  9 +import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
7 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; 10 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
8 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; 11 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
9 import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; 12 import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
10 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerExportReqVO;  
11 import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; 13 import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;
12 -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; 14 +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
13 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; 15 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
14 -import cn.iocoder.yudao.module.crm.service.contact.ContactService; 16 +import cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants;
  17 +import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
15 import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; 18 import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
16 import cn.iocoder.yudao.module.system.api.user.AdminUserApi; 19 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
17 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; 20 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
@@ -19,6 +22,7 @@ import com.google.common.collect.Lists; @@ -19,6 +22,7 @@ import com.google.common.collect.Lists;
19 import io.swagger.v3.oas.annotations.Operation; 22 import io.swagger.v3.oas.annotations.Operation;
20 import io.swagger.v3.oas.annotations.Parameter; 23 import io.swagger.v3.oas.annotations.Parameter;
21 import io.swagger.v3.oas.annotations.tags.Tag; 24 import io.swagger.v3.oas.annotations.tags.Tag;
  25 +import lombok.extern.slf4j.Slf4j;
22 import org.springframework.security.access.prepost.PreAuthorize; 26 import org.springframework.security.access.prepost.PreAuthorize;
23 import org.springframework.validation.annotation.Validated; 27 import org.springframework.validation.annotation.Validated;
24 import org.springframework.web.bind.annotation.*; 28 import org.springframework.web.bind.annotation.*;
@@ -27,27 +31,29 @@ import javax.annotation.Resource; @@ -27,27 +31,29 @@ import javax.annotation.Resource;
27 import javax.servlet.http.HttpServletResponse; 31 import javax.servlet.http.HttpServletResponse;
28 import javax.validation.Valid; 32 import javax.validation.Valid;
29 import java.io.IOException; 33 import java.io.IOException;
  34 +import java.util.Collections;
30 import java.util.List; 35 import java.util.List;
31 import java.util.Map; 36 import java.util.Map;
32 -import java.util.Optional;  
33 -import java.util.stream.Collectors; 37 +import java.util.stream.Stream;
34 38
  39 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
35 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 40 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  41 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap;
  42 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
36 import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; 43 import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
37 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; 44 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
38 45
39 -// TODO @zya:crm 所有的类,dou带 Crm 前缀,因为它的名字太通用了,可能和后续的 erp 之类的冲突  
40 @Tag(name = "管理后台 - CRM 联系人") 46 @Tag(name = "管理后台 - CRM 联系人")
41 @RestController 47 @RestController
42 @RequestMapping("/crm/contact") 48 @RequestMapping("/crm/contact")
43 @Validated 49 @Validated
44 -public class ContactController { 50 +@Slf4j
  51 +public class CrmContactController {
45 52
46 @Resource 53 @Resource
47 - private ContactService contactService;  
48 - // TODO @zyna:模块内,注入的变量,不用带 crm 前缀哈 54 + private CrmContactService contactService;
49 @Resource 55 @Resource
50 - private CrmCustomerService crmCustomerService; 56 + private CrmCustomerService customerService;
51 57
52 @Resource 58 @Resource
53 private AdminUserApi adminUserApi; 59 private AdminUserApi adminUserApi;
@@ -55,14 +61,14 @@ public class ContactController { @@ -55,14 +61,14 @@ public class ContactController {
55 @PostMapping("/create") 61 @PostMapping("/create")
56 @Operation(summary = "创建联系人") 62 @Operation(summary = "创建联系人")
57 @PreAuthorize("@ss.hasPermission('crm:contact:create')") 63 @PreAuthorize("@ss.hasPermission('crm:contact:create')")
58 - public CommonResult<Long> createContact(@Valid @RequestBody ContactCreateReqVO createReqVO) { 64 + public CommonResult<Long> createContact(@Valid @RequestBody CrmContactCreateReqVO createReqVO) {
59 return success(contactService.createContact(createReqVO, getLoginUserId())); 65 return success(contactService.createContact(createReqVO, getLoginUserId()));
60 } 66 }
61 67
62 @PutMapping("/update") 68 @PutMapping("/update")
63 @Operation(summary = "更新联系人") 69 @Operation(summary = "更新联系人")
64 @PreAuthorize("@ss.hasPermission('crm:contact:update')") 70 @PreAuthorize("@ss.hasPermission('crm:contact:update')")
65 - public CommonResult<Boolean> updateContact(@Valid @RequestBody ContactUpdateReqVO updateReqVO) { 71 + public CommonResult<Boolean> updateContact(@Valid @RequestBody CrmContactUpdateReqVO updateReqVO) {
66 contactService.updateContact(updateReqVO); 72 contactService.updateContact(updateReqVO);
67 return success(true); 73 return success(true);
68 } 74 }
@@ -80,56 +86,78 @@ public class ContactController { @@ -80,56 +86,78 @@ public class ContactController {
80 @Operation(summary = "获得联系人") 86 @Operation(summary = "获得联系人")
81 @Parameter(name = "id", description = "编号", required = true, example = "1024") 87 @Parameter(name = "id", description = "编号", required = true, example = "1024")
82 @PreAuthorize("@ss.hasPermission('crm:contact:query')") 88 @PreAuthorize("@ss.hasPermission('crm:contact:query')")
83 - public CommonResult<ContactRespVO> getContact(@RequestParam("id") Long id) {  
84 - ContactDO contact = contactService.getContact(id);  
85 - // TODO @zyna:需要考虑 null 的情况;  
86 - ContactRespVO contactRespVO = ContactConvert.INSTANCE.convert(contact);  
87 - // TODO @zyna:可以把数据读完后,convert 统一交给 ContactConvert,让 controller 更简洁;而 convert 专门去做一些转换逻辑 89 + public CommonResult<CrmContactRespVO> getContact(@RequestParam("id") Long id) {
  90 + CrmContactDO contact = contactService.getContact(id);
  91 + if (contact == null) {
  92 + throw exception(ErrorCodeConstants.CONTACT_NOT_EXISTS);
  93 + }
  94 + // 1. 获取用户名
88 Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(CollUtil.removeNull(Lists.newArrayList( 95 Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(CollUtil.removeNull(Lists.newArrayList(
89 - NumberUtil.parseLong(contact.getCreator()))));  
90 - contactRespVO.setCreatorName(Optional.ofNullable(userMap.get(NumberUtil.parseLong(contact.getCreator()))).map(AdminUserRespDTO::getNickname).orElse(null));  
91 - contactRespVO.setCustomerName(Optional.ofNullable(crmCustomerService.getCustomer(contact.getCustomerId())).map(CrmCustomerDO::getName).orElse(null));  
92 - return success(contactRespVO); 96 + NumberUtil.parseLong(contact.getCreator()), contact.getOwnerUserId())));
  97 + // 2. 获取客户信息
  98 + List<CrmCustomerDO> customerList = customerService.getCustomerList(Collections.singletonList(contact.getCustomerId()));
  99 + // 3. 直属上级
  100 + List<CrmContactDO> parentContactList = contactService.getContactList(Collections.singletonList(contact.getParentId()));
  101 + return success(ContactConvert.INSTANCE.convert(contact, userMap, customerList, parentContactList));
93 } 102 }
94 103
95 - // TODO @zyna:url 使用中划线噢;然后,单词的拼写也要注意呀,AllList 是不是更好呀;  
96 - @GetMapping("/simpleAlllist") 104 + @GetMapping("/simple-all-list")
97 @Operation(summary = "获得联系人列表") 105 @Operation(summary = "获得联系人列表")
98 @PreAuthorize("@ss.hasPermission('crm:contact:query')") 106 @PreAuthorize("@ss.hasPermission('crm:contact:query')")
99 - public CommonResult<List<ContactSimpleRespVO>> simpleAlllist() {  
100 - // TODO @zyna:方法名改成,getContactList;方法命名,要动名词,get 动词;all 可以去掉,因为没条件,自然是全部  
101 - List<ContactDO> list = contactService.allContactList(); 107 + public CommonResult<List<CrmContactSimpleRespVO>> getSimpleContactList() {
  108 + List<CrmContactDO> list = contactService.getContactList();
102 return success(ContactConvert.INSTANCE.convertAllList(list)); 109 return success(ContactConvert.INSTANCE.convertAllList(list));
103 } 110 }
104 111
105 @GetMapping("/page") 112 @GetMapping("/page")
106 @Operation(summary = "获得联系人分页") 113 @Operation(summary = "获得联系人分页")
107 @PreAuthorize("@ss.hasPermission('crm:contact:query')") 114 @PreAuthorize("@ss.hasPermission('crm:contact:query')")
108 - public CommonResult<PageResult<ContactRespVO>> getContactPage(@Valid ContactPageReqVO pageVO) {  
109 - PageResult<ContactDO> pageData = contactService.getContactPage(pageVO);  
110 - PageResult<ContactRespVO> pageResult =ContactConvert.INSTANCE.convertPage(pageData);  
111 - // TODO @zyna:需要考虑 null 的情况;  
112 - // TODO @zyna:可以把数据读完后,convert 统一交给 ContactConvert,让 controller 更简洁;而 convert 专门去做一些转换逻辑  
113 - //待接口实现后修改  
114 - List<CrmCustomerDO> crmCustomerDOList = crmCustomerService.getCustomerList(new CrmCustomerExportReqVO());  
115 - Map<Long,CrmCustomerDO> crmCustomerDOMap = crmCustomerDOList.stream().collect(Collectors.toMap(CrmCustomerDO::getId,v->v));  
116 - pageResult.getList().forEach(item -> {  
117 - item.setCustomerName(Optional.ofNullable(crmCustomerDOMap.get(item.getCustomerId())).map(CrmCustomerDO::getName).orElse(null));  
118 - });  
119 - return success(pageResult); 115 + public CommonResult<PageResult<CrmContactRespVO>> getContactPage(@Valid CrmContactPageReqVO pageVO) {
  116 + PageResult<CrmContactDO> pageResult = contactService.getContactPage(pageVO);
  117 + return success(convertDetailContactPage(pageResult));
  118 + }
  119 +
  120 + @GetMapping("/page-by-customer")
  121 + @Operation(summary = "获得联系人分页,基于指定客户")
  122 + public CommonResult<PageResult<CrmContactRespVO>> getContactPageByCustomer(@Valid CrmContactPageReqVO pageVO) {
  123 + Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空");
  124 + PageResult<CrmContactDO> pageResult = contactService.getContactPageByCustomer(pageVO);
  125 + return success(convertDetailContactPage(pageResult));
120 } 126 }
121 127
122 - // TODO @zyna:可以看下新的导出写法,这里调整下  
123 @GetMapping("/export-excel") 128 @GetMapping("/export-excel")
124 @Operation(summary = "导出联系人 Excel") 129 @Operation(summary = "导出联系人 Excel")
125 @PreAuthorize("@ss.hasPermission('crm:contact:export')") 130 @PreAuthorize("@ss.hasPermission('crm:contact:export')")
126 @OperateLog(type = EXPORT) 131 @OperateLog(type = EXPORT)
127 - public void exportContactExcel(@Valid ContactExportReqVO exportReqVO,  
128 - HttpServletResponse response) throws IOException {  
129 - List<ContactDO> list = contactService.getContactList(exportReqVO);  
130 - // 导出 Excel  
131 - List<ContactExcelVO> datas = ContactConvert.INSTANCE.convertList02(list);  
132 - ExcelUtils.write(response, "crm联系人.xls", "数据", ContactExcelVO.class, datas); 132 + public void exportContactExcel(@Valid CrmContactPageReqVO exportReqVO,
  133 + HttpServletResponse response) throws IOException {
  134 + exportReqVO.setPageNo(PageParam.PAGE_SIZE_NONE);
  135 + PageResult<CrmContactDO> pageResult = contactService.getContactPage(exportReqVO);
  136 + ExcelUtils.write(response, "联系人.xls", "数据", CrmContactRespVO.class,
  137 + convertDetailContactPage(pageResult).getList());
  138 + }
  139 +
  140 + /**
  141 + * 转换成详细的联系人分页,即读取关联信息
  142 + *
  143 + * @param pageResult 联系人分页
  144 + * @return 详细的联系人分页
  145 + */
  146 + private PageResult<CrmContactRespVO> convertDetailContactPage(PageResult<CrmContactDO> pageResult) {
  147 + List<CrmContactDO> contactList = pageResult.getList();
  148 + if (CollUtil.isEmpty(contactList)) {
  149 + return PageResult.empty(pageResult.getTotal());
  150 + }
  151 + // 1. 获取客户列表
  152 + List<CrmCustomerDO> crmCustomerDOList = customerService.getCustomerList(
  153 + convertSet(contactList, CrmContactDO::getCustomerId));
  154 + // 2. 获取创建人、负责人列表
  155 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList,
  156 + contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId())));
  157 + // 3. 直属上级
  158 + List<CrmContactDO> parentContactList = contactService.getContactList(
  159 + convertSet(contactList, CrmContactDO::getParentId));
  160 + return ContactConvert.INSTANCE.convertPage(pageResult, userMap, crmCustomerDOList, parentContactList);
133 } 161 }
134 162
135 } 163 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExcelVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;  
2 -  
3 -import com.alibaba.excel.annotation.ExcelProperty;  
4 -import lombok.Data;  
5 -  
6 -import java.time.LocalDateTime;  
7 -  
8 -// TODO @zyna:参考新的 VO 结构,把 ContactExcelVO 融合到 ContactRespVO 中  
9 -/**  
10 - * crm联系人 Excel VO  
11 - *  
12 - * @author 芋道源码  
13 - */  
14 -@Data  
15 -@Deprecated  
16 -public class ContactExcelVO {  
17 -  
18 - @ExcelProperty("下次联系时间")  
19 - private LocalDateTime nextTime;  
20 -  
21 - @ExcelProperty("手机号")  
22 - private String mobile;  
23 -  
24 - @ExcelProperty("电话")  
25 - private String telephone;  
26 -  
27 - @ExcelProperty("电子邮箱")  
28 - private String email;  
29 -  
30 - @ExcelProperty("客户编号")  
31 - private Long customerId;  
32 -  
33 - @ExcelProperty("地址")  
34 - private String address;  
35 -  
36 - @ExcelProperty("备注")  
37 - private String remark;  
38 -  
39 - @ExcelProperty("创建时间")  
40 - private LocalDateTime createTime;  
41 -  
42 - @ExcelProperty("最后跟进时间")  
43 - private LocalDateTime lastTime;  
44 -  
45 - @ExcelProperty("主键")  
46 - private Long id;  
47 -  
48 - @ExcelProperty("直属上级")  
49 - private Long parentId;  
50 -  
51 - @ExcelProperty("姓名")  
52 - private String name;  
53 -  
54 - @ExcelProperty("职位")  
55 - private String post;  
56 -  
57 - @ExcelProperty("QQ")  
58 - private Long qq;  
59 -  
60 - @ExcelProperty("微信")  
61 - private String webchat;  
62 -  
63 - @ExcelProperty("性别")  
64 - private Integer sex;  
65 -  
66 - @ExcelProperty("是否关键决策人")  
67 - private Boolean policyMakers;  
68 -  
69 - @ExcelProperty("负责人用户编号")  
70 - private String ownerUserId;  
71 -  
72 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import org.springframework.format.annotation.DateTimeFormat;  
6 -  
7 -import java.time.LocalDateTime;  
8 -  
9 -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;  
10 -  
11 -// TODO @zyna:参考新的 VO 结构,使用 ContactPageReqVO 查询导出的数据  
12 -@Schema(description = "管理后台 - crm联系人 Excel 导出 Request VO,参数和 ContactPageReqVO 是一致的")  
13 -@Data  
14 -@Deprecated  
15 -public class ContactExportReqVO {  
16 -  
17 - @Schema(description = "下次联系时间")  
18 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
19 - private LocalDateTime[] nextTime;  
20 -  
21 - @Schema(description = "手机号")  
22 - private String mobile;  
23 -  
24 - @Schema(description = "电话")  
25 - private String telephone;  
26 -  
27 - @Schema(description = "电子邮箱")  
28 - private String email;  
29 -  
30 - @Schema(description = "客户编号", example = "10795")  
31 - private Long customerId;  
32 -  
33 - @Schema(description = "地址")  
34 - private String address;  
35 -  
36 - @Schema(description = "备注", example = "你说的对")  
37 - private String remark;  
38 -  
39 - @Schema(description = "创建时间")  
40 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
41 - private LocalDateTime[] createTime;  
42 -  
43 - @Schema(description = "最后跟进时间")  
44 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
45 - private LocalDateTime[] lastTime;  
46 -  
47 - @Schema(description = "直属上级", example = "23457")  
48 - private Long parentId;  
49 -  
50 - @Schema(description = "姓名", example = "芋艿")  
51 - private String name;  
52 -  
53 - @Schema(description = "职位")  
54 - private String post;  
55 -  
56 - @Schema(description = "QQ")  
57 - private Long qq;  
58 -  
59 - @Schema(description = "微信")  
60 - private String webchat;  
61 -  
62 - @Schema(description = "性别")  
63 - private Integer sex;  
64 -  
65 - @Schema(description = "是否关键决策人")  
66 - private Boolean policyMakers;  
67 -  
68 - @Schema(description = "负责人用户编号", example = "14334")  
69 - private String ownerUserId;  
70 -  
71 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;  
2 -  
3 -import cn.iocoder.yudao.framework.common.pojo.PageParam;  
4 -import io.swagger.v3.oas.annotations.media.Schema;  
5 -import lombok.Data;  
6 -import lombok.EqualsAndHashCode;  
7 -import lombok.ToString;  
8 -import org.springframework.format.annotation.DateTimeFormat;  
9 -  
10 -import java.time.LocalDateTime;  
11 -  
12 -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;  
13 -  
14 -@Schema(description = "管理后台 - crm联系人分页 Request VO")  
15 -@Data  
16 -@EqualsAndHashCode(callSuper = true)  
17 -@ToString(callSuper = true)  
18 -public class ContactPageReqVO extends PageParam {  
19 -  
20 - // TODO @zyna:筛选条件  
21 - // ●客户:  
22 - // ●姓名:  
23 - // ●手机、电话、座机、QQ、微信、邮箱  
24 -  
25 - @Schema(description = "下次联系时间")  
26 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
27 - private LocalDateTime[] nextTime;  
28 -  
29 - @Schema(description = "手机号")  
30 - private String mobile;  
31 -  
32 - @Schema(description = "电话")  
33 - private String telephone;  
34 -  
35 - @Schema(description = "电子邮箱")  
36 - private String email;  
37 -  
38 - @Schema(description = "客户编号", example = "10795")  
39 - private Long customerId;  
40 -  
41 - @Schema(description = "地址")  
42 - private String address;  
43 -  
44 - @Schema(description = "备注", example = "你说的对")  
45 - private String remark;  
46 -  
47 - @Schema(description = "创建时间")  
48 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
49 - private LocalDateTime[] createTime;  
50 -  
51 - @Schema(description = "最后跟进时间")  
52 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
53 - private LocalDateTime[] lastTime;  
54 -  
55 - @Schema(description = "直属上级", example = "23457")  
56 - private Long parentId;  
57 -  
58 - @Schema(description = "姓名", example = "芋艿")  
59 - private String name;  
60 -  
61 - @Schema(description = "职位")  
62 - private String post;  
63 -  
64 - @Schema(description = "QQ")  
65 - private Long qq;  
66 -  
67 - @Schema(description = "微信")  
68 - private String webchat;  
69 -  
70 - @Schema(description = "性别")  
71 - private Integer sex;  
72 -  
73 - @Schema(description = "是否关键决策人")  
74 - private Boolean policyMakers;  
75 -  
76 - @Schema(description = "负责人用户编号", example = "14334")  
77 - private String ownerUserId;  
78 -  
79 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBaseVO.java
1 package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; 1 package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
2 2
  3 +import cn.iocoder.yudao.framework.common.validation.Mobile;
  4 +import cn.iocoder.yudao.framework.common.validation.Telephone;
  5 +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
  6 +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
  7 +import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
  8 +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
  9 +import com.alibaba.excel.annotation.ExcelProperty;
3 import io.swagger.v3.oas.annotations.media.Schema; 10 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 11 import lombok.Data;
5 import org.springframework.format.annotation.DateTimeFormat; 12 import org.springframework.format.annotation.DateTimeFormat;
6 13
  14 +import javax.validation.constraints.Email;
  15 +import javax.validation.constraints.NotNull;
7 import java.time.LocalDateTime; 16 import java.time.LocalDateTime;
8 17
9 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; 18 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
10 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; 19 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
11 20
12 -// TODO zyna:参考新的 vo,重新拆分下 VO 21 +// TODO zyna:要不按照新的,干掉这个 basevo,都放子类里
13 /** 22 /**
14 * CRM 联系人 Base VO,提供给添加、修改、详细的子 VO 使用 23 * CRM 联系人 Base VO,提供给添加、修改、详细的子 VO 使用
15 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 24 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
16 */ 25 */
17 @Data 26 @Data
18 -public class ContactBaseVO { 27 +@ExcelIgnoreUnannotated
  28 +public class CrmContactBaseVO {
19 29
20 - // TODO @zyna:example 最好都写下  
21 - // TODO @zyna:必要的字段校验,例如说 @Mobile,@Emal 等等 30 + @ExcelProperty(value = "姓名",order = 1)
  31 + @Schema(description = "姓名", example = "芋艿")
  32 + @NotNull(message = "姓名不能为空")
  33 + private String name;
22 34
23 - @Schema(description = "下次联系时间")  
24 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)  
25 - private LocalDateTime nextTime; 35 + @Schema(description = "客户编号", example = "10795")
  36 + private Long customerId;
  37 +
  38 + @ExcelProperty(value = "性别", converter = DictConvert.class, order = 3)
  39 + @DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_SEX)
  40 + @Schema(description = "性别")
  41 + private Integer sex;
26 42
27 - @Schema(description = "手机号") 43 + @Schema(description = "职位")
  44 + @ExcelProperty(value = "职位", order = 3)
  45 + private String post;
  46 +
  47 + @Schema(description = "是否关键决策人")
  48 + @ExcelProperty(value = "是否关键决策人", converter = DictConvert.class, order = 3)
  49 + @DictFormat(DictTypeConstants.BOOLEAN_STRING)
  50 + private Boolean master;
  51 +
  52 + @Schema(description = "直属上级", example = "23457")
  53 + private Long parentId;
  54 +
  55 + @Schema(description = "手机号",example = "1387171766")
  56 + @Mobile
  57 + @ExcelProperty(value = "手机号",order = 4)
28 private String mobile; 58 private String mobile;
29 59
30 - @Schema(description = "电话") 60 + @Schema(description = "座机",example = "021-0029922")
  61 + @Telephone
  62 + @ExcelProperty(value = "座机",order = 4)
31 private String telephone; 63 private String telephone;
32 64
33 - @Schema(description = "电子邮箱")  
34 - private String email; 65 + @ExcelProperty(value = "QQ",order = 4)
  66 + @Schema(description = "QQ",example = "197272662")
  67 + private Long qq;
35 68
36 - @Schema(description = "客户编号", example = "10795")  
37 - private Long customerId; 69 + @ExcelProperty(value = "微信",order = 4)
  70 + @Schema(description = "微信",example = "zzz3883")
  71 + private String wechat;
  72 +
  73 + @Schema(description = "电子邮箱",example = "1111@22.com")
  74 + @Email
  75 + @ExcelProperty(value = "邮箱",order = 4)
  76 + private String email;
38 77
  78 + @ExcelProperty(value = "地址",order = 5)
39 @Schema(description = "地址") 79 @Schema(description = "地址")
40 private String address; 80 private String address;
41 81
  82 + @Schema(description = "下次联系时间")
  83 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
  84 + @ExcelProperty(value = "下次联系时间",order = 6)
  85 + private LocalDateTime nextTime;
  86 +
42 @Schema(description = "备注", example = "你说的对") 87 @Schema(description = "备注", example = "你说的对")
  88 + @ExcelProperty(value = "备注",order = 6)
43 private String remark; 89 private String remark;
44 90
45 @Schema(description = "最后跟进时间") 91 @Schema(description = "最后跟进时间")
46 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) 92 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  93 + @ExcelProperty(value = "最后跟进时间",order = 6)
47 private LocalDateTime lastTime; 94 private LocalDateTime lastTime;
48 95
49 - @Schema(description = "直属上级", example = "23457")  
50 - private Long parentId;  
51 -  
52 - @Schema(description = "姓名", example = "芋艿")  
53 - private String name;  
54 -  
55 - @Schema(description = "职位")  
56 - private String post;  
57 -  
58 - @Schema(description = "QQ")  
59 - private Long qq;  
60 -  
61 - @Schema(description = "微信")  
62 - private String webchat;  
63 -  
64 - @Schema(description = "性别")  
65 - private Integer sex;  
66 -  
67 - @Schema(description = "是否关键决策人")  
68 - private Boolean policyMakers;  
69 -  
70 @Schema(description = "负责人用户编号", example = "14334") 96 @Schema(description = "负责人用户编号", example = "14334")
71 - private String ownerUserId; 97 + @NotNull(message = "负责人不能为空")
  98 + private Long ownerUserId;
  99 +
  100 + @Schema(description = "地区编号", example = "20158")
  101 + private Integer areaId;
72 102
73 } 103 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactCreateReqVO.java
@@ -9,6 +9,6 @@ import lombok.ToString; @@ -9,6 +9,6 @@ import lombok.ToString;
9 @Data 9 @Data
10 @EqualsAndHashCode(callSuper = true) 10 @EqualsAndHashCode(callSuper = true)
11 @ToString(callSuper = true) 11 @ToString(callSuper = true)
12 -public class ContactCreateReqVO extends ContactBaseVO { 12 +public class CrmContactCreateReqVO extends CrmContactBaseVO {
13 13
14 } 14 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactPageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import io.swagger.v3.oas.annotations.media.Schema;
  5 +import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
  7 +import lombok.ToString;
  8 +
  9 +@Schema(description = "管理后台 - CRM 联系人分页 Request VO")
  10 +@Data
  11 +@EqualsAndHashCode(callSuper = true)
  12 +@ToString(callSuper = true)
  13 +public class CrmContactPageReqVO extends PageParam {
  14 +
  15 + @Schema(description = "姓名", example = "芋艿")
  16 + private String name;
  17 +
  18 + @Schema(description = "客户编号", example = "10795")
  19 + private Long customerId;
  20 +
  21 + @Schema(description = "手机号", example = "13898273941")
  22 + private String mobile;
  23 +
  24 + @Schema(description = "电话", example = "021-383773")
  25 + private String telephone;
  26 +
  27 + @Schema(description = "电子邮箱", example = "111@22.com")
  28 + private String email;
  29 +
  30 + @Schema(description = "QQ", example = "3882872")
  31 + private Long qq;
  32 +
  33 + @Schema(description = "微信", example = "zzZ98373")
  34 + private String wechat;
  35 +
  36 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactRespVO.java
1 package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; 1 package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
2 2
  3 +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
  4 +import com.alibaba.excel.annotation.ExcelProperty;
3 import io.swagger.v3.oas.annotations.media.Schema; 5 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.*; 6 import lombok.*;
5 import java.time.LocalDateTime; 7 import java.time.LocalDateTime;
@@ -8,20 +10,41 @@ import java.time.LocalDateTime; @@ -8,20 +10,41 @@ import java.time.LocalDateTime;
8 @Data 10 @Data
9 @EqualsAndHashCode(callSuper = true) 11 @EqualsAndHashCode(callSuper = true)
10 @ToString(callSuper = true) 12 @ToString(callSuper = true)
11 -public class ContactRespVO extends ContactBaseVO { 13 +@ExcelIgnoreUnannotated
  14 +public class CrmContactRespVO extends CrmContactBaseVO {
12 15
13 @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167") 16 @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
14 private Long id; 17 private Long id;
15 18
16 @Schema(description = "创建时间") 19 @Schema(description = "创建时间")
  20 + @ExcelProperty(value = "创建时间", order = 8)
17 private LocalDateTime createTime; 21 private LocalDateTime createTime;
18 22
19 - // TODO @zyna:example 最好写下; 23 + @Schema(description = "更新时间")
  24 + @ExcelProperty(value = "更新时间", order = 8)
  25 + private LocalDateTime updateTime;
20 26
21 - @Schema(description = "创建人") 27 + @Schema(description = "创建人", example = "25682")
  28 + private String creator;
  29 +
  30 + @Schema(description = "创建人名字", example = "test")
  31 + @ExcelProperty(value = "创建人", order = 8)
22 private String creatorName; 32 private String creatorName;
23 33
24 - @Schema(description = "客户名字") 34 + @ExcelProperty(value = "客户名称",order = 2)
  35 + @Schema(description = "客户名字", example = "test")
25 private String customerName; 36 private String customerName;
26 37
  38 + @Schema(description = "负责人", example = "test")
  39 + @ExcelProperty(value = "负责人", order = 7)
  40 + private String ownerUserName;
  41 +
  42 + @Schema(description = "直属上级名", example = "芋头")
  43 + @ExcelProperty(value = "直属上级", order = 4)
  44 + private String parentName;
  45 +
  46 + @Schema(description = "地区名", example = "上海上海市浦东新区")
  47 + @ExcelProperty(value = "地区", order = 5)
  48 + private String areaName;
  49 +
27 } 50 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactSimpleRespVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactSimpleRespVO.java
@@ -4,14 +4,15 @@ import io.swagger.v3.oas.annotations.media.Schema; @@ -4,14 +4,15 @@ import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 4 import lombok.Data;
5 import lombok.ToString; 5 import lombok.ToString;
6 6
7 -@Schema(description = "管理后台 - CRM 联系人 Response VO") 7 +@Schema(description = "管理后台 - CRM 联系人的精简 Response VO")
8 @Data 8 @Data
9 @ToString(callSuper = true) 9 @ToString(callSuper = true)
10 -public class ContactSimpleRespVO {  
11 - @Schema(description = "姓名", example = "芋艿") // TODO @zyna:requiredMode = Schema.RequiredMode.REQUIRED;需要空一行;字段的顺序改下,id 在 name 前面,会更干净  
12 - private String name; 10 +public class CrmContactSimpleRespVO {
13 11
14 @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167") 12 @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
15 private Long id; 13 private Long id;
16 14
  15 + @Schema(description = "姓名", example = "芋艿")
  16 + private String name;
  17 +
17 } 18 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java
1 package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; 1 package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
2 2
3 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 3 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
4 import io.swagger.v3.oas.annotations.media.Schema; 4 import io.swagger.v3.oas.annotations.media.Schema;
5 import lombok.Data; 5 import lombok.Data;
6 6
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactUpdateReqVO.java
@@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull; @@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull;
11 @Data 11 @Data
12 @EqualsAndHashCode(callSuper = true) 12 @EqualsAndHashCode(callSuper = true)
13 @ToString(callSuper = true) 13 @ToString(callSuper = true)
14 -public class ContactUpdateReqVO extends ContactBaseVO { 14 +public class CrmContactUpdateReqVO extends CrmContactBaseVO {
15 15
16 @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167") 16 @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
17 @NotNull(message = "主键不能为空") 17 @NotNull(message = "主键不能为空")
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/ContractController.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java
1 package cn.iocoder.yudao.module.crm.controller.admin.contract; 1 package cn.iocoder.yudao.module.crm.controller.admin.contract;
2 2
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.lang.Assert;
3 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 5 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 import cn.iocoder.yudao.framework.common.pojo.PageResult; 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  7 +import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
5 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; 8 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
6 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; 9 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
7 import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; 10 import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*;
8 import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert; 11 import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert;
9 -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO;  
10 -import cn.iocoder.yudao.module.crm.service.contract.ContractService; 12 +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
  13 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
  14 +import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
  15 +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
  16 +import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
  17 +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
11 import io.swagger.v3.oas.annotations.Operation; 18 import io.swagger.v3.oas.annotations.Operation;
12 import io.swagger.v3.oas.annotations.Parameter; 19 import io.swagger.v3.oas.annotations.Parameter;
13 import io.swagger.v3.oas.annotations.tags.Tag; 20 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -20,8 +27,12 @@ import javax.servlet.http.HttpServletResponse; @@ -20,8 +27,12 @@ import javax.servlet.http.HttpServletResponse;
20 import javax.validation.Valid; 27 import javax.validation.Valid;
21 import java.io.IOException; 28 import java.io.IOException;
22 import java.util.List; 29 import java.util.List;
  30 +import java.util.Map;
  31 +import java.util.stream.Stream;
23 32
24 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 33 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  34 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap;
  35 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
25 import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; 36 import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
26 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; 37 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
27 38
@@ -29,22 +40,27 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti @@ -29,22 +40,27 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti
29 @RestController 40 @RestController
30 @RequestMapping("/crm/contract") 41 @RequestMapping("/crm/contract")
31 @Validated 42 @Validated
32 -public class ContractController { 43 +public class CrmContractController {
33 44
34 @Resource 45 @Resource
35 - private ContractService contractService; 46 + private CrmContractService contractService;
  47 + @Resource
  48 + private CrmCustomerService customerService;
  49 +
  50 + @Resource
  51 + private AdminUserApi adminUserApi;
36 52
37 @PostMapping("/create") 53 @PostMapping("/create")
38 @Operation(summary = "创建合同") 54 @Operation(summary = "创建合同")
39 @PreAuthorize("@ss.hasPermission('crm:contract:create')") 55 @PreAuthorize("@ss.hasPermission('crm:contract:create')")
40 - public CommonResult<Long> createContract(@Valid @RequestBody ContractCreateReqVO createReqVO) { 56 + public CommonResult<Long> createContract(@Valid @RequestBody CrmContractCreateReqVO createReqVO) {
41 return success(contractService.createContract(createReqVO, getLoginUserId())); 57 return success(contractService.createContract(createReqVO, getLoginUserId()));
42 } 58 }
43 59
44 @PutMapping("/update") 60 @PutMapping("/update")
45 @Operation(summary = "更新合同") 61 @Operation(summary = "更新合同")
46 @PreAuthorize("@ss.hasPermission('crm:contract:update')") 62 @PreAuthorize("@ss.hasPermission('crm:contract:update')")
47 - public CommonResult<Boolean> updateContract(@Valid @RequestBody ContractUpdateReqVO updateReqVO) { 63 + public CommonResult<Boolean> updateContract(@Valid @RequestBody CrmContractUpdateReqVO updateReqVO) {
48 contractService.updateContract(updateReqVO); 64 contractService.updateContract(updateReqVO);
49 return success(true); 65 return success(true);
50 } 66 }
@@ -63,28 +79,56 @@ public class ContractController { @@ -63,28 +79,56 @@ public class ContractController {
63 @Parameter(name = "id", description = "编号", required = true, example = "1024") 79 @Parameter(name = "id", description = "编号", required = true, example = "1024")
64 @PreAuthorize("@ss.hasPermission('crm:contract:query')") 80 @PreAuthorize("@ss.hasPermission('crm:contract:query')")
65 public CommonResult<ContractRespVO> getContract(@RequestParam("id") Long id) { 81 public CommonResult<ContractRespVO> getContract(@RequestParam("id") Long id) {
66 - ContractDO contract = contractService.getContract(id); 82 + CrmContractDO contract = contractService.getContract(id);
67 return success(ContractConvert.INSTANCE.convert(contract)); 83 return success(ContractConvert.INSTANCE.convert(contract));
68 } 84 }
69 85
70 @GetMapping("/page") 86 @GetMapping("/page")
71 @Operation(summary = "获得合同分页") 87 @Operation(summary = "获得合同分页")
72 @PreAuthorize("@ss.hasPermission('crm:contract:query')") 88 @PreAuthorize("@ss.hasPermission('crm:contract:query')")
73 - public CommonResult<PageResult<ContractRespVO>> getContractPage(@Valid ContractPageReqVO pageVO) {  
74 - PageResult<ContractDO> pageResult = contractService.getContractPage(pageVO);  
75 - return success(ContractConvert.INSTANCE.convertPage(pageResult)); 89 + public CommonResult<PageResult<ContractRespVO>> getContractPage(@Valid CrmContractPageReqVO pageVO) {
  90 + PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO);
  91 + return success(convertDetailContractPage(pageResult));
  92 + }
  93 +
  94 + @GetMapping("/page-by-customer")
  95 + @Operation(summary = "获得联系人分页,基于指定客户")
  96 + public CommonResult<PageResult<ContractRespVO>> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) {
  97 + Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空");
  98 + PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomer(pageVO);
  99 + return success(convertDetailContractPage(pageResult));
76 } 100 }
77 101
78 @GetMapping("/export-excel") 102 @GetMapping("/export-excel")
79 @Operation(summary = "导出合同 Excel") 103 @Operation(summary = "导出合同 Excel")
80 @PreAuthorize("@ss.hasPermission('crm:contract:export')") 104 @PreAuthorize("@ss.hasPermission('crm:contract:export')")
81 @OperateLog(type = EXPORT) 105 @OperateLog(type = EXPORT)
82 - public void exportContractExcel(@Valid ContractExportReqVO exportReqVO, 106 + public void exportContractExcel(@Valid CrmContractPageReqVO exportReqVO,
83 HttpServletResponse response) throws IOException { 107 HttpServletResponse response) throws IOException {
84 - List<ContractDO> list = contractService.getContractList(exportReqVO); 108 + PageResult<CrmContractDO> pageResult = contractService.getContractPage(exportReqVO);
85 // 导出 Excel 109 // 导出 Excel
86 - List<ContractExcelVO> datas = ContractConvert.INSTANCE.convertList02(list);  
87 - ExcelUtils.write(response, "合同.xls", "数据", ContractExcelVO.class, datas); 110 + ExcelUtils.write(response, "合同.xls", "数据", CrmContractExcelVO.class,
  111 + ContractConvert.INSTANCE.convertList02(pageResult.getList()));
  112 + }
  113 +
  114 + /**
  115 + * 转换成详细的联系人分页,即读取关联信息
  116 + *
  117 + * @param pageResult 联系人分页
  118 + * @return 详细的联系人分页
  119 + */
  120 + private PageResult<ContractRespVO> convertDetailContractPage(PageResult<CrmContractDO> pageResult) {
  121 + List<CrmContractDO> contactList = pageResult.getList();
  122 + if (CollUtil.isEmpty(contactList)) {
  123 + return PageResult.empty(pageResult.getTotal());
  124 + }
  125 + // 1. 获取客户列表
  126 + List<CrmCustomerDO> customerList = customerService.getCustomerList(
  127 + convertSet(contactList, CrmContractDO::getCustomerId));
  128 + // 2. 获取创建人、负责人列表
  129 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList,
  130 + contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId())));
  131 + return ContractConvert.INSTANCE.convertPage(pageResult, userMap, customerList);
88 } 132 }
89 133
90 @PutMapping("/transfer") 134 @PutMapping("/transfer")
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractExportReqVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import org.springframework.format.annotation.DateTimeFormat;  
6 -  
7 -import java.time.LocalDateTime;  
8 -  
9 -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;  
10 -  
11 -@Schema(description = "管理后台 - CRM 合同 Excel 导出 Request VO,参数和 ContractPageReqVO 是一致的")  
12 -@Data  
13 -public class ContractExportReqVO {  
14 -  
15 - @Schema(description = "合同名称", example = "王五")  
16 - private String name;  
17 -  
18 - @Schema(description = "客户编号", example = "18336")  
19 - private Long customerId;  
20 -  
21 - @Schema(description = "商机编号", example = "10864")  
22 - private Long businessId;  
23 -  
24 - @Schema(description = "下单日期")  
25 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
26 - private LocalDateTime[] orderDate;  
27 -  
28 - @Schema(description = "合同编号")  
29 - private String no;  
30 -  
31 - @Schema(description = "整单折扣")  
32 - private Integer discountPercent;  
33 -  
34 - @Schema(description = "产品总金额", example = "19510")  
35 - private Integer productPrice;  
36 -  
37 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractRespVO.java
@@ -11,7 +11,7 @@ import java.time.LocalDateTime; @@ -11,7 +11,7 @@ import java.time.LocalDateTime;
11 @Data 11 @Data
12 @EqualsAndHashCode(callSuper = true) 12 @EqualsAndHashCode(callSuper = true)
13 @ToString(callSuper = true) 13 @ToString(callSuper = true)
14 -public class ContractRespVO extends ContractBaseVO { 14 +public class ContractRespVO extends CrmContractBaseVO {
15 15
16 @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") 16 @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
17 private Long id; 17 private Long id;
@@ -19,4 +19,19 @@ public class ContractRespVO extends ContractBaseVO { @@ -19,4 +19,19 @@ public class ContractRespVO extends ContractBaseVO {
19 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) 19 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
20 private LocalDateTime createTime; 20 private LocalDateTime createTime;
21 21
  22 + @Schema(description = "创建人", example = "25682")
  23 + private String creator;
  24 +
  25 + @Schema(description = "创建人名字", example = "test")
  26 + private String creatorName;
  27 +
  28 + @Schema(description = "客户名字", example = "test")
  29 + private String customerName;
  30 +
  31 + @Schema(description = "负责人", example = "test")
  32 + private String ownerUserName;
  33 +
  34 + @Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
  35 + private Integer auditStatus;
  36 +
22 } 37 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractBaseVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractBaseVO.java
@@ -9,13 +9,12 @@ import java.time.LocalDateTime; @@ -9,13 +9,12 @@ import java.time.LocalDateTime;
9 9
10 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; 10 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
11 11
12 -// TODO @dhb52:所有类,带下 Crm 前缀,避免和别的模块重复  
13 /** 12 /**
14 * 合同 Base VO,提供给添加、修改、详细的子 VO 使用 13 * 合同 Base VO,提供给添加、修改、详细的子 VO 使用
15 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 14 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
16 */ 15 */
17 @Data 16 @Data
18 -public class ContractBaseVO { 17 +public class CrmContractBaseVO {
19 18
20 // TODO @dhb52:类似 no 字段的 example 要写xia 哈; 19 // TODO @dhb52:类似 no 字段的 example 要写xia 哈;
21 20
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractCreateReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractCreateReqVO.java
@@ -9,6 +9,6 @@ import lombok.ToString; @@ -9,6 +9,6 @@ import lombok.ToString;
9 @Data 9 @Data
10 @EqualsAndHashCode(callSuper = true) 10 @EqualsAndHashCode(callSuper = true)
11 @ToString(callSuper = true) 11 @ToString(callSuper = true)
12 -public class ContractCreateReqVO extends ContractBaseVO { 12 +public class CrmContractCreateReqVO extends CrmContractBaseVO {
13 13
14 } 14 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractExcelVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractExcelVO.java
@@ -11,7 +11,7 @@ import java.time.LocalDateTime; @@ -11,7 +11,7 @@ import java.time.LocalDateTime;
11 * @author dhb52 11 * @author dhb52
12 */ 12 */
13 @Data 13 @Data
14 -public class ContractExcelVO { 14 +public class CrmContractExcelVO {
15 15
16 @ExcelProperty("合同编号") 16 @ExcelProperty("合同编号")
17 private Long id; 17 private Long id;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractPageReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractPageReqVO.java
@@ -5,17 +5,15 @@ import io.swagger.v3.oas.annotations.media.Schema; @@ -5,17 +5,15 @@ import io.swagger.v3.oas.annotations.media.Schema;
5 import lombok.Data; 5 import lombok.Data;
6 import lombok.EqualsAndHashCode; 6 import lombok.EqualsAndHashCode;
7 import lombok.ToString; 7 import lombok.ToString;
8 -import org.springframework.format.annotation.DateTimeFormat;  
9 -  
10 -import java.time.LocalDateTime;  
11 -  
12 -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;  
13 8
14 @Schema(description = "管理后台 - CRM 合同分页 Request VO") 9 @Schema(description = "管理后台 - CRM 合同分页 Request VO")
15 @Data 10 @Data
16 @EqualsAndHashCode(callSuper = true) 11 @EqualsAndHashCode(callSuper = true)
17 @ToString(callSuper = true) 12 @ToString(callSuper = true)
18 -public class ContractPageReqVO extends PageParam { 13 +public class CrmContractPageReqVO extends PageParam {
  14 +
  15 + @Schema(description = "合同编号", example = "XYZ008")
  16 + private String no;
19 17
20 @Schema(description = "合同名称", example = "王五") 18 @Schema(description = "合同名称", example = "王五")
21 private String name; 19 private String name;
@@ -26,17 +24,4 @@ public class ContractPageReqVO extends PageParam { @@ -26,17 +24,4 @@ public class ContractPageReqVO extends PageParam {
26 @Schema(description = "商机编号", example = "10864") 24 @Schema(description = "商机编号", example = "10864")
27 private Long businessId; 25 private Long businessId;
28 26
29 - @Schema(description = "下单日期")  
30 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
31 - private LocalDateTime[] orderDate;  
32 -  
33 - @Schema(description = "合同编号")  
34 - private String no;  
35 -  
36 - @Schema(description = "整单折扣")  
37 - private Integer discountPercent;  
38 -  
39 - @Schema(description = "产品总金额", example = "19510")  
40 - private Integer productPrice;  
41 -  
42 } 27 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractTransferReqVO.java
1 package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; 1 package cn.iocoder.yudao.module.crm.controller.admin.contract.vo;
2 2
3 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 3 +import cn.iocoder.yudao.framework.common.validation.InEnum;
  4 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
4 import io.swagger.v3.oas.annotations.media.Schema; 5 import io.swagger.v3.oas.annotations.media.Schema;
5 import lombok.Data; 6 import lombok.Data;
6 7
@@ -14,19 +15,12 @@ public class CrmContractTransferReqVO { @@ -14,19 +15,12 @@ public class CrmContractTransferReqVO {
14 @NotNull(message = "联系人编号不能为空") 15 @NotNull(message = "联系人编号不能为空")
15 private Long id; 16 private Long id;
16 17
17 - /**  
18 - * 新负责人的用户编号  
19 - */  
20 @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") 18 @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
21 @NotNull(message = "新负责人的用户编号不能为空") 19 @NotNull(message = "新负责人的用户编号不能为空")
22 private Long newOwnerUserId; 20 private Long newOwnerUserId;
23 21
24 - /**  
25 - * 老负责人加入团队后的权限级别。如果 null 说明移除  
26 - *  
27 - * 关联 {@link CrmPermissionLevelEnum}  
28 - */  
29 @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") 22 @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
  23 + @InEnum(value = CrmPermissionLevelEnum.class)
30 private Integer oldOwnerPermissionLevel; 24 private Integer oldOwnerPermissionLevel;
31 25
32 } 26 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractUpdateReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractUpdateReqVO.java
@@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull; @@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull;
11 @Data 11 @Data
12 @EqualsAndHashCode(callSuper = true) 12 @EqualsAndHashCode(callSuper = true)
13 @ToString(callSuper = true) 13 @ToString(callSuper = true)
14 -public class ContractUpdateReqVO extends ContractBaseVO { 14 +public class CrmContractUpdateReqVO extends CrmContractBaseVO {
15 15
16 @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") 16 @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
17 @NotNull(message = "合同编号不能为空") 17 @NotNull(message = "合同编号不能为空")
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.http 0 → 100644
  1 +### 请求 /update
  2 +GET {{baseUrl}}/crm/customer/page?pageNo=1&pageSize=10&name="张三"
  3 +Authorization: Bearer {{token}}
  4 +tenant-id: {{adminTenentId}}
  5 +
  6 +
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
1 package cn.iocoder.yudao.module.crm.controller.admin.customer; 1 package cn.iocoder.yudao.module.crm.controller.admin.customer;
2 2
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 -import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;  
5 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 4 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
6 import cn.iocoder.yudao.framework.common.pojo.PageResult; 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
7 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; 6 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
@@ -9,20 +8,17 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; @@ -9,20 +8,17 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
9 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; 8 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
10 import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; 9 import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert;
11 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; 10 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
12 -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;  
13 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;  
14 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum;  
15 import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; 11 import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
16 -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;  
17 import cn.iocoder.yudao.module.system.api.dept.DeptApi; 12 import cn.iocoder.yudao.module.system.api.dept.DeptApi;
18 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; 13 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
19 import cn.iocoder.yudao.module.system.api.user.AdminUserApi; 14 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
20 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; 15 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
21 import io.swagger.v3.oas.annotations.Operation; 16 import io.swagger.v3.oas.annotations.Operation;
22 import io.swagger.v3.oas.annotations.Parameter; 17 import io.swagger.v3.oas.annotations.Parameter;
  18 +import io.swagger.v3.oas.annotations.Parameters;
23 import io.swagger.v3.oas.annotations.tags.Tag; 19 import io.swagger.v3.oas.annotations.tags.Tag;
  20 +import org.mapstruct.ap.internal.util.Collections;
24 import org.springframework.security.access.prepost.PreAuthorize; 21 import org.springframework.security.access.prepost.PreAuthorize;
25 -import org.springframework.util.CollectionUtils;  
26 import org.springframework.validation.annotation.Validated; 22 import org.springframework.validation.annotation.Validated;
27 import org.springframework.web.bind.annotation.*; 23 import org.springframework.web.bind.annotation.*;
28 24
@@ -30,17 +26,17 @@ import javax.annotation.Resource; @@ -30,17 +26,17 @@ import javax.annotation.Resource;
30 import javax.servlet.http.HttpServletResponse; 26 import javax.servlet.http.HttpServletResponse;
31 import javax.validation.Valid; 27 import javax.validation.Valid;
32 import java.io.IOException; 28 import java.io.IOException;
33 -import java.util.Collections;  
34 import java.util.List; 29 import java.util.List;
35 import java.util.Map; 30 import java.util.Map;
36 -import java.util.Set; 31 +import java.util.stream.Stream;
37 32
38 -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;  
39 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 33 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
40 -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; 34 +import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
41 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; 35 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
  36 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap;
42 import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; 37 import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
43 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; 38 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
  39 +import static java.util.Collections.singletonList;
44 40
45 @Tag(name = "管理后台 - CRM 客户") 41 @Tag(name = "管理后台 - CRM 客户")
46 @RestController 42 @RestController
@@ -55,8 +51,6 @@ public class CrmCustomerController { @@ -55,8 +51,6 @@ public class CrmCustomerController {
55 private DeptApi deptApi; 51 private DeptApi deptApi;
56 @Resource 52 @Resource
57 private AdminUserApi adminUserApi; 53 private AdminUserApi adminUserApi;
58 - @Resource  
59 - private CrmPermissionService permissionService;  
60 54
61 @PostMapping("/create") 55 @PostMapping("/create")
62 @Operation(summary = "创建客户") 56 @Operation(summary = "创建客户")
@@ -92,73 +86,38 @@ public class CrmCustomerController { @@ -92,73 +86,38 @@ public class CrmCustomerController {
92 if (customer == null) { 86 if (customer == null) {
93 return success(null); 87 return success(null);
94 } 88 }
95 -  
96 // 2. 拼接数据 89 // 2. 拼接数据
97 - // 2.1 获取负责人  
98 - List<CrmPermissionDO> ownerList = permissionService.getPermissionByBizTypeAndBizIdsAndLevel(  
99 - CrmBizTypeEnum.CRM_CUSTOMER.getType(), Collections.singletonList(customer.getId()),  
100 - CrmPermissionLevelEnum.OWNER.getLevel());  
101 - Map<Long, CrmPermissionDO> ownerMap = convertMap(ownerList, CrmPermissionDO::getBizId);  
102 - // 2.2 获取负责人详情  
103 - Set<Long> userIds = convertSet(ownerList, CrmPermissionDO::getUserId);  
104 - userIds.add(Long.parseLong(customer.getCreator())); // 加入创建者  
105 - List<AdminUserRespDTO> userList = adminUserApi.getUserList(userIds);  
106 - Map<Long, AdminUserRespDTO> userMap = convertMap(userList, AdminUserRespDTO::getId);  
107 - // 2.3 获取部门详情  
108 - Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userList, AdminUserRespDTO::getDeptId));  
109 - return success(CrmCustomerConvert.INSTANCE.convert(customer, ownerMap, userMap, deptMap)); 90 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
  91 + Collections.asSet(Long.valueOf(customer.getCreator()), customer.getOwnerUserId()));
  92 + Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
  93 + return success(CrmCustomerConvert.INSTANCE.convert(customer, userMap, deptMap));
110 } 94 }
111 95
112 - // TODO @puhui999:可以在 CrmCustomerPageReqVO 里面加个 pool 参数,为 true 时,代表来自公海客户的分页  
113 @GetMapping("/page") 96 @GetMapping("/page")
114 @Operation(summary = "获得客户分页") 97 @Operation(summary = "获得客户分页")
115 @PreAuthorize("@ss.hasPermission('crm:customer:query')") 98 @PreAuthorize("@ss.hasPermission('crm:customer:query')")
116 public CommonResult<PageResult<CrmCustomerRespVO>> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { 99 public CommonResult<PageResult<CrmCustomerRespVO>> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) {
  100 + // 1. 查询客户分页
117 PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(pageVO, getLoginUserId()); 101 PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(pageVO, getLoginUserId());
118 if (CollUtil.isEmpty(pageResult.getList())) { 102 if (CollUtil.isEmpty(pageResult.getList())) {
119 return success(PageResult.empty(pageResult.getTotal())); 103 return success(PageResult.empty(pageResult.getTotal()));
120 } 104 }
121 - // 拼接数据  
122 - // TODO @puhui999:这块的拼接逻辑,可以和 convertPage 合并下;  
123 -// Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(  
124 -// convertSetByFlatMap(pageResult.getList(), user -> Stream.of(NumberUtil.parseLong(user.getCreator()), user.getOwnerUserId())));  
125 -// Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(  
126 -// convertSet(userMap.values(), AdminUserRespDTO::getDeptId));  
127 - return convertPage(customerService.getCustomerPage(pageVO, getLoginUserId()));  
128 - }  
129 -  
130 - // TODO @puhui999:  
131 - @GetMapping("/pool-page")  
132 - @Operation(summary = "获得公海客户分页")  
133 - @PreAuthorize("@ss.hasPermission('crm:customer:query')")  
134 - public CommonResult<PageResult<CrmCustomerRespVO>> getPoolCustomerPage(@Valid CrmCustomerPageReqVO pageVO) {  
135 - return convertPage(customerService.getCustomerPage(pageVO, CrmPermissionDO.POOL_USER_ID));  
136 - }  
137 105
138 - private CommonResult<PageResult<CrmCustomerRespVO>> convertPage(PageResult<CrmCustomerDO> pageResult) {  
139 // 2. 拼接数据 106 // 2. 拼接数据
140 - Set<Long> ids = convertSet(pageResult.getList(), CrmCustomerDO::getId);  
141 - // 2.1 获取负责人  
142 - List<CrmPermissionDO> ownerList = permissionService.getPermissionByBizTypeAndBizIdsAndLevel(  
143 - CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, CrmPermissionLevelEnum.OWNER.getLevel());  
144 - Map<Long, CrmPermissionDO> ownerMap = convertMap(ownerList, CrmPermissionDO::getBizId);  
145 - // 2.2 获取负责人详情  
146 - Set<Long> userIds = convertSet(ownerList, CrmPermissionDO::getUserId);  
147 - userIds.addAll(convertSet(pageResult.getList(), item -> Long.parseLong(item.getCreator()))); // 加入创建者  
148 - List<AdminUserRespDTO> userList = adminUserApi.getUserList(userIds);  
149 - Map<Long, AdminUserRespDTO> userMap = convertMap(userList, AdminUserRespDTO::getId);  
150 - // 2.3 获取部门详情  
151 - Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userList, AdminUserRespDTO::getDeptId));  
152 - return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, ownerMap, userMap, deptMap)); 107 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
  108 + convertSetByFlatMap(pageResult.getList(), user -> Stream.of(Long.parseLong(user.getCreator()), user.getOwnerUserId())));
  109 + Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
  110 + return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap));
153 } 111 }
154 112
155 @GetMapping("/export-excel") 113 @GetMapping("/export-excel")
156 @Operation(summary = "导出客户 Excel") 114 @Operation(summary = "导出客户 Excel")
157 @PreAuthorize("@ss.hasPermission('crm:customer:export')") 115 @PreAuthorize("@ss.hasPermission('crm:customer:export')")
158 @OperateLog(type = EXPORT) 116 @OperateLog(type = EXPORT)
159 - public void exportCustomerExcel(@Valid CrmCustomerExportReqVO exportReqVO, 117 + public void exportCustomerExcel(@Valid CrmCustomerPageReqVO pageVO,
160 HttpServletResponse response) throws IOException { 118 HttpServletResponse response) throws IOException {
161 - List<CrmCustomerDO> list = customerService.getCustomerList(exportReqVO); 119 + pageVO.setPageSize(PAGE_SIZE_NONE); // 不分页
  120 + List<CrmCustomerDO> list = customerService.getCustomerPage(pageVO, getLoginUserId()).getList();
162 // 导出 Excel 121 // 导出 Excel
163 List<CrmCustomerExcelVO> datas = CrmCustomerConvert.INSTANCE.convertList02(list); 122 List<CrmCustomerExcelVO> datas = CrmCustomerConvert.INSTANCE.convertList02(list);
164 ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerExcelVO.class, datas); 123 ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerExcelVO.class, datas);
@@ -181,30 +140,48 @@ public class CrmCustomerController { @@ -181,30 +140,48 @@ public class CrmCustomerController {
181 return success(true); 140 return success(true);
182 } 141 }
183 142
  143 + // ==================== 公海相关操作 ====================
  144 +
  145 + @PutMapping("/put-pool")
  146 + @Operation(summary = "数据放入公海")
  147 + @Parameter(name = "id", description = "客户编号", required = true, example = "1024")
  148 + @PreAuthorize("@ss.hasPermission('crm:customer:update')")
  149 + public CommonResult<Boolean> putCustomerPool(@RequestParam("id") Long id) {
  150 + customerService.putCustomerPool(id);
  151 + return success(true);
  152 + }
  153 +
184 @PutMapping("/receive") 154 @PutMapping("/receive")
185 @Operation(summary = "领取公海客户") 155 @Operation(summary = "领取公海客户")
186 - // TODO @xiaqing:1)receiveCustomer 方法名字;2)cIds 改成 ids,要加下 @RequestParam,还有 swagger 注解;3)参数非空,使用 validator 校验;4)返回 true 即可; 156 + @Parameter(name = "ids", description = "编号数组", required = true, example = "1,2,3")
187 @PreAuthorize("@ss.hasPermission('crm:customer:receive')") 157 @PreAuthorize("@ss.hasPermission('crm:customer:receive')")
188 - public CommonResult<String> receiveByIds(List<Long> cIds){  
189 - // 判断是否为空  
190 - if(CollectionUtils.isEmpty(cIds))  
191 - return error(GlobalErrorCodeConstants.BAD_REQUEST.getCode(),GlobalErrorCodeConstants.BAD_REQUEST.getMsg());  
192 - // 领取公海任务  
193 - // TODO @xiaqing:userid,通过 controller 传递给 service,不要在 service 里面获取,无状态  
194 - customerService.receive(cIds);  
195 - return success("领取成功"); 158 + public CommonResult<Boolean> receiveCustomer(@RequestParam(value = "ids") List<Long> ids) {
  159 + customerService.receiveCustomer(ids, getLoginUserId());
  160 + return success(true);
196 } 161 }
197 162
198 - // TODO @xiaqing:1)distributeCustomer 方法名;2)cIds 同上;3)参数校验,同上;4)ownerId 改成 ownerUserId,和别的模块统一;5)返回 true 即可;  
199 - @PutMapping("/distributeByIds") 163 + @PutMapping("/distribute")
200 @Operation(summary = "分配公海给对应负责人") 164 @Operation(summary = "分配公海给对应负责人")
201 - @PreAuthorize("@ss.hasPermission('crm:customer:distributeByIds')")  
202 - public CommonResult<String> distributeByIds(Long ownerId,List<Long>cIds){  
203 - //判断参数不能为空  
204 - if(ownerId==null || CollectionUtils.isEmpty(cIds))  
205 - return error(GlobalErrorCodeConstants.BAD_REQUEST.getCode(),GlobalErrorCodeConstants.BAD_REQUEST.getMsg());  
206 - customerService.distributeByIds(cIds,ownerId);  
207 - return success("分配成功"); 165 + @Parameters({
  166 + @Parameter(name = "ids", description = "客户编号数组", required = true, example = "1,2,3"),
  167 + @Parameter(name = "ownerUserId", description = "分配的负责人编号", required = true, example = "12345")
  168 + })
  169 + @PreAuthorize("@ss.hasPermission('crm:customer:distribute')")
  170 + public CommonResult<Boolean> distributeCustomer(@RequestParam(value = "ids") List<Long> ids,
  171 + @RequestParam(value = "ownerUserId") Long ownerUserId) {
  172 + // 领取公海数据
  173 + customerService.receiveCustomer(ids, ownerUserId);
  174 + return success(true);
  175 + }
  176 +
  177 + // TODO 芋艿:这个接口要调整下
  178 + @GetMapping("/query-all-list")
  179 + @Operation(summary = "查询客户列表")
  180 + @PreAuthorize("@ss.hasPermission('crm:customer:all')")
  181 + public CommonResult<List<CrmCustomerQueryAllRespVO>> queryAll(){
  182 + List<CrmCustomerDO> crmCustomerDOList = customerService.getCustomerList();
  183 + List<CrmCustomerQueryAllRespVO> data = CrmCustomerConvert.INSTANCE.convertQueryAll(crmCustomerDOList);
  184 + return success(data);
208 } 185 }
209 186
210 } 187 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerLimitConfigController.java
@@ -3,13 +3,13 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer; @@ -3,13 +3,13 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer;
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 4 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigCreateReqVO;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigPageReqVO;  
8 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigRespVO;  
9 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigUpdateReqVO; 6 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO;
  8 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO;
  9 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO;
10 import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert; 10 import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert;
11 -import cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig.CrmCustomerLimitConfigDO;  
12 -import cn.iocoder.yudao.module.crm.service.customerlimitconfig.CrmCustomerLimitConfigService; 11 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
  12 +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigService;
13 import cn.iocoder.yudao.module.system.api.dept.DeptApi; 13 import cn.iocoder.yudao.module.system.api.dept.DeptApi;
14 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; 14 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
15 import cn.iocoder.yudao.module.system.api.user.AdminUserApi; 15 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
@@ -29,7 +29,7 @@ import java.util.Map; @@ -29,7 +29,7 @@ import java.util.Map;
29 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 29 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
30 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; 30 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap;
31 31
32 -@Tag(name = "管理后台 - 客户限制配置") 32 +@Tag(name = "管理后台 - CRM 客户限制配置")
33 @RestController 33 @RestController
34 @RequestMapping("/crm/customer-limit-config") 34 @RequestMapping("/crm/customer-limit-config")
35 @Validated 35 @Validated
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerPoolConfigController.java
1 package cn.iocoder.yudao.module.crm.controller.admin.customer; 1 package cn.iocoder.yudao.module.crm.controller.admin.customer;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPoolConfigRespVO;  
5 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPoolConfigUpdateReqVO; 4 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigRespVO;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO;
6 import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; 6 import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert;
7 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; 7 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
8 import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService; 8 import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService;
@@ -34,12 +34,11 @@ public class CrmCustomerPoolConfigController { @@ -34,12 +34,11 @@ public class CrmCustomerPoolConfigController {
34 return success(CrmCustomerConvert.INSTANCE.convert(customerPoolConfig)); 34 return success(CrmCustomerConvert.INSTANCE.convert(customerPoolConfig));
35 } 35 }
36 36
37 - // TODO @wanwan:这个请求,搞成 save 哈;  
38 - @PutMapping("/update") 37 + @PutMapping("/save")
39 @Operation(summary = "更新客户公海规则设置") 38 @Operation(summary = "更新客户公海规则设置")
40 @PreAuthorize("@ss.hasPermission('crm:customer-pool-config:update')") 39 @PreAuthorize("@ss.hasPermission('crm:customer-pool-config:update')")
41 - public CommonResult<Boolean> updateCustomerPoolConfig(@Valid @RequestBody CrmCustomerPoolConfigUpdateReqVO updateReqVO) {  
42 - customerPoolConfigService.updateCustomerPoolConfig(updateReqVO); 40 + public CommonResult<Boolean> saveCustomerPoolConfig(@Valid @RequestBody CrmCustomerPoolConfigSaveReqVO updateReqVO) {
  41 + customerPoolConfigService.saveCustomerPoolConfig(updateReqVO);
43 return success(true); 42 return success(true);
44 } 43 }
45 44
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -  
6 -// TODO 芋艿:导出最后做,等基本确认的差不多之后;  
7 -@Schema(description = "管理后台 - CRM 客户 Excel 导出 Request VO,参数和 CrmCustomerPageReqVO 是一致的")  
8 -@Data  
9 -public class CrmCustomerExportReqVO {  
10 -  
11 - @Schema(description = "客户名称", example = "赵六")  
12 - private String name;  
13 -  
14 - @Schema(description = "手机", example = "18000000000")  
15 - private String mobile;  
16 -  
17 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java
1 package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; 1 package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageParam; 3 import cn.iocoder.yudao.framework.common.pojo.PageParam;
4 -import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerSceneEnum; 4 +import cn.iocoder.yudao.module.crm.enums.common.CrmSceneEnum;
5 import io.swagger.v3.oas.annotations.media.Schema; 5 import io.swagger.v3.oas.annotations.media.Schema;
6 import lombok.Data; 6 import lombok.Data;
7 import lombok.EqualsAndHashCode; 7 import lombok.EqualsAndHashCode;
8 import lombok.ToString; 8 import lombok.ToString;
9 9
  10 +import javax.validation.constraints.NotNull;
  11 +
10 @Schema(description = "管理后台 - CRM 客户分页 Request VO") 12 @Schema(description = "管理后台 - CRM 客户分页 Request VO")
11 @Data 13 @Data
12 @EqualsAndHashCode(callSuper = true) 14 @EqualsAndHashCode(callSuper = true)
@@ -31,9 +33,13 @@ public class CrmCustomerPageReqVO extends PageParam { @@ -31,9 +33,13 @@ public class CrmCustomerPageReqVO extends PageParam {
31 /** 33 /**
32 * 场景类型 34 * 场景类型
33 * 35 *
34 - * 关联 {@link CrmCustomerSceneEnum} 36 + * 关联 {@link CrmSceneEnum}
35 */ 37 */
36 @Schema(description = "场景类型", example = "1") 38 @Schema(description = "场景类型", example = "1")
37 private Integer sceneType; 39 private Integer sceneType;
38 40
  41 + @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
  42 + @NotNull(message = "是否为公海数据不能为空")
  43 + private Boolean pool;
  44 +
39 } 45 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPoolConfigUpdateReqVO.java deleted
1 -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString;  
7 -  
8 -@Schema(description = "管理后台 - CRM 客户更新 Request VO")  
9 -@Data  
10 -@EqualsAndHashCode(callSuper = true)  
11 -@ToString(callSuper = true)  
12 -public class CrmCustomerPoolConfigUpdateReqVO extends CrmCustomerPoolConfigBaseVO {  
13 -  
14 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerQueryAllRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +
  6 +// TODO 芋艿:这块要统一下;
  7 +@Schema(description = "管理后台 - CRM 全部客户 Response VO")
  8 +@Data
  9 +public class CrmCustomerQueryAllRespVO{
  10 +
  11 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
  12 + private Long id;
  13 +
  14 + @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
  15 + private String name;
  16 +
  17 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerTransferReqVO.java
1 package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; 1 package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
2 2
3 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 3 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
4 import io.swagger.v3.oas.annotations.media.Schema; 4 import io.swagger.v3.oas.annotations.media.Schema;
5 import lombok.Data; 5 import lombok.Data;
6 6
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerLimitConfigBaseVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigBaseVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig;
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 4 import lombok.Data;
@@ -6,7 +6,6 @@ import lombok.Data; @@ -6,7 +6,6 @@ import lombok.Data;
6 import javax.validation.constraints.NotNull; 6 import javax.validation.constraints.NotNull;
7 import java.util.List; 7 import java.util.List;
8 8
9 -// TODO @wanwan:vo 下,可以新建一个 limitconfig,放它的 vo;  
10 /** 9 /**
11 * 客户限制配置 Base VO,提供给添加、修改、详细的子 VO 使用 10 * 客户限制配置 Base VO,提供给添加、修改、详细的子 VO 使用
12 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 11 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerLimitConfigCreateReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigCreateReqVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig;
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 4 import lombok.Data;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerLimitConfigPageReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigPageReqVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageParam; 3 import cn.iocoder.yudao.framework.common.pojo.PageParam;
4 import io.swagger.v3.oas.annotations.media.Schema; 4 import io.swagger.v3.oas.annotations.media.Schema;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerLimitConfigRespVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig;
2 2
  3 +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
  4 +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
3 import io.swagger.v3.oas.annotations.media.Schema; 5 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 6 import lombok.Data;
5 import lombok.EqualsAndHashCode; 7 import lombok.EqualsAndHashCode;
@@ -18,10 +20,10 @@ public class CrmCustomerLimitConfigRespVO extends CrmCustomerLimitConfigBaseVO { @@ -18,10 +20,10 @@ public class CrmCustomerLimitConfigRespVO extends CrmCustomerLimitConfigBaseVO {
18 private Long id; 20 private Long id;
19 21
20 @Schema(description = "规则适用人群名称") 22 @Schema(description = "规则适用人群名称")
21 - private String userNames; 23 + private List<AdminUserRespDTO> users;
22 24
23 @Schema(description = "规则适用部门名称") 25 @Schema(description = "规则适用部门名称")
24 - private String deptNames; 26 + private List<DeptRespDTO> depts;
25 27
26 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) 28 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
27 private LocalDateTime createTime; 29 private LocalDateTime createTime;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerLimitConfigUpdateReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigUpdateReqVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig;
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 4 import lombok.Data;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPoolConfigBaseVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigBaseVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig;
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 4 import lombok.Data;
@@ -12,7 +12,6 @@ import javax.validation.constraints.NotNull; @@ -12,7 +12,6 @@ import javax.validation.constraints.NotNull;
12 @Data 12 @Data
13 public class CrmCustomerPoolConfigBaseVO { 13 public class CrmCustomerPoolConfigBaseVO {
14 14
15 - // TODO @wanwan:参数校验  
16 @Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") 15 @Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
17 @NotNull(message = "是否启用客户公海不能为空") 16 @NotNull(message = "是否启用客户公海不能为空")
18 private Boolean enabled; 17 private Boolean enabled;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPoolConfigRespVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigRespVO.java
1 -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; 1 +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig;
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 4 import lombok.Data;
5 import lombok.EqualsAndHashCode; 5 import lombok.EqualsAndHashCode;
6 import lombok.ToString; 6 import lombok.ToString;
7 7
8 -// TODO @wanwan:vo 下,可以新建一个 poolconfig,放它的 vo;  
9 @Schema(description = "管理后台 - CRM 客户公海规则 Response VO") 8 @Schema(description = "管理后台 - CRM 客户公海规则 Response VO")
10 @Data 9 @Data
11 @EqualsAndHashCode(callSuper = true) 10 @EqualsAndHashCode(callSuper = true)
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig;
  2 +
  3 +import cn.hutool.core.util.BooleanUtil;
  4 +import cn.hutool.core.util.ObjectUtil;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import lombok.Data;
  7 +import lombok.EqualsAndHashCode;
  8 +import lombok.ToString;
  9 +
  10 +import javax.validation.constraints.AssertTrue;
  11 +import java.util.Objects;
  12 +
  13 +@Schema(description = "管理后台 - CRM 客户公海配置的保存 Request VO")
  14 +@Data
  15 +@EqualsAndHashCode(callSuper = true)
  16 +@ToString(callSuper = true)
  17 +public class CrmCustomerPoolConfigSaveReqVO extends CrmCustomerPoolConfigBaseVO {
  18 +
  19 + // TODO @wanwan:AssertTrue 必须 is 开头哈;注意需要 json 忽略下,避免被序列化;
  20 + @AssertTrue(message = "客户公海规则设置不正确")
  21 + // TODO @wanwan:这个方法,是不是拆成 2 个,一个校验 contactExpireDays、一个校验 dealExpireDays;
  22 + public boolean poolEnableValid() {
  23 + if (!BooleanUtil.isTrue(getEnabled())) {
  24 + return true;
  25 + }
  26 + return ObjectUtil.isAllNotEmpty(getContactExpireDays(), getDealExpireDays());
  27 + }
  28 +
  29 + @AssertTrue(message = "客户公海规则设置不正确")
  30 + // TODO @wanwan:这个方法,是不是改成 isNotifyDaysValid() 更好点?本质校验的是 notifyDays 是否为空
  31 + public boolean notifyEnableValid() {
  32 + if (!BooleanUtil.isTrue(getNotifyEnabled())) {
  33 + return true;
  34 + }
  35 + return Objects.nonNull(getNotifyDays());
  36 + }
  37 +
  38 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.http
1 ### 请求 /add 1 ### 请求 /add
2 -PUT {{baseUrl}}/crm/permission/add 2 +POST {{baseUrl}}/crm/permission/create
3 Content-Type: application/json 3 Content-Type: application/json
4 Authorization: Bearer {{token}} 4 Authorization: Bearer {{token}}
5 tenant-id: {{adminTenentId}} 5 tenant-id: {{adminTenentId}}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java
1 package cn.iocoder.yudao.module.crm.controller.admin.permission; 1 package cn.iocoder.yudao.module.crm.controller.admin.permission;
2 2
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 -import cn.hutool.core.util.ObjUtil;  
5 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 4 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  5 +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
6 import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionCreateReqVO; 6 import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionCreateReqVO;
7 import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionRespVO; 7 import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionRespVO;
8 import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO; 8 import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO;
9 import cn.iocoder.yudao.module.crm.convert.permission.CrmPermissionConvert; 9 import cn.iocoder.yudao.module.crm.convert.permission.CrmPermissionConvert;
10 import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; 10 import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
11 import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; 11 import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
12 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;  
13 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 12 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
14 import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; 13 import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
15 import cn.iocoder.yudao.module.system.api.dept.DeptApi; 14 import cn.iocoder.yudao.module.system.api.dept.DeptApi;
16 import cn.iocoder.yudao.module.system.api.dept.PostApi; 15 import cn.iocoder.yudao.module.system.api.dept.PostApi;
@@ -29,17 +28,12 @@ import org.springframework.web.bind.annotation.*; @@ -29,17 +28,12 @@ import org.springframework.web.bind.annotation.*;
29 import javax.annotation.Resource; 28 import javax.annotation.Resource;
30 import javax.validation.Valid; 29 import javax.validation.Valid;
31 import java.util.*; 30 import java.util.*;
32 -import java.util.function.Predicate;  
33 -import java.util.stream.Collectors;  
34 31
35 -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;  
36 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 32 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
37 -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch;  
38 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; 33 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
39 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; 34 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
40 -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSION_NOT_EXISTS;  
41 35
42 -@Tag(name = "管理后台 - CRM 数据权限(数据团队成员操作)") 36 +@Tag(name = "管理后台 - CRM 数据权限")
43 @RestController 37 @RestController
44 @RequestMapping("/crm/permission") 38 @RequestMapping("/crm/permission")
45 @Validated 39 @Validated
@@ -55,87 +49,45 @@ public class CrmPermissionController { @@ -55,87 +49,45 @@ public class CrmPermissionController {
55 @Resource 49 @Resource
56 private PostApi postApi; 50 private PostApi postApi;
57 51
58 - // TODO @puhui999:保持统一,create 噢;然后是 PostMapping  
59 - @PutMapping("/add")  
60 - @Operation(summary = "添加团队成员") 52 + @PostMapping("/create")
  53 + @Operation(summary = "创建数据权限")
61 @PreAuthorize("@ss.hasPermission('crm:permission:create')") 54 @PreAuthorize("@ss.hasPermission('crm:permission:create')")
62 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PERMISSION, bizTypeValue = "#reqVO.bizType", bizId = "#reqVO.bizId",  
63 - level = CrmPermissionLevelEnum.OWNER) 55 + @CrmPermission(bizTypeValue = "#reqVO.bizType", bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER)
64 public CommonResult<Boolean> addPermission(@Valid @RequestBody CrmPermissionCreateReqVO reqVO) { 56 public CommonResult<Boolean> addPermission(@Valid @RequestBody CrmPermissionCreateReqVO reqVO) {
65 permissionService.createPermission(CrmPermissionConvert.INSTANCE.convert(reqVO)); 57 permissionService.createPermission(CrmPermissionConvert.INSTANCE.convert(reqVO));
66 return success(true); 58 return success(true);
67 } 59 }
68 60
69 - // TODO @puhui999:领取公海客户,是不是放到客户那更合适哈?  
70 - @PutMapping("/receive")  
71 - @Operation(summary = "领取公海数据")  
72 - @PreAuthorize("@ss.hasPermission('crm:permission:update')")  
73 - public CommonResult<Boolean> receive(@RequestParam("bizType") Integer bizType, @RequestParam("bizId") Long bizId) {  
74 - permissionService.receiveBiz(bizType, bizId, getLoginUserId());  
75 - return success(true);  
76 - }  
77 -  
78 - // TODO @puhui999:是不是放到客户那更合适哈?  
79 - @PutMapping("/put-pool")  
80 - @Operation(summary = "数据放入公海")  
81 - @PreAuthorize("@ss.hasPermission('crm:permission:update')")  
82 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PERMISSION, bizTypeValue = "#bizType", bizId = "#bizId"  
83 - , level = CrmPermissionLevelEnum.OWNER)  
84 - public CommonResult<Boolean> putPool(@RequestParam(value = "bizType") Integer bizType, @RequestParam("bizId") Long bizId) {  
85 - permissionService.putPool(bizType, bizId, getLoginUserId());  
86 - return success(true);  
87 - }  
88 -  
89 @PutMapping("/update") 61 @PutMapping("/update")
90 - @Operation(summary = "编辑团队成员权限") 62 + @Operation(summary = "编辑数据权限")
91 @PreAuthorize("@ss.hasPermission('crm:permission:update')") 63 @PreAuthorize("@ss.hasPermission('crm:permission:update')")
92 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PERMISSION, bizTypeValue = "#updateReqVO.bizType", bizId = "#updateReqVO.bizId" 64 + @CrmPermission(bizTypeValue = "#updateReqVO.bizType", bizId = "#updateReqVO.bizId"
93 , level = CrmPermissionLevelEnum.OWNER) 65 , level = CrmPermissionLevelEnum.OWNER)
94 public CommonResult<Boolean> updatePermission(@Valid @RequestBody CrmPermissionUpdateReqVO updateReqVO) { 66 public CommonResult<Boolean> updatePermission(@Valid @RequestBody CrmPermissionUpdateReqVO updateReqVO) {
95 permissionService.updatePermission(updateReqVO); 67 permissionService.updatePermission(updateReqVO);
96 return success(true); 68 return success(true);
97 } 69 }
98 70
99 - // TODO @puhui999:bizType 和 bizId 是不是不用啦;因为参数校验需要 bizType 和 bizId,可以先查询下,在直接调用方法;不一定都要注解哈;  
100 @DeleteMapping("/delete") 71 @DeleteMapping("/delete")
101 - @Operation(summary = "移除团队成员")  
102 - @Parameters({  
103 - @Parameter(name = "bizType", description = "CRM 类型", required = true, example = "2"),  
104 - @Parameter(name = "bizId", description = "CRM 类型数据编号", required = true, example = "1024"),  
105 - @Parameter(name = "ids", description = "团队成员编号", required = true, example = "1024")  
106 - }) 72 + @Operation(summary = "删除数据权限")
  73 + @Parameter(name = "ids", description = "数据权限编号", required = true, example = "1024")
107 @PreAuthorize("@ss.hasPermission('crm:permission:delete')") 74 @PreAuthorize("@ss.hasPermission('crm:permission:delete')")
108 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PERMISSION, bizTypeValue = "#bizType", bizId = "#bizId"  
109 - , level = CrmPermissionLevelEnum.OWNER) // 为了校验权限请求必须带上 bizType 和 bizId  
110 - public CommonResult<Boolean> deletePermission(@RequestParam("bizType") Integer bizType,  
111 - @RequestParam("bizId") Long bizId,  
112 - @RequestParam("ids") Collection<Long> ids) {  
113 - permissionService.deletePermission(ids); 75 + public CommonResult<Boolean> deletePermission(@RequestParam("ids") Collection<Long> ids) {
  76 + permissionService.deletePermissionBatch(ids, getLoginUserId());
114 return success(true); 77 return success(true);
115 } 78 }
116 79
117 - // TODO @puhui999:deleteSelfPermission;尽量归成 crud 这样的操作哈;  
118 - @DeleteMapping("/quit-team")  
119 - @Operation(summary = "退出团队")  
120 - @Parameters({  
121 - // TODO @puhui999:这个可以拿出来,不用包在 @Parameters 里,在只有一个参数时哈;  
122 - @Parameter(name = "id", description = "团队成员编号", required = true, example = "1024")  
123 - }) 80 + @DeleteMapping("/delete-self")
  81 + @Operation(summary = "删除自己的数据权限")
  82 + @Parameter(name = "id", description = "数据权限编号", required = true, example = "1024")
124 @PreAuthorize("@ss.hasPermission('crm:permission:delete')") 83 @PreAuthorize("@ss.hasPermission('crm:permission:delete')")
125 - public CommonResult<Boolean> deletePermission(@RequestParam("id") Long id) {  
126 - // 校验数据存在且是自己  
127 - CrmPermissionDO permission = permissionService.getPermissionByIdAndUserId(id, getLoginUserId());  
128 - if (permission == null) {  
129 - throw exception(CRM_PERMISSION_NOT_EXISTS);  
130 - }  
131 -  
132 - // 删除  
133 - permissionService.deletePermission(Collections.singletonList(id)); 84 + public CommonResult<Boolean> deleteSelfPermission(@RequestParam("id") Long id) {
  85 + permissionService.deleteSelfPermission(id, getLoginUserId());
134 return success(true); 86 return success(true);
135 } 87 }
136 88
137 @GetMapping("/list") 89 @GetMapping("/list")
138 - @Operation(summary = "获取团队成员") 90 + @Operation(summary = "获得数据权限列表")
139 @Parameters({ 91 @Parameters({
140 @Parameter(name = "bizType", description = "CRM 类型", required = true, example = "2"), 92 @Parameter(name = "bizType", description = "CRM 类型", required = true, example = "2"),
141 @Parameter(name = "bizId", description = "CRM 类型数据编号", required = true, example = "1024") 93 @Parameter(name = "bizId", description = "CRM 类型数据编号", required = true, example = "1024")
@@ -143,23 +95,15 @@ public class CrmPermissionController { @@ -143,23 +95,15 @@ public class CrmPermissionController {
143 @PreAuthorize("@ss.hasPermission('crm:permission:query')") 95 @PreAuthorize("@ss.hasPermission('crm:permission:query')")
144 public CommonResult<List<CrmPermissionRespVO>> getPermissionList(@RequestParam("bizType") Integer bizType, 96 public CommonResult<List<CrmPermissionRespVO>> getPermissionList(@RequestParam("bizType") Integer bizType,
145 @RequestParam("bizId") Long bizId) { 97 @RequestParam("bizId") Long bizId) {
146 - List<CrmPermissionDO> permission = permissionService.getPermissionByBizTypeAndBizId(bizType, bizId); 98 + List<CrmPermissionDO> permission = permissionService.getPermissionListByBiz(bizType, bizId);
147 if (CollUtil.isEmpty(permission)) { 99 if (CollUtil.isEmpty(permission)) {
148 return success(Collections.emptyList()); 100 return success(Collections.emptyList());
149 } 101 }
150 - // TODO @puhui999:池子的逻辑;  
151 - // 判断是否是公海数据  
152 - // TODO @puhui999:这段逻辑,可以删除么?  
153 - Predicate<CrmPermissionDO> filter = item -> ObjUtil.equal(item.getUserId(), CrmPermissionDO.POOL_USER_ID);  
154 - if (anyMatch(permission, filter)) {  
155 - permission.removeIf(filter); // 排除  
156 - }  
157 102
158 // 拼接数据 103 // 拼接数据
159 List<AdminUserRespDTO> userList = adminUserApi.getUserList(convertSet(permission, CrmPermissionDO::getUserId)); 104 List<AdminUserRespDTO> userList = adminUserApi.getUserList(convertSet(permission, CrmPermissionDO::getUserId));
160 Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userList, AdminUserRespDTO::getDeptId)); 105 Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userList, AdminUserRespDTO::getDeptId));
161 - // TODO @puhui999:CollectionUtils.convertSetByFlatMap() 看看可以不  
162 - Set<Long> postIds = userList.stream().flatMap(item -> item.getPostIds().stream()).collect(Collectors.toSet()); 106 + Set<Long> postIds = CollectionUtils.convertSetByFlatMap(userList, AdminUserRespDTO::getPostIds, Collection::stream);
163 Map<Long, PostRespDTO> postMap = postApi.getPostMap(postIds); 107 Map<Long, PostRespDTO> postMap = postApi.getPostMap(postIds);
164 return success(CrmPermissionConvert.INSTANCE.convert(permission, userList, deptMap, postMap)); 108 return success(CrmPermissionConvert.INSTANCE.convert(permission, userList, deptMap, postMap));
165 } 109 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionBaseVO.java
1 package cn.iocoder.yudao.module.crm.controller.admin.permission.vo; 1 package cn.iocoder.yudao.module.crm.controller.admin.permission.vo;
2 2
3 import cn.iocoder.yudao.framework.common.validation.InEnum; 3 import cn.iocoder.yudao.framework.common.validation.InEnum;
4 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;  
5 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 4 +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
  5 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
6 import io.swagger.v3.oas.annotations.media.Schema; 6 import io.swagger.v3.oas.annotations.media.Schema;
7 import lombok.Data; 7 import lombok.Data;
8 8
9 import javax.validation.constraints.NotNull; 9 import javax.validation.constraints.NotNull;
10 10
11 /** 11 /**
12 - * 数据权限(团队成员) Base VO,提供给添加、修改、详细的子 VO 使用 12 + * 数据权限 Base VO,提供给添加、修改、详细的子 VO 使用
13 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 13 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
14 * 14 *
15 * @author HUIHUI 15 * @author HUIHUI
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionRespVO.java
@@ -6,7 +6,7 @@ import lombok.Data; @@ -6,7 +6,7 @@ import lombok.Data;
6 import java.time.LocalDateTime; 6 import java.time.LocalDateTime;
7 import java.util.Set; 7 import java.util.Set;
8 8
9 -@Schema(description = "管理后台 - CRM 数据权限(团队成员) Response VO") 9 +@Schema(description = "管理后台 - CRM 数据权限 Response VO")
10 @Data 10 @Data
11 public class CrmPermissionRespVO extends CrmPermissionBaseVO { 11 public class CrmPermissionRespVO extends CrmPermissionBaseVO {
12 12
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionUpdateReqVO.java
1 package cn.iocoder.yudao.module.crm.controller.admin.permission.vo; 1 package cn.iocoder.yudao.module.crm.controller.admin.permission.vo;
2 2
3 import cn.iocoder.yudao.framework.common.validation.InEnum; 3 import cn.iocoder.yudao.framework.common.validation.InEnum;
4 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;  
5 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 4 +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
  5 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
6 import io.swagger.v3.oas.annotations.media.Schema; 6 import io.swagger.v3.oas.annotations.media.Schema;
7 import lombok.Data; 7 import lombok.Data;
8 8
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableBaseVO.java
1 package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; 1 package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
2 2
3 import cn.iocoder.yudao.framework.common.validation.InEnum; 3 import cn.iocoder.yudao.framework.common.validation.InEnum;
4 -import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; 4 +import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
5 import io.swagger.v3.oas.annotations.media.Schema; 5 import io.swagger.v3.oas.annotations.media.Schema;
6 import lombok.Data; 6 import lombok.Data;
7 import org.springframework.format.annotation.DateTimeFormat; 7 import org.springframework.format.annotation.DateTimeFormat;
@@ -34,7 +34,7 @@ public class CrmReceivableBaseVO { @@ -34,7 +34,7 @@ public class CrmReceivableBaseVO {
34 34
35 // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的 35 // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的
36 @Schema(description = "审批状态", example = "1") 36 @Schema(description = "审批状态", example = "1")
37 - @InEnum(AuditStatusEnum.class) 37 + @InEnum(CrmAuditStatusEnum.class)
38 private Integer checkStatus; 38 private Integer checkStatus;
39 39
40 @Schema(description = "回款日期") 40 @Schema(description = "回款日期")
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExcelVO.java
@@ -28,7 +28,7 @@ public class CrmReceivableExcelVO { @@ -28,7 +28,7 @@ public class CrmReceivableExcelVO {
28 private Long contractId; 28 private Long contractId;
29 29
30 @ExcelProperty(value = "审批状态", converter = DictConvert.class) 30 @ExcelProperty(value = "审批状态", converter = DictConvert.class)
31 - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_RECEIVABLE_CHECK_STATUS) 31 + @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_AUDIT_STATUS)
32 private Integer checkStatus; 32 private Integer checkStatus;
33 33
34 @ExcelProperty("工作流编号") 34 @ExcelProperty("工作流编号")
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanBaseVO.java
1 package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; 1 package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
2 2
3 import cn.iocoder.yudao.framework.common.validation.InEnum; 3 import cn.iocoder.yudao.framework.common.validation.InEnum;
4 -import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; 4 +import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
5 import io.swagger.v3.oas.annotations.media.Schema; 5 import io.swagger.v3.oas.annotations.media.Schema;
6 import lombok.Data; 6 import lombok.Data;
7 import org.springframework.format.annotation.DateTimeFormat; 7 import org.springframework.format.annotation.DateTimeFormat;
@@ -28,7 +28,7 @@ public class CrmReceivablePlanBaseVO { @@ -28,7 +28,7 @@ public class CrmReceivablePlanBaseVO {
28 private Integer status; 28 private Integer status;
29 29
30 @Schema(description = "审批状态", example = "1") 30 @Schema(description = "审批状态", example = "1")
31 - @InEnum(AuditStatusEnum.class) 31 + @InEnum(CrmAuditStatusEnum.class)
32 private Integer checkStatus; 32 private Integer checkStatus;
33 33
34 @Schema(description = "计划回款金额", example = "29675") 34 @Schema(description = "计划回款金额", example = "29675")
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExcelVO.java
@@ -31,7 +31,7 @@ public class CrmReceivablePlanExcelVO { @@ -31,7 +31,7 @@ public class CrmReceivablePlanExcelVO {
31 private Integer status; 31 private Integer status;
32 32
33 @ExcelProperty(value = "审批状态", converter = DictConvert.class) 33 @ExcelProperty(value = "审批状态", converter = DictConvert.class)
34 - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_RECEIVABLE_CHECK_STATUS) 34 + @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_AUDIT_STATUS)
35 private Integer checkStatus; 35 private Integer checkStatus;
36 36
37 //@ExcelProperty("工作流编号") 37 //@ExcelProperty("工作流编号")
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java
1 package cn.iocoder.yudao.module.crm.convert.business; 1 package cn.iocoder.yudao.module.crm.convert.business;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; 4 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
5 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; 5 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
  6 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
  7 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
  8 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
6 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; 9 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
7 import org.mapstruct.Mapper; 10 import org.mapstruct.Mapper;
8 import org.mapstruct.Mapping; 11 import org.mapstruct.Mapping;
@@ -10,6 +13,9 @@ import org.mapstruct.Mappings; @@ -10,6 +13,9 @@ import org.mapstruct.Mappings;
10 import org.mapstruct.factory.Mappers; 13 import org.mapstruct.factory.Mappers;
11 14
12 import java.util.List; 15 import java.util.List;
  16 +import java.util.Map;
  17 +
  18 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
13 19
14 /** 20 /**
15 * 商机 Convert 21 * 商机 Convert
@@ -37,4 +43,18 @@ public interface CrmBusinessConvert { @@ -37,4 +43,18 @@ public interface CrmBusinessConvert {
37 }) 43 })
38 CrmPermissionTransferReqBO convert(CrmBusinessTransferReqVO reqVO, Long userId); 44 CrmPermissionTransferReqBO convert(CrmBusinessTransferReqVO reqVO, Long userId);
39 45
  46 + default PageResult<CrmBusinessRespVO> convertPage(PageResult<CrmBusinessDO> page, List<CrmCustomerDO> customerList,
  47 + List<CrmBusinessStatusTypeDO> statusTypeList, List<CrmBusinessStatusDO> statusList) {
  48 + PageResult<CrmBusinessRespVO> result = convertPage(page);
  49 + // 拼接关联字段
  50 + Map<Long, String> customerMap = convertMap(customerList, CrmCustomerDO::getId, CrmCustomerDO::getName);
  51 + Map<Long, String> statusTypeMap = convertMap(statusTypeList, CrmBusinessStatusTypeDO::getId, CrmBusinessStatusTypeDO::getName);
  52 + Map<Long, String> statusMap = convertMap(statusList, CrmBusinessStatusDO::getId, CrmBusinessStatusDO::getName);
  53 + result.getList().forEach(type -> type
  54 + .setCustomerName(customerMap.get(type.getCustomerId()))
  55 + .setStatusTypeName(statusTypeMap.get(type.getStatusTypeId()))
  56 + .setStatusName(statusMap.get(type.getStatusId())));
  57 + return result;
  58 + }
  59 +
40 } 60 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatus/CrmBusinessStatusConvert.java
1 package cn.iocoder.yudao.module.crm.convert.businessstatus; 1 package cn.iocoder.yudao.module.crm.convert.businessstatus;
2 2
3 -import java.util.*;  
4 -  
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 - 4 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusRespVO;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO;
  6 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
7 import org.mapstruct.Mapper; 7 import org.mapstruct.Mapper;
8 import org.mapstruct.factory.Mappers; 8 import org.mapstruct.factory.Mappers;
9 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.*;  
10 -import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; 9 +
  10 +import java.util.List;
11 11
12 /** 12 /**
13 * 商机状态 Convert 13 * 商机状态 Convert
@@ -19,9 +19,7 @@ public interface CrmBusinessStatusConvert { @@ -19,9 +19,7 @@ public interface CrmBusinessStatusConvert {
19 19
20 CrmBusinessStatusConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusConvert.class); 20 CrmBusinessStatusConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusConvert.class);
21 21
22 - CrmBusinessStatusDO convert(CrmBusinessStatusCreateReqVO bean);  
23 -  
24 - CrmBusinessStatusDO convert(CrmBusinessStatusUpdateReqVO bean); 22 + CrmBusinessStatusDO convert(CrmBusinessStatusSaveReqVO bean);
25 23
26 CrmBusinessStatusRespVO convert(CrmBusinessStatusDO bean); 24 CrmBusinessStatusRespVO convert(CrmBusinessStatusDO bean);
27 25
@@ -29,6 +27,4 @@ public interface CrmBusinessStatusConvert { @@ -29,6 +27,4 @@ public interface CrmBusinessStatusConvert {
29 27
30 PageResult<CrmBusinessStatusRespVO> convertPage(PageResult<CrmBusinessStatusDO> page); 28 PageResult<CrmBusinessStatusRespVO> convertPage(PageResult<CrmBusinessStatusDO> page);
31 29
32 - List<CrmBusinessStatusExcelVO> convertList02(List<CrmBusinessStatusDO> list);  
33 -  
34 } 30 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatustype/CrmBusinessStatusTypeConvert.java
1 package cn.iocoder.yudao.module.crm.convert.businessstatustype; 1 package cn.iocoder.yudao.module.crm.convert.businessstatustype;
2 2
3 -import java.util.*;  
4 -  
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 - 4 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeRespVO;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO;
  6 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
  7 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
  8 +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
7 import org.mapstruct.Mapper; 9 import org.mapstruct.Mapper;
8 import org.mapstruct.factory.Mappers; 10 import org.mapstruct.factory.Mappers;
9 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.*;  
10 -import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; 11 +
  12 +import java.util.List;
  13 +import java.util.Map;
  14 +
  15 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
  16 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
11 17
12 /** 18 /**
13 * 商机状态类型 Convert 19 * 商机状态类型 Convert
@@ -19,16 +25,25 @@ public interface CrmBusinessStatusTypeConvert { @@ -19,16 +25,25 @@ public interface CrmBusinessStatusTypeConvert {
19 25
20 CrmBusinessStatusTypeConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusTypeConvert.class); 26 CrmBusinessStatusTypeConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusTypeConvert.class);
21 27
22 - CrmBusinessStatusTypeDO convert(CrmBusinessStatusTypeCreateReqVO bean);  
23 -  
24 - CrmBusinessStatusTypeDO convert(CrmBusinessStatusTypeUpdateReqVO bean); 28 + CrmBusinessStatusTypeDO convert(CrmBusinessStatusTypeSaveReqVO bean);
25 29
26 CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean); 30 CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean);
27 31
28 - List<CrmBusinessStatusTypeRespVO> convertList(List<CrmBusinessStatusTypeDO> list);  
29 -  
30 PageResult<CrmBusinessStatusTypeRespVO> convertPage(PageResult<CrmBusinessStatusTypeDO> page); 32 PageResult<CrmBusinessStatusTypeRespVO> convertPage(PageResult<CrmBusinessStatusTypeDO> page);
31 33
32 - List<CrmBusinessStatusTypeExcelVO> convertList02(List<CrmBusinessStatusTypeDO> list); 34 + default PageResult<CrmBusinessStatusTypeRespVO> convertPage(PageResult<CrmBusinessStatusTypeDO> page, List<DeptRespDTO> deptList) {
  35 + PageResult<CrmBusinessStatusTypeRespVO> pageResult = convertPage(page);
  36 + // 拼接关联字段
  37 + Map<Long, String> deptMap = convertMap(deptList, DeptRespDTO::getId, DeptRespDTO::getName);
  38 + pageResult.getList().forEach(type -> type.setDeptNames(convertList(type.getDeptIds(), deptMap::get)));
  39 + return pageResult;
  40 + }
  41 +
  42 + default CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean, List<CrmBusinessStatusDO> statusList) {
  43 + // TODO @ljlleo 可以链式赋值,简化成一行;
  44 + CrmBusinessStatusTypeRespVO result = convert(bean);
  45 + result.setStatusList(statusList);
  46 + return result;
  47 + }
33 48
34 } 49 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java
1 package cn.iocoder.yudao.module.crm.convert.contact; 1 package cn.iocoder.yudao.module.crm.convert.contact;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
4 import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; 5 import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
5 -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; 6 +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
  7 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
6 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; 8 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
  9 +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
7 import org.mapstruct.Mapper; 10 import org.mapstruct.Mapper;
8 import org.mapstruct.Mapping; 11 import org.mapstruct.Mapping;
9 import org.mapstruct.Mappings; 12 import org.mapstruct.Mappings;
10 import org.mapstruct.factory.Mappers; 13 import org.mapstruct.factory.Mappers;
11 14
12 import java.util.List; 15 import java.util.List;
  16 +import java.util.Map;
  17 +import java.util.stream.Collectors;
13 18
  19 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
  20 +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
  21 +
  22 +// TODO 芋艿:convert 后面在梳理下,略微有点乱
14 /** 23 /**
15 - * crm联系人 Convert 24 + * CRM 联系人 Convert
16 * 25 *
17 * @author 芋道源码 26 * @author 芋道源码
18 */ 27 */
@@ -21,19 +30,23 @@ public interface ContactConvert { @@ -21,19 +30,23 @@ public interface ContactConvert {
21 30
22 ContactConvert INSTANCE = Mappers.getMapper(ContactConvert.class); 31 ContactConvert INSTANCE = Mappers.getMapper(ContactConvert.class);
23 32
24 - ContactDO convert(ContactCreateReqVO bean); 33 + CrmContactDO convert(CrmContactCreateReqVO bean);
25 34
26 - ContactDO convert(ContactUpdateReqVO bean); 35 + CrmContactDO convert(CrmContactUpdateReqVO bean);
27 36
28 - ContactRespVO convert(ContactDO bean); 37 + CrmContactRespVO convert(CrmContactDO bean);
29 38
30 - List<ContactRespVO> convertList(List<ContactDO> list); 39 + List<CrmContactRespVO> convertList(List<CrmContactDO> list);
31 40
32 - PageResult<ContactRespVO> convertPage(PageResult<ContactDO> page); 41 + PageResult<CrmContactRespVO> convertPage(PageResult<CrmContactDO> page);
33 42
34 - List<ContactExcelVO> convertList02(List<ContactDO> list); 43 + default PageResult<CrmContactRespVO> convertPage(PageResult<CrmContactDO> pageResult, Map<Long, AdminUserRespDTO> userMap,
  44 + List<CrmCustomerDO> customerList, List<CrmContactDO> parentContactList) {
  45 + List<CrmContactRespVO> list = converList(pageResult.getList(), userMap, customerList, parentContactList);
  46 + return convertPage(pageResult).setList(list);
  47 + }
35 48
36 - List<ContactSimpleRespVO> convertAllList(List<ContactDO> list); 49 + List<CrmContactSimpleRespVO> convertAllList(List<CrmContactDO> list);
37 50
38 @Mappings({ 51 @Mappings({
39 @Mapping(target = "bizId", source = "reqVO.id"), 52 @Mapping(target = "bizId", source = "reqVO.id"),
@@ -41,4 +54,54 @@ public interface ContactConvert { @@ -41,4 +54,54 @@ public interface ContactConvert {
41 }) 54 })
42 CrmPermissionTransferReqBO convert(CrmContactTransferReqVO reqVO, Long userId); 55 CrmPermissionTransferReqBO convert(CrmContactTransferReqVO reqVO, Long userId);
43 56
  57 + /**
  58 + * 转换详情信息
  59 + *
  60 + * @param contactDO 联系人
  61 + * @param userMap 用户列表
  62 + * @param crmCustomerDOList 客户
  63 + * @return ContactRespVO
  64 + */
  65 + default CrmContactRespVO convert(CrmContactDO contactDO, Map<Long, AdminUserRespDTO> userMap, List<CrmCustomerDO> crmCustomerDOList,
  66 + List<CrmContactDO> contactList) {
  67 + CrmContactRespVO contactVO = convert(contactDO);
  68 + setUserInfo(contactVO, userMap);
  69 + Map<Long, CrmCustomerDO> ustomerMap = crmCustomerDOList.stream().collect(Collectors.toMap(CrmCustomerDO::getId, v -> v));
  70 + Map<Long, CrmContactDO> contactMap = contactList.stream().collect(Collectors.toMap(CrmContactDO::getId, v -> v));
  71 + findAndThen(ustomerMap, contactDO.getCustomerId(), customer -> contactVO.setCustomerName(customer.getName()));
  72 + findAndThen(contactMap, contactDO.getParentId(), contact -> contactVO.setParentName(contact.getName()));
  73 + return contactVO;
  74 + }
  75 +
  76 + default List<CrmContactRespVO> converList(List<CrmContactDO> contactList, Map<Long, AdminUserRespDTO> userMap,
  77 + List<CrmCustomerDO> customerList, List<CrmContactDO> parentContactList) {
  78 + List<CrmContactRespVO> result = convertList(contactList);
  79 + Map<Long, CrmContactDO> parentContactMap = convertMap(parentContactList, CrmContactDO::getId);
  80 + Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId);
  81 + result.forEach(item -> {
  82 + setUserInfo(item, userMap);
  83 + findAndThen(customerMap, item.getCustomerId(), customer -> { // TODO @zyna:这里的 { 可以去掉
  84 + item.setCustomerName(customer.getName());
  85 + });
  86 + findAndThen(parentContactMap, item.getParentId(), contactDO -> { // TODO @zyna:这里的 { 可以去掉
  87 + item.setParentName(contactDO.getName());
  88 + });
  89 + });
  90 + return result;
  91 + }
  92 +
  93 + /**
  94 + * 设置用户信息
  95 + *
  96 + * @param contactRespVO 联系人Response VO
  97 + * @param userMap 用户信息 map
  98 + */
  99 + static void setUserInfo(CrmContactRespVO contactRespVO, Map<Long, AdminUserRespDTO> userMap) {
  100 + contactRespVO.setAreaName(AreaUtils.format(contactRespVO.getAreaId()));
  101 + findAndThen(userMap, contactRespVO.getOwnerUserId(), user -> {
  102 + contactRespVO.setOwnerUserName(user == null ? "" : user.getNickname());
  103 + });
  104 + findAndThen(userMap, Long.parseLong(contactRespVO.getCreator()), user -> contactRespVO.setCreatorName(user.getNickname()));
  105 + }
  106 +
44 } 107 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/ContractConvert.java
@@ -2,14 +2,20 @@ package cn.iocoder.yudao.module.crm.convert.contract; @@ -2,14 +2,20 @@ package cn.iocoder.yudao.module.crm.convert.contract;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; 4 import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*;
5 -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; 5 +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
  6 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
6 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; 7 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
  8 +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
7 import org.mapstruct.Mapper; 9 import org.mapstruct.Mapper;
8 import org.mapstruct.Mapping; 10 import org.mapstruct.Mapping;
9 import org.mapstruct.Mappings; 11 import org.mapstruct.Mappings;
10 import org.mapstruct.factory.Mappers; 12 import org.mapstruct.factory.Mappers;
11 13
12 import java.util.List; 14 import java.util.List;
  15 +import java.util.Map;
  16 +
  17 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
  18 +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
13 19
14 /** 20 /**
15 * 合同 Convert 21 * 合同 Convert
@@ -21,17 +27,17 @@ public interface ContractConvert { @@ -21,17 +27,17 @@ public interface ContractConvert {
21 27
22 ContractConvert INSTANCE = Mappers.getMapper(ContractConvert.class); 28 ContractConvert INSTANCE = Mappers.getMapper(ContractConvert.class);
23 29
24 - ContractDO convert(ContractCreateReqVO bean); 30 + CrmContractDO convert(CrmContractCreateReqVO bean);
25 31
26 - ContractDO convert(ContractUpdateReqVO bean); 32 + CrmContractDO convert(CrmContractUpdateReqVO bean);
27 33
28 - ContractRespVO convert(ContractDO bean); 34 + ContractRespVO convert(CrmContractDO bean);
29 35
30 - List<ContractRespVO> convertList(List<ContractDO> list); 36 + List<ContractRespVO> convertList(List<CrmContractDO> list);
31 37
32 - PageResult<ContractRespVO> convertPage(PageResult<ContractDO> page); 38 + PageResult<ContractRespVO> convertPage(PageResult<CrmContractDO> page);
33 39
34 - List<ContractExcelVO> convertList02(List<ContractDO> list); 40 + List<CrmContractExcelVO> convertList02(List<CrmContractDO> list);
35 41
36 @Mappings({ 42 @Mappings({
37 @Mapping(target = "bizId", source = "reqVO.id"), 43 @Mapping(target = "bizId", source = "reqVO.id"),
@@ -39,4 +45,25 @@ public interface ContractConvert { @@ -39,4 +45,25 @@ public interface ContractConvert {
39 }) 45 })
40 CrmPermissionTransferReqBO convert(CrmContractTransferReqVO reqVO, Long userId); 46 CrmPermissionTransferReqBO convert(CrmContractTransferReqVO reqVO, Long userId);
41 47
  48 + default PageResult<ContractRespVO> convertPage(PageResult<CrmContractDO> pageResult, Map<Long, AdminUserRespDTO> userMap,
  49 + List<CrmCustomerDO> customerList) {
  50 + return new PageResult<>(converList(pageResult.getList(), userMap, customerList), pageResult.getTotal());
  51 + }
  52 +
  53 + default List<ContractRespVO> converList(List<CrmContractDO> contractList, Map<Long, AdminUserRespDTO> userMap,
  54 + List<CrmCustomerDO> customerList) {
  55 + List<ContractRespVO> result = convertList(contractList);
  56 + Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId);
  57 + result.forEach(item -> {
  58 + setUserInfo(item, userMap);
  59 + findAndThen(customerMap, item.getCustomerId(), customer -> item.setCustomerName(customer.getName()));
  60 + });
  61 + return result;
  62 + }
  63 +
  64 + static void setUserInfo(ContractRespVO contract, Map<Long, AdminUserRespDTO> userMap) {
  65 + findAndThen(userMap, contract.getOwnerUserId(), user -> contract.setOwnerUserName(user.getNickname()));
  66 + findAndThen(userMap, Long.parseLong(contract.getCreator()), user -> contract.setCreatorName(user.getNickname()));
  67 + }
  68 +
42 } 69 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java
1 package cn.iocoder.yudao.module.crm.convert.customer; 1 package cn.iocoder.yudao.module.crm.convert.customer;
2 2
3 -import cn.hutool.core.util.NumberUtil;  
4 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 -import cn.iocoder.yudao.framework.common.util.collection.MapUtils;  
6 import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; 4 import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
7 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; 5 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigRespVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO;
8 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; 8 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
9 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; 9 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
10 -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;  
11 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; 10 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
12 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; 11 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
13 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; 12 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
@@ -37,38 +36,20 @@ public interface CrmCustomerConvert { @@ -37,38 +36,20 @@ public interface CrmCustomerConvert {
37 36
38 CrmCustomerRespVO convert(CrmCustomerDO bean); 37 CrmCustomerRespVO convert(CrmCustomerDO bean);
39 38
40 - default CrmCustomerRespVO convert(CrmCustomerDO customer, Map<Long, CrmPermissionDO> ownerMap,  
41 - Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) {  
42 - CrmCustomerRespVO customerResp = convert(customer);  
43 - findAndThen(ownerMap, customerResp.getId(), owner -> {  
44 - customerResp.setOwnerUserId(owner.getUserId());  
45 - customerResp.setAreaName(AreaUtils.format(customerResp.getAreaId()));  
46 - findAndThen(userMap, owner.getUserId(), user -> {  
47 - customerResp.setOwnerUserName(user.getNickname());  
48 - });  
49 - findAndThen(userMap, Long.parseLong(customerResp.getCreator()), user -> {  
50 - customerResp.setCreatorName(user.getNickname());  
51 - });  
52 - findAndThen(deptMap, customerResp.getOwnerUserId(), dept -> {  
53 - customerResp.setOwnerUserDeptName(dept.getName());  
54 - });  
55 - });  
56 - return customerResp;  
57 - }  
58 -  
59 - default PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page, Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) {  
60 - PageResult<CrmCustomerRespVO> result = convertPage(page);  
61 - result.getList().forEach(customerRespVO -> {  
62 - customerRespVO.setAreaName(AreaUtils.format(customerRespVO.getAreaId()));  
63 - MapUtils.findAndThen(userMap, NumberUtil.parseLong(customerRespVO.getCreator()), creator ->  
64 - customerRespVO.setCreatorName(creator.getNickname()));  
65 - MapUtils.findAndThen(userMap, customerRespVO.getOwnerUserId(), ownerUser -> {  
66 - customerRespVO.setOwnerUserName(ownerUser.getNickname());  
67 - MapUtils.findAndThen(deptMap, ownerUser.getDeptId(), dept ->  
68 - customerRespVO.setOwnerUserDeptName(dept.getName()));  
69 - }); 39 + /**
  40 + * 设置用户信息
  41 + *
  42 + * @param customer CRM 客户 Response VO
  43 + * @param userMap 用户信息 map
  44 + * @param deptMap 用户部门信息 map
  45 + */
  46 + static void setUserInfo(CrmCustomerRespVO customer, Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) {
  47 + customer.setAreaName(AreaUtils.format(customer.getAreaId()));
  48 + findAndThen(userMap, customer.getOwnerUserId(), user -> {
  49 + customer.setOwnerUserName(user.getNickname());
  50 + findAndThen(deptMap, user.getDeptId(), dept -> customer.setOwnerUserDeptName(dept.getName()));
70 }); 51 });
71 - return result; 52 + findAndThen(userMap, Long.parseLong(customer.getCreator()), user -> customer.setCreatorName(user.getNickname()));
72 } 53 }
73 54
74 List<CrmCustomerExcelVO> convertList02(List<CrmCustomerDO> list); 55 List<CrmCustomerExcelVO> convertList02(List<CrmCustomerDO> list);
@@ -81,30 +62,24 @@ public interface CrmCustomerConvert { @@ -81,30 +62,24 @@ public interface CrmCustomerConvert {
81 62
82 PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page); 63 PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page);
83 64
84 - // TODO @puhui999:两个 convertPage 的逻辑,合并下;  
85 - default PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> pageResult, Map<Long, CrmPermissionDO> ownerMap,  
86 - Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) { 65 + default CrmCustomerRespVO convert(CrmCustomerDO customer, Map<Long, AdminUserRespDTO> userMap,
  66 + Map<Long, DeptRespDTO> deptMap) {
  67 + CrmCustomerRespVO customerResp = convert(customer);
  68 + setUserInfo(customerResp, userMap, deptMap);
  69 + return customerResp;
  70 + }
  71 +
  72 + default PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> pageResult, Map<Long, AdminUserRespDTO> userMap,
  73 + Map<Long, DeptRespDTO> deptMap) {
87 PageResult<CrmCustomerRespVO> result = convertPage(pageResult); 74 PageResult<CrmCustomerRespVO> result = convertPage(pageResult);
88 - result.getList().forEach(item -> {  
89 - findAndThen(ownerMap, item.getId(), owner -> {  
90 - item.setOwnerUserId(owner.getUserId());  
91 - item.setAreaName(AreaUtils.format(item.getAreaId()));  
92 - findAndThen(userMap, owner.getUserId(), user -> {  
93 - item.setOwnerUserName(user.getNickname());  
94 - });  
95 - findAndThen(userMap, Long.parseLong(item.getCreator()), user -> {  
96 - item.setCreatorName(user.getNickname());  
97 - });  
98 - findAndThen(deptMap, item.getOwnerUserId(), dept -> {  
99 - item.setOwnerUserDeptName(dept.getName());  
100 - });  
101 - });  
102 - }); 75 + result.getList().forEach(item -> setUserInfo(item, userMap, deptMap));
103 return result; 76 return result;
104 } 77 }
105 78
106 CrmCustomerPoolConfigRespVO convert(CrmCustomerPoolConfigDO customerPoolConfig); 79 CrmCustomerPoolConfigRespVO convert(CrmCustomerPoolConfigDO customerPoolConfig);
107 80
108 - CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigUpdateReqVO updateReqVO); 81 + CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO);
  82 +
  83 + List<CrmCustomerQueryAllRespVO> convertQueryAll(List<CrmCustomerDO> crmCustomerDO);
109 84
110 } 85 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerLimitConfigConvert.java
1 package cn.iocoder.yudao.module.crm.convert.customer; 1 package cn.iocoder.yudao.module.crm.convert.customer;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigCreateReqVO;  
5 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigRespVO;  
6 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigUpdateReqVO;  
7 -import cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig.CrmCustomerLimitConfigDO; 4 +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO;
  8 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
8 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; 9 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
9 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; 10 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
10 import org.mapstruct.Mapper; 11 import org.mapstruct.Mapper;
@@ -12,8 +13,6 @@ import org.mapstruct.factory.Mappers; @@ -12,8 +13,6 @@ import org.mapstruct.factory.Mappers;
12 13
13 import java.util.List; 14 import java.util.List;
14 import java.util.Map; 15 import java.util.Map;
15 -import java.util.Objects;  
16 -import java.util.stream.Collectors;  
17 16
18 /** 17 /**
19 * 客户限制配置 Convert 18 * 客户限制配置 Convert
@@ -54,14 +53,11 @@ public interface CrmCustomerLimitConfigConvert { @@ -54,14 +53,11 @@ public interface CrmCustomerLimitConfigConvert {
54 * 53 *
55 * @param userMap 用户映射 54 * @param userMap 用户映射
56 * @param deptMap 部门映射 55 * @param deptMap 部门映射
57 - * @param respVo 响应实体 56 + * @param respVo 响应实体
58 */ 57 */
59 static void fillNameField(Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap, CrmCustomerLimitConfigRespVO respVo) { 58 static void fillNameField(Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap, CrmCustomerLimitConfigRespVO respVo) {
60 - // TODO wanwan:返回 list,具体怎么拼接叫给前端;  
61 - respVo.setUserNames(respVo.getUserIds().stream().map(userMap::get)  
62 - .filter(Objects::nonNull).map(AdminUserRespDTO::getNickname).collect(Collectors.joining(",")));  
63 - respVo.setDeptNames(respVo.getDeptIds().stream().map(deptMap::get)  
64 - .filter(Objects::nonNull).map(DeptRespDTO::getName).collect(Collectors.joining(","))); 59 + respVo.setUsers(CollectionUtils.convertList(respVo.getUserIds(), userMap::get));
  60 + respVo.setDepts(CollectionUtils.convertList(respVo.getDeptIds(), deptMap::get));
65 } 61 }
66 62
67 } 63 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java
@@ -15,14 +15,15 @@ import com.google.common.collect.Multimaps; @@ -15,14 +15,15 @@ import com.google.common.collect.Multimaps;
15 import org.mapstruct.Mapper; 15 import org.mapstruct.Mapper;
16 import org.mapstruct.factory.Mappers; 16 import org.mapstruct.factory.Mappers;
17 17
18 -import java.util.ArrayList;  
19 import java.util.List; 18 import java.util.List;
20 import java.util.Map; 19 import java.util.Map;
21 20
  21 +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
  22 +
22 /** 23 /**
23 * Crm 数据权限 Convert 24 * Crm 数据权限 Convert
24 * 25 *
25 - * @author Wanwan 26 + * @author HUIHUI
26 */ 27 */
27 @Mapper 28 @Mapper
28 public interface CrmPermissionConvert { 29 public interface CrmPermissionConvert {
@@ -43,9 +44,9 @@ public interface CrmPermissionConvert { @@ -43,9 +44,9 @@ public interface CrmPermissionConvert {
43 Map<Long, DeptRespDTO> deptMap, Map<Long, PostRespDTO> postMap) { 44 Map<Long, DeptRespDTO> deptMap, Map<Long, PostRespDTO> postMap) {
44 Map<Long, AdminUserRespDTO> userMap = CollectionUtils.convertMap(userList, AdminUserRespDTO::getId); 45 Map<Long, AdminUserRespDTO> userMap = CollectionUtils.convertMap(userList, AdminUserRespDTO::getId);
45 return CollectionUtils.convertList(convert(permission), item -> { 46 return CollectionUtils.convertList(convert(permission), item -> {
46 - MapUtils.findAndThen(userMap, item.getId(), user -> { 47 + findAndThen(userMap, item.getUserId(), user -> {
47 item.setNickname(user.getNickname()); 48 item.setNickname(user.getNickname());
48 - MapUtils.findAndThen(deptMap, user.getDeptId(), deptRespDTO -> { 49 + findAndThen(deptMap, user.getDeptId(), deptRespDTO -> {
49 item.setDeptName(deptRespDTO.getName()); 50 item.setDeptName(deptRespDTO.getName());
50 }); 51 });
51 List<PostRespDTO> postRespList = MapUtils.getList(Multimaps.forMap(postMap), user.getPostIds()); 52 List<PostRespDTO> postRespList = MapUtils.getList(Multimaps.forMap(postMap), user.getPostIds());
@@ -56,12 +57,10 @@ public interface CrmPermissionConvert { @@ -56,12 +57,10 @@ public interface CrmPermissionConvert {
56 } 57 }
57 58
58 default List<CrmPermissionDO> convertList(CrmPermissionUpdateReqVO updateReqVO) { 59 default List<CrmPermissionDO> convertList(CrmPermissionUpdateReqVO updateReqVO) {
59 - // TODO @puhui999:CollectionUtils.convert  
60 - List<CrmPermissionDO> permissions = new ArrayList<>();  
61 - updateReqVO.getIds().forEach(id -> {  
62 - permissions.add(new CrmPermissionDO().setId(id).setLevel(updateReqVO.getLevel()));  
63 - });  
64 - return permissions; 60 + return CollectionUtils.convertList(updateReqVO.getIds(),
  61 + id -> new CrmPermissionDO().setId(id).setLevel(updateReqVO.getLevel()));
65 } 62 }
66 63
  64 + List<CrmPermissionDO> convertList(List<CrmPermissionCreateReqBO> list);
  65 +
67 } 66 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java
1 package cn.iocoder.yudao.module.crm.dal.dataobject.business; 1 package cn.iocoder.yudao.module.crm.dal.dataobject.business;
2 2
3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
4 -import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO;  
5 -import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO;  
6 import com.baomidou.mybatisplus.annotation.KeySequence; 4 import com.baomidou.mybatisplus.annotation.KeySequence;
7 import com.baomidou.mybatisplus.annotation.TableId; 5 import com.baomidou.mybatisplus.annotation.TableId;
8 import com.baomidou.mybatisplus.annotation.TableName; 6 import com.baomidou.mybatisplus.annotation.TableName;
@@ -71,8 +69,7 @@ public class CrmBusinessDO extends BaseDO { @@ -71,8 +69,7 @@ public class CrmBusinessDO extends BaseDO {
71 */ 69 */
72 private Integer discountPercent; 70 private Integer discountPercent;
73 /** 71 /**
74 - * 产品总金额  
75 - * 72 + * 产品总金额,单位:分
76 */ 73 */
77 private Integer productPrice; 74 private Integer productPrice;
78 /** 75 /**
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatus/CrmBusinessStatusDO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusDO.java
1 -package cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus; 1 +package cn.iocoder.yudao.module.crm.dal.dataobject.business;
2 2
3 import com.baomidou.mybatisplus.annotation.KeySequence; 3 import com.baomidou.mybatisplus.annotation.KeySequence;
4 import com.baomidou.mybatisplus.annotation.TableId; 4 import com.baomidou.mybatisplus.annotation.TableId;
@@ -27,7 +27,7 @@ public class CrmBusinessStatusDO { @@ -27,7 +27,7 @@ public class CrmBusinessStatusDO {
27 /** 27 /**
28 * 状态类型编号 28 * 状态类型编号
29 * 29 *
30 - * // TODO @ljlleo:要写下关联字段噢 30 + * 关联 {@link CrmBusinessStatusTypeDO#getId()}
31 */ 31 */
32 private Long typeId; 32 private Long typeId;
33 /** 33 /**
@@ -36,6 +36,8 @@ public class CrmBusinessStatusDO { @@ -36,6 +36,8 @@ public class CrmBusinessStatusDO {
36 private String name; 36 private String name;
37 /** 37 /**
38 * 赢单率 38 * 赢单率
  39 + *
  40 + * TODO 这里是不是改成 Integer 存储,百分比 * 100 ;
39 */ 41 */
40 private String percent; 42 private String percent;
41 /** 43 /**
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatustype/CrmBusinessStatusTypeDO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java
1 -package cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype; 1 +package cn.iocoder.yudao.module.crm.dal.dataobject.business;
2 2
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
3 import com.baomidou.mybatisplus.annotation.KeySequence; 5 import com.baomidou.mybatisplus.annotation.KeySequence;
  6 +import com.baomidou.mybatisplus.annotation.TableField;
4 import com.baomidou.mybatisplus.annotation.TableId; 7 import com.baomidou.mybatisplus.annotation.TableId;
5 import com.baomidou.mybatisplus.annotation.TableName; 8 import com.baomidou.mybatisplus.annotation.TableName;
6 import lombok.*; 9 import lombok.*;
7 10
  11 +import java.util.List;
  12 +
8 /** 13 /**
9 * 商机状态类型 DO 14 * 商机状态类型 DO
10 * 15 *
11 * @author ljlleo 16 * @author ljlleo
12 */ 17 */
13 -@TableName("crm_business_status_type") 18 +@TableName(value = "crm_business_status_type", autoResultMap = true)
14 @KeySequence("crm_business_status_type_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 19 @KeySequence("crm_business_status_type_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
15 @Data 20 @Data
  21 +@EqualsAndHashCode(callSuper = true)
16 @ToString(callSuper = true) 22 @ToString(callSuper = true)
17 @Builder 23 @Builder
18 @NoArgsConstructor 24 @NoArgsConstructor
19 @AllArgsConstructor 25 @AllArgsConstructor
20 -public class CrmBusinessStatusTypeDO { 26 +public class CrmBusinessStatusTypeDO extends BaseDO {
21 27
22 /** 28 /**
23 * 主键 29 * 主键
@@ -28,15 +34,16 @@ public class CrmBusinessStatusTypeDO { @@ -28,15 +34,16 @@ public class CrmBusinessStatusTypeDO {
28 * 状态类型名 34 * 状态类型名
29 */ 35 */
30 private String name; 36 private String name;
31 - // TODO @ljlleo:List 存储哈  
32 /** 37 /**
33 * 使用的部门编号 38 * 使用的部门编号
34 */ 39 */
35 - private String deptIds; 40 + @TableField(typeHandler = LongListTypeHandler.class)
  41 + private List<Long> deptIds;
36 /** 42 /**
37 * 开启状态 43 * 开启状态
  44 + *
  45 + * TODO 改成 Integer,关联 CommonStatus
38 */ 46 */
39 - // TODO @ljlleo:这个字段,使用 Integer,对应 CommonStatus  
40 private Boolean status; 47 private Boolean status;
41 48
42 } 49 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactDO.java
@@ -21,9 +21,13 @@ import java.time.LocalDateTime; @@ -21,9 +21,13 @@ import java.time.LocalDateTime;
21 @Builder 21 @Builder
22 @NoArgsConstructor 22 @NoArgsConstructor
23 @AllArgsConstructor 23 @AllArgsConstructor
24 -public class ContactDO extends BaseDO { 24 +public class CrmContactDO extends BaseDO {
25 25
26 - // TODO @zyna:这个字段的顺序,是不是整理下; 26 + /**
  27 + * 主键
  28 + */
  29 + @TableId
  30 + private Long id;
27 /** 31 /**
28 * 下次联系时间 32 * 下次联系时间
29 */ 33 */
@@ -56,15 +60,10 @@ public class ContactDO extends BaseDO { @@ -56,15 +60,10 @@ public class ContactDO extends BaseDO {
56 * 最后跟进时间 60 * 最后跟进时间
57 */ 61 */
58 private LocalDateTime lastTime; 62 private LocalDateTime lastTime;
59 - // TODO @zyna:这个放在最前面吧  
60 - /**  
61 - * 主键  
62 - */  
63 - @TableId  
64 - private Long id;  
65 - // TODO @zyna:直接上级,最好写下它关联的字段,例如说这个,应该关联 ContactDO 的 id 字段  
66 /** 63 /**
67 * 直属上级 64 * 直属上级
  65 + *
  66 + * 关联 {@link CrmContactDO#id}
68 */ 67 */
69 private Long parentId; 68 private Long parentId;
70 /** 69 /**
@@ -79,25 +78,32 @@ public class ContactDO extends BaseDO { @@ -79,25 +78,32 @@ public class ContactDO extends BaseDO {
79 * QQ 78 * QQ
80 */ 79 */
81 private Long qq; 80 private Long qq;
82 - // TODO @zyna:wechat  
83 /** 81 /**
84 * 微信 82 * 微信
85 */ 83 */
86 - private String webchat;  
87 - // TODO @zyna:关联的枚举 84 + private String wechat;
88 /** 85 /**
89 * 性别 86 * 性别
  87 + *
  88 + * 枚举 {@link cn.iocoder.yudao.module.system.enums.common.SexEnum}
90 */ 89 */
91 private Integer sex; 90 private Integer sex;
92 - // TODO @zyna:这个字段改成 master 哈;  
93 /** 91 /**
94 * 是否关键决策人 92 * 是否关键决策人
95 */ 93 */
96 - private Boolean policyMakers;  
97 - // TODO @zyna:应该是 Long 94 + private Boolean master;
98 /** 95 /**
99 * 负责人用户编号 96 * 负责人用户编号
  97 + *
  98 + * 关联 AdminUserDO 的 id 字段
  99 + */
  100 + private Long ownerUserId;
  101 +
  102 + /**
  103 + * 所在地
  104 + *
  105 + * 关联 {@link cn.iocoder.yudao.framework.ip.core.Area#getId()} 字段
100 */ 106 */
101 - private String ownerUserId; 107 + private Integer areaId;
102 108
103 } 109 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/ContractDO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractDO.java
1 package cn.iocoder.yudao.module.crm.dal.dataobject.contract; 1 package cn.iocoder.yudao.module.crm.dal.dataobject.contract;
2 2
3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
4 import com.baomidou.mybatisplus.annotation.KeySequence; 5 import com.baomidou.mybatisplus.annotation.KeySequence;
5 import com.baomidou.mybatisplus.annotation.TableId; 6 import com.baomidou.mybatisplus.annotation.TableId;
6 import com.baomidou.mybatisplus.annotation.TableName; 7 import com.baomidou.mybatisplus.annotation.TableName;
@@ -8,8 +9,9 @@ import lombok.*; @@ -8,8 +9,9 @@ import lombok.*;
8 9
9 import java.time.LocalDateTime; 10 import java.time.LocalDateTime;
10 11
  12 +// TODO 芋艿:实体的梳理
11 /** 13 /**
12 - * 合同 DO 14 + * CRM 合同 DO
13 * 15 *
14 * @author dhb52 16 * @author dhb52
15 */ 17 */
@@ -21,7 +23,7 @@ import java.time.LocalDateTime; @@ -21,7 +23,7 @@ import java.time.LocalDateTime;
21 @Builder 23 @Builder
22 @NoArgsConstructor 24 @NoArgsConstructor
23 @AllArgsConstructor 25 @AllArgsConstructor
24 -public class ContractDO extends BaseDO { 26 +public class CrmContractDO extends BaseDO {
25 27
26 /** 28 /**
27 * 合同编号 29 * 合同编号
@@ -89,4 +91,18 @@ public class ContractDO extends BaseDO { @@ -89,4 +91,18 @@ public class ContractDO extends BaseDO {
89 */ 91 */
90 private String remark; 92 private String remark;
91 93
  94 + /**
  95 + * 负责人的用户编号
  96 + *
  97 + * 关联 AdminUserDO 的 id 字段
  98 + */
  99 + private Long ownerUserId;
  100 +
  101 + /**
  102 + * 审批状态
  103 + *
  104 + * 枚举 {@link CrmAuditStatusEnum}
  105 + */
  106 + private Integer auditStatus;
  107 +
92 } 108 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customerlimitconfig/CrmCustomerLimitConfigDO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerLimitConfigDO.java
1 -package cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig; 1 +package cn.iocoder.yudao.module.crm.dal.dataobject.customer;
2 2
3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
4 import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; 4 import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
  5 +import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum;
5 import com.baomidou.mybatisplus.annotation.KeySequence; 6 import com.baomidou.mybatisplus.annotation.KeySequence;
6 import com.baomidou.mybatisplus.annotation.TableField; 7 import com.baomidou.mybatisplus.annotation.TableField;
7 import com.baomidou.mybatisplus.annotation.TableId; 8 import com.baomidou.mybatisplus.annotation.TableId;
@@ -32,8 +33,8 @@ public class CrmCustomerLimitConfigDO extends BaseDO { @@ -32,8 +33,8 @@ public class CrmCustomerLimitConfigDO extends BaseDO {
32 private Long id; 33 private Long id;
33 /** 34 /**
34 * 规则类型 35 * 规则类型
35 - *  
36 - * TODO @wanwan:搞个枚举哈; 36 + * <p>
  37 + * 枚举 {@link CrmCustomerLimitConfigTypeEnum}
37 */ 38 */
38 private Integer type; 39 private Integer type;
39 /** 40 /**
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerPoolConfigDO.java
1 package cn.iocoder.yudao.module.crm.dal.dataobject.customer; 1 package cn.iocoder.yudao.module.crm.dal.dataobject.customer;
2 2
3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
4 -import com.baomidou.mybatisplus.annotation.KeySequence;  
5 -import com.baomidou.mybatisplus.annotation.TableId;  
6 -import com.baomidou.mybatisplus.annotation.TableName; 4 +import com.baomidou.mybatisplus.annotation.*;
7 import lombok.*; 5 import lombok.*;
8 6
9 /** 7 /**
@@ -33,18 +31,22 @@ public class CrmCustomerPoolConfigDO extends BaseDO { @@ -33,18 +31,22 @@ public class CrmCustomerPoolConfigDO extends BaseDO {
33 /** 31 /**
34 * 未跟进放入公海天数 32 * 未跟进放入公海天数
35 */ 33 */
  34 + @TableField(updateStrategy = FieldStrategy.ALWAYS)
36 private Integer contactExpireDays; 35 private Integer contactExpireDays;
37 /** 36 /**
38 * 未成交放入公海天数 37 * 未成交放入公海天数
39 */ 38 */
  39 + @TableField(updateStrategy = FieldStrategy.ALWAYS)
40 private Integer dealExpireDays; 40 private Integer dealExpireDays;
41 /** 41 /**
42 * 是否开启提前提醒 42 * 是否开启提前提醒
43 */ 43 */
  44 + @TableField(updateStrategy = FieldStrategy.ALWAYS)
44 private Boolean notifyEnabled; 45 private Boolean notifyEnabled;
45 /** 46 /**
46 * 提前提醒天数 47 * 提前提醒天数
47 */ 48 */
  49 + @TableField(updateStrategy = FieldStrategy.ALWAYS)
48 private Integer notifyDays; 50 private Integer notifyDays;
49 51
50 } 52 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java
1 package cn.iocoder.yudao.module.crm.dal.dataobject.permission; 1 package cn.iocoder.yudao.module.crm.dal.dataobject.permission;
2 2
3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
4 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;  
5 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 4 +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
  5 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
6 import com.baomidou.mybatisplus.annotation.KeySequence; 6 import com.baomidou.mybatisplus.annotation.KeySequence;
7 import com.baomidou.mybatisplus.annotation.TableId; 7 import com.baomidou.mybatisplus.annotation.TableId;
8 import com.baomidou.mybatisplus.annotation.TableName; 8 import com.baomidou.mybatisplus.annotation.TableName;
9 import lombok.*; 9 import lombok.*;
10 10
11 /** 11 /**
12 - * Crm 数据权限 DO 12 + * CRM 数据权限 DO
13 * 13 *
14 * @author HUIHUI 14 * @author HUIHUI
15 */ 15 */
@@ -23,16 +23,8 @@ import lombok.*; @@ -23,16 +23,8 @@ import lombok.*;
23 @AllArgsConstructor 23 @AllArgsConstructor
24 public class CrmPermissionDO extends BaseDO { 24 public class CrmPermissionDO extends BaseDO {
25 25
26 - // TODO puhui999:是不是公海的数据,就不插入了;这样方便获取公海数据鸭  
27 - // TODO @puhui999:每个数据那的负责人,我想了下,还是存储的;  
28 /** 26 /**
29 - * 当数据变为公海数据时,也就是数据团队成员中没有负责人的时候,将原本的负责人 userId 设置为 POOL_USER_ID 方便查询公海数据。  
30 - * 也就是说每条数据到最后都有一个负责人,如果有人领取则 userId 为领取人  
31 - */  
32 - public static final Long POOL_USER_ID = 0L;  
33 -  
34 - /**  
35 - * ID 27 + * 编号,主键自增
36 */ 28 */
37 @TableId 29 @TableId
38 private Long id; 30 private Long id;
@@ -51,12 +43,9 @@ public class CrmPermissionDO extends BaseDO { @@ -51,12 +43,9 @@ public class CrmPermissionDO extends BaseDO {
51 private Long bizId; 43 private Long bizId;
52 44
53 /** 45 /**
54 - * 团队成员 46 + * 用户编号
55 * 47 *
56 * 关联 AdminUser 的 id 字段 48 * 关联 AdminUser 的 id 字段
57 - *  
58 - * 如果为公海数据的话会干掉此数据的负责人后设置为 {@link #POOL_USER_ID},领取人则上位负责人  
59 - * 例:客户放入公海后会干掉团队成员中的负责人,而其他团队成员则不受影响  
60 */ 49 */
61 private Long userId; 50 private Long userId;
62 51
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java
1 package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; 1 package cn.iocoder.yudao.module.crm.dal.dataobject.receivable;
2 2
3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
4 import com.baomidou.mybatisplus.annotation.KeySequence; 5 import com.baomidou.mybatisplus.annotation.KeySequence;
5 import com.baomidou.mybatisplus.annotation.TableId; 6 import com.baomidou.mybatisplus.annotation.TableId;
6 import com.baomidou.mybatisplus.annotation.TableName; 7 import com.baomidou.mybatisplus.annotation.TableName;
@@ -50,13 +51,13 @@ public class CrmReceivableDO extends BaseDO { @@ -50,13 +51,13 @@ public class CrmReceivableDO extends BaseDO {
50 /** 51 /**
51 * 合同 ID 52 * 合同 ID
52 * 53 *
53 - * 对应实体 {@link cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO} 54 + * 对应实体 {@link CrmContractDO}
54 */ 55 */
55 private Long contractId; 56 private Long contractId;
56 // TODO @liuhongfeng:“对应字典”,参考别的模块,枚举 {@link XXXX};另外,这个字段就叫 status,整体状态,不只审批 57 // TODO @liuhongfeng:“对应字典”,参考别的模块,枚举 {@link XXXX};另外,这个字段就叫 status,整体状态,不只审批
57 /** 58 /**
58 * 审批状态 59 * 审批状态
59 - * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_RECEIVABLE_CHECK_STATUS} 60 + * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_AUDIT_STATUS}
60 */ 61 */
61 private Integer checkStatus; 62 private Integer checkStatus;
62 /** 63 /**
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java
@@ -48,7 +48,7 @@ public class CrmReceivablePlanDO extends BaseDO { @@ -48,7 +48,7 @@ public class CrmReceivablePlanDO extends BaseDO {
48 /** 48 /**
49 * 审批状态 49 * 审批状态
50 * 50 *
51 - * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_RECEIVABLE_CHECK_STATUS} 51 + * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_AUDIT_STATUS}
52 * // TODO @liuhongfeng:关联的枚举 52 * // TODO @liuhongfeng:关联的枚举
53 */ 53 */
54 private Integer checkStatus; 54 private Integer checkStatus;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java
@@ -3,13 +3,12 @@ package cn.iocoder.yudao.module.crm.dal.mysql.business; @@ -3,13 +3,12 @@ package cn.iocoder.yudao.module.crm.dal.mysql.business;
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6 -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO; 6 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
8 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; 8 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
9 import org.apache.ibatis.annotations.Mapper; 9 import org.apache.ibatis.annotations.Mapper;
10 10
11 import java.util.Collection; 11 import java.util.Collection;
12 -import java.util.List;  
13 12
14 /** 13 /**
15 * 商机 Mapper 14 * 商机 Mapper
@@ -26,24 +25,10 @@ public interface CrmBusinessMapper extends BaseMapperX&lt;CrmBusinessDO&gt; { @@ -26,24 +25,10 @@ public interface CrmBusinessMapper extends BaseMapperX&lt;CrmBusinessDO&gt; {
26 .orderByDesc(CrmBusinessDO::getId)); 25 .orderByDesc(CrmBusinessDO::getId));
27 } 26 }
28 27
29 - // TODO @puhui999:selectList 噢;  
30 - default List<CrmBusinessDO> selectPage(CrmBusinessExportReqVO reqVO) {  
31 - return selectList(new LambdaQueryWrapperX<CrmBusinessDO>() 28 + default PageResult<CrmBusinessDO> selectPageByCustomer(CrmContractPageReqVO reqVO) {
  29 + return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessDO>()
  30 + .eq(CrmBusinessDO::getCustomerId, reqVO.getCustomerId()) // 必须传递
32 .likeIfPresent(CrmBusinessDO::getName, reqVO.getName()) 31 .likeIfPresent(CrmBusinessDO::getName, reqVO.getName())
33 - .eqIfPresent(CrmBusinessDO::getStatusTypeId, reqVO.getStatusTypeId())  
34 - .eqIfPresent(CrmBusinessDO::getStatusId, reqVO.getStatusId())  
35 - .betweenIfPresent(CrmBusinessDO::getContactNextTime, reqVO.getContactNextTime())  
36 - .eqIfPresent(CrmBusinessDO::getCustomerId, reqVO.getCustomerId())  
37 - .betweenIfPresent(CrmBusinessDO::getDealTime, reqVO.getDealTime())  
38 - .eqIfPresent(CrmBusinessDO::getPrice, reqVO.getPrice())  
39 - .eqIfPresent(CrmBusinessDO::getDiscountPercent, reqVO.getDiscountPercent())  
40 - .eqIfPresent(CrmBusinessDO::getProductPrice, reqVO.getProductPrice())  
41 - .eqIfPresent(CrmBusinessDO::getRemark, reqVO.getRemark())  
42 - .betweenIfPresent(CrmBusinessDO::getCreateTime, reqVO.getCreateTime())  
43 - .eqIfPresent(CrmBusinessDO::getEndStatus, reqVO.getEndStatus())  
44 - .eqIfPresent(CrmBusinessDO::getEndRemark, reqVO.getEndRemark())  
45 - .betweenIfPresent(CrmBusinessDO::getContactLastTime, reqVO.getContactLastTime())  
46 - .eqIfPresent(CrmBusinessDO::getFollowUpStatus, reqVO.getFollowUpStatus())  
47 .orderByDesc(CrmBusinessDO::getId)); 32 .orderByDesc(CrmBusinessDO::getId));
48 } 33 }
49 34
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatus/CrmBusinessStatusMapper.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java
1 -package cn.iocoder.yudao.module.crm.dal.mysql.businessstatus; 1 +package cn.iocoder.yudao.module.crm.dal.mysql.business;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusExportReqVO;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusPageReqVO;  
8 -import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; 6 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusPageReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
  8 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
9 import org.apache.ibatis.annotations.Mapper; 9 import org.apache.ibatis.annotations.Mapper;
10 10
11 import java.util.List; 11 import java.util.List;
@@ -20,21 +20,18 @@ public interface CrmBusinessStatusMapper extends BaseMapperX&lt;CrmBusinessStatusDO @@ -20,21 +20,18 @@ public interface CrmBusinessStatusMapper extends BaseMapperX&lt;CrmBusinessStatusDO
20 20
21 default PageResult<CrmBusinessStatusDO> selectPage(CrmBusinessStatusPageReqVO reqVO) { 21 default PageResult<CrmBusinessStatusDO> selectPage(CrmBusinessStatusPageReqVO reqVO) {
22 return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessStatusDO>() 22 return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessStatusDO>()
23 - .eqIfPresent(CrmBusinessStatusDO::getTypeId, reqVO.getTypeId())  
24 .orderByDesc(CrmBusinessStatusDO::getId)); 23 .orderByDesc(CrmBusinessStatusDO::getId));
25 } 24 }
26 25
27 - default List<CrmBusinessStatusDO> selectList(CrmBusinessStatusExportReqVO reqVO) { 26 + default List<CrmBusinessStatusDO> selectList(CrmBusinessStatusQueryVO queryVO) {
28 return selectList(new LambdaQueryWrapperX<CrmBusinessStatusDO>() 27 return selectList(new LambdaQueryWrapperX<CrmBusinessStatusDO>()
29 - .eqIfPresent(CrmBusinessStatusDO::getTypeId, reqVO.getTypeId())  
30 - .likeIfPresent(CrmBusinessStatusDO::getName, reqVO.getName())  
31 - .eqIfPresent(CrmBusinessStatusDO::getPercent, reqVO.getPercent())  
32 - .eqIfPresent(CrmBusinessStatusDO::getSort, reqVO.getSort()) 28 + .eqIfPresent(CrmBusinessStatusDO::getTypeId, queryVO.getTypeId())
  29 + .inIfPresent(CrmBusinessStatusDO::getId, queryVO.getIdList())
33 .orderByDesc(CrmBusinessStatusDO::getId)); 30 .orderByDesc(CrmBusinessStatusDO::getId));
34 } 31 }
35 32
36 - default List<CrmBusinessStatusDO> getBusinessStatusListByTypeId(Integer typeId) {  
37 - return selectList(CrmBusinessStatusDO::getTypeId, typeId); 33 + default int delete(Long typeId) {
  34 + return delete(CrmBusinessStatusDO::getTypeId, typeId);
38 } 35 }
39 36
40 } 37 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatustype/CrmBusinessStatusTypeMapper.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusTypeMapper.java
1 -package cn.iocoder.yudao.module.crm.dal.mysql.businessstatustype; 1 +package cn.iocoder.yudao.module.crm.dal.mysql.business;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeExportReqVO;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypePageReqVO;  
8 -import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; 6 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
  8 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
9 import org.apache.ibatis.annotations.Mapper; 9 import org.apache.ibatis.annotations.Mapper;
10 10
11 import java.util.List; 11 import java.util.List;
@@ -20,22 +20,12 @@ public interface CrmBusinessStatusTypeMapper extends BaseMapperX&lt;CrmBusinessStat @@ -20,22 +20,12 @@ public interface CrmBusinessStatusTypeMapper extends BaseMapperX&lt;CrmBusinessStat
20 20
21 default PageResult<CrmBusinessStatusTypeDO> selectPage(CrmBusinessStatusTypePageReqVO reqVO) { 21 default PageResult<CrmBusinessStatusTypeDO> selectPage(CrmBusinessStatusTypePageReqVO reqVO) {
22 return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessStatusTypeDO>() 22 return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessStatusTypeDO>()
23 - .likeIfPresent(CrmBusinessStatusTypeDO::getName, reqVO.getName())  
24 -// .eqIfPresent(CrmBusinessStatusTypeDO::getDeptIds, reqVO.getDeptIds()) TODO 报错,临时注释掉  
25 - .eqIfPresent(CrmBusinessStatusTypeDO::getStatus, reqVO.getStatus())  
26 .orderByDesc(CrmBusinessStatusTypeDO::getId)); 23 .orderByDesc(CrmBusinessStatusTypeDO::getId));
27 } 24 }
28 25
29 - default List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeExportReqVO reqVO) { 26 + default List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeQueryVO queryVO) {
30 return selectList(new LambdaQueryWrapperX<CrmBusinessStatusTypeDO>() 27 return selectList(new LambdaQueryWrapperX<CrmBusinessStatusTypeDO>()
31 - .likeIfPresent(CrmBusinessStatusTypeDO::getName, reqVO.getName())  
32 - .eqIfPresent(CrmBusinessStatusTypeDO::getDeptIds, reqVO.getDeptIds())  
33 - .eqIfPresent(CrmBusinessStatusTypeDO::getStatus, reqVO.getStatus())  
34 - .orderByDesc(CrmBusinessStatusTypeDO::getId));  
35 - }  
36 -  
37 - default List<CrmBusinessStatusTypeDO> getBusinessStatusTypeListByStatus(Integer status) {  
38 - return selectList(CrmBusinessStatusTypeDO::getStatus, status.byteValue()); 28 + .eqIfPresent(CrmBusinessStatusTypeDO::getStatus, queryVO.getStatus())
  29 + .inIfPresent(CrmBusinessStatusTypeDO::getId, queryVO.getIdList()));
39 } 30 }
40 -  
41 } 31 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java deleted
1 -package cn.iocoder.yudao.module.crm.dal.mysql.contact;  
2 -  
3 -import java.util.*;  
4 -  
5 -import cn.iocoder.yudao.framework.common.pojo.PageResult;  
6 -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;  
7 -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;  
8 -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO;  
9 -import org.apache.ibatis.annotations.Mapper;  
10 -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;  
11 -  
12 -/**  
13 - * crm联系人 Mapper  
14 - *  
15 - * @author 芋道源码  
16 - */  
17 -@Mapper  
18 -public interface ContactMapper extends BaseMapperX<ContactDO> {  
19 -  
20 - default PageResult<ContactDO> selectPage(ContactPageReqVO reqVO) {  
21 - return selectPage(reqVO, new LambdaQueryWrapperX<ContactDO>()  
22 - .betweenIfPresent(ContactDO::getNextTime, reqVO.getNextTime())  
23 - .eqIfPresent(ContactDO::getMobile, reqVO.getMobile())  
24 - .eqIfPresent(ContactDO::getTelephone, reqVO.getTelephone())  
25 - .eqIfPresent(ContactDO::getEmail, reqVO.getEmail())  
26 - .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId())  
27 - .eqIfPresent(ContactDO::getAddress, reqVO.getAddress())  
28 - .eqIfPresent(ContactDO::getRemark, reqVO.getRemark())  
29 - .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime())  
30 - .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime())  
31 - .eqIfPresent(ContactDO::getParentId, reqVO.getParentId())  
32 - .likeIfPresent(ContactDO::getName, reqVO.getName())  
33 - .eqIfPresent(ContactDO::getPost, reqVO.getPost())  
34 - .eqIfPresent(ContactDO::getQq, reqVO.getQq())  
35 - .eqIfPresent(ContactDO::getWebchat, reqVO.getWebchat())  
36 - .eqIfPresent(ContactDO::getSex, reqVO.getSex())  
37 - .eqIfPresent(ContactDO::getPolicyMakers, reqVO.getPolicyMakers())  
38 - .eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId())  
39 - .orderByDesc(ContactDO::getId));  
40 - }  
41 -  
42 - default List<ContactDO> selectList(ContactExportReqVO reqVO) {  
43 - return selectList(new LambdaQueryWrapperX<ContactDO>()  
44 - .betweenIfPresent(ContactDO::getNextTime, reqVO.getNextTime())  
45 - .eqIfPresent(ContactDO::getMobile, reqVO.getMobile())  
46 - .eqIfPresent(ContactDO::getTelephone, reqVO.getTelephone())  
47 - .eqIfPresent(ContactDO::getEmail, reqVO.getEmail())  
48 - .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId())  
49 - .eqIfPresent(ContactDO::getAddress, reqVO.getAddress())  
50 - .eqIfPresent(ContactDO::getRemark, reqVO.getRemark())  
51 - .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime())  
52 - .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime())  
53 - .eqIfPresent(ContactDO::getParentId, reqVO.getParentId())  
54 - .likeIfPresent(ContactDO::getName, reqVO.getName())  
55 - .eqIfPresent(ContactDO::getPost, reqVO.getPost())  
56 - .eqIfPresent(ContactDO::getQq, reqVO.getQq())  
57 - .eqIfPresent(ContactDO::getWebchat, reqVO.getWebchat())  
58 - .eqIfPresent(ContactDO::getSex, reqVO.getSex())  
59 - .eqIfPresent(ContactDO::getPolicyMakers, reqVO.getPolicyMakers())  
60 - .eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId())  
61 - .orderByDesc(ContactDO::getId));  
62 - }  
63 -  
64 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.dal.mysql.contact;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  5 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO;
  7 +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +
  10 +/**
  11 + * CRM 联系人 Mapper
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +@Mapper
  16 +public interface CrmContactMapper extends BaseMapperX<CrmContactDO> {
  17 +
  18 + // TODO @puhui999:数据权限
  19 + default PageResult<CrmContactDO> selectPage(CrmContactPageReqVO reqVO) {
  20 + return selectPage(reqVO, new LambdaQueryWrapperX<CrmContactDO>()
  21 + .eqIfPresent(CrmContactDO::getMobile, reqVO.getMobile())
  22 + .eqIfPresent(CrmContactDO::getTelephone, reqVO.getTelephone())
  23 + .eqIfPresent(CrmContactDO::getEmail, reqVO.getEmail())
  24 + .eqIfPresent(CrmContactDO::getCustomerId, reqVO.getCustomerId())
  25 + .likeIfPresent(CrmContactDO::getName, reqVO.getName())
  26 + .eqIfPresent(CrmContactDO::getQq, reqVO.getQq())
  27 + .eqIfPresent(CrmContactDO::getWechat, reqVO.getWechat())
  28 + .orderByDesc(CrmContactDO::getId));
  29 + }
  30 +
  31 + default PageResult<CrmContactDO> selectPageByCustomer(CrmContactPageReqVO pageVO) {
  32 + return selectPage(pageVO, new LambdaQueryWrapperX<CrmContactDO>()
  33 + .eq(CrmContactDO::getCustomerId, pageVO.getCustomerId()) // 必须传递
  34 + .likeIfPresent(CrmContactDO::getName, pageVO.getName())
  35 + .eqIfPresent(CrmContactDO::getMobile, pageVO.getMobile())
  36 + .eqIfPresent(CrmContactDO::getTelephone, pageVO.getTelephone())
  37 + .eqIfPresent(CrmContactDO::getEmail, pageVO.getEmail())
  38 + .eqIfPresent(CrmContactDO::getQq, pageVO.getQq())
  39 + .eqIfPresent(CrmContactDO::getWechat, pageVO.getWechat())
  40 + .orderByDesc(CrmContactDO::getId));
  41 + }
  42 +
  43 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/ContractMapper.java deleted
1 -package cn.iocoder.yudao.module.crm.dal.mysql.contract;  
2 -  
3 -import cn.iocoder.yudao.framework.common.pojo.PageResult;  
4 -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;  
5 -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;  
6 -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractExportReqVO;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractPageReqVO;  
8 -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO;  
9 -import org.apache.ibatis.annotations.Mapper;  
10 -  
11 -import java.util.List;  
12 -  
13 -/**  
14 - * 合同 Mapper  
15 - *  
16 - * @author dhb52  
17 - */  
18 -@Mapper  
19 -public interface ContractMapper extends BaseMapperX<ContractDO> {  
20 -  
21 - default PageResult<ContractDO> selectPage(ContractPageReqVO reqVO) {  
22 - return selectPage(reqVO, new LambdaQueryWrapperX<ContractDO>()  
23 - .likeIfPresent(ContractDO::getName, reqVO.getName())  
24 - .eqIfPresent(ContractDO::getCustomerId, reqVO.getCustomerId())  
25 - .eqIfPresent(ContractDO::getBusinessId, reqVO.getBusinessId())  
26 - .betweenIfPresent(ContractDO::getOrderDate, reqVO.getOrderDate())  
27 - .eqIfPresent(ContractDO::getNo, reqVO.getNo())  
28 - .eqIfPresent(ContractDO::getDiscountPercent, reqVO.getDiscountPercent())  
29 - .eqIfPresent(ContractDO::getProductPrice, reqVO.getProductPrice())  
30 - .orderByDesc(ContractDO::getId));  
31 - }  
32 -  
33 - default List<ContractDO> selectList(ContractExportReqVO reqVO) {  
34 - return selectList(new LambdaQueryWrapperX<ContractDO>()  
35 - .likeIfPresent(ContractDO::getName, reqVO.getName())  
36 - .eqIfPresent(ContractDO::getCustomerId, reqVO.getCustomerId())  
37 - .eqIfPresent(ContractDO::getBusinessId, reqVO.getBusinessId())  
38 - .betweenIfPresent(ContractDO::getOrderDate, reqVO.getOrderDate())  
39 - .eqIfPresent(ContractDO::getNo, reqVO.getNo())  
40 - .eqIfPresent(ContractDO::getDiscountPercent, reqVO.getDiscountPercent())  
41 - .eqIfPresent(ContractDO::getProductPrice, reqVO.getProductPrice())  
42 - .orderByDesc(ContractDO::getId));  
43 - }  
44 -  
45 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.dal.mysql.contract;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  5 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
  7 +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +
  10 +/**
  11 + * CRM 合同 Mapper
  12 + *
  13 + * @author dhb52
  14 + */
  15 +@Mapper
  16 +public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
  17 +
  18 + default PageResult<CrmContractDO> selectPage(CrmContractPageReqVO reqVO) {
  19 + return selectPage(reqVO, new LambdaQueryWrapperX<CrmContractDO>()
  20 + .likeIfPresent(CrmContractDO::getNo, reqVO.getNo())
  21 + .likeIfPresent(CrmContractDO::getName, reqVO.getName())
  22 + .eqIfPresent(CrmContractDO::getCustomerId, reqVO.getCustomerId())
  23 + .eqIfPresent(CrmContractDO::getBusinessId, reqVO.getBusinessId())
  24 + .orderByDesc(CrmContractDO::getId));
  25 + }
  26 +
  27 + default PageResult<CrmContractDO> selectPageByCustomer(CrmContractPageReqVO reqVO) {
  28 + return selectPage(reqVO, new LambdaQueryWrapperX<CrmContractDO>()
  29 + .eq(CrmContractDO::getCustomerId, reqVO.getCustomerId()) // 必须传递
  30 + .likeIfPresent(CrmContractDO::getNo, reqVO.getNo())
  31 + .likeIfPresent(CrmContractDO::getName, reqVO.getName())
  32 + .eqIfPresent(CrmContractDO::getBusinessId, reqVO.getBusinessId())
  33 + .orderByDesc(CrmContractDO::getId));
  34 + }
  35 +
  36 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java
1 package cn.iocoder.yudao.module.crm.dal.mysql.customer; 1 package cn.iocoder.yudao.module.crm.dal.mysql.customer;
2 2
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 5 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 6 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  7 +import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
  8 +import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
6 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; 9 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
7 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; 10 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
  11 +import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
  12 +import cn.iocoder.yudao.module.crm.enums.common.CrmSceneEnum;
  13 +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
  14 +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  15 +import com.baomidou.mybatisplus.core.metadata.IPage;
8 import org.apache.ibatis.annotations.Mapper; 16 import org.apache.ibatis.annotations.Mapper;
9 17
10 -import java.util.Collection; 18 +import java.util.List;
11 19
12 /** 20 /**
13 * 客户 Mapper 21 * 客户 Mapper
@@ -17,9 +25,17 @@ import java.util.Collection; @@ -17,9 +25,17 @@ import java.util.Collection;
17 @Mapper 25 @Mapper
18 public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { 26 public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
19 27
20 - default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO pageReqVO, Collection<Long> ids) {  
21 - return selectPage(pageReqVO, new LambdaQueryWrapperX<CrmCustomerDO>()  
22 - .inIfPresent(CrmCustomerDO::getId, ids) 28 + default int updateOwnerUserIdById(Long id, Long ownerUserId) {
  29 + return update(new LambdaUpdateWrapper<CrmCustomerDO>()
  30 + .eq(CrmCustomerDO::getId, id)
  31 + .set(CrmCustomerDO::getOwnerUserId, ownerUserId));
  32 + }
  33 +
  34 + default PageResult<CrmCustomerDO> selectPageWithAdmin(CrmCustomerPageReqVO pageReqVO, Long userId) {
  35 + // 情况一:管理员查看
  36 + LambdaQueryWrapperX<CrmCustomerDO> queryWrapperX = new LambdaQueryWrapperX<>();
  37 + appendQueryParams(queryWrapperX, pageReqVO, userId);
  38 + return selectPage(pageReqVO, queryWrapperX
23 .likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName()) 39 .likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName())
24 .eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile()) 40 .eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile())
25 .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId()) 41 .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId())
@@ -27,4 +43,54 @@ public interface CrmCustomerMapper extends BaseMapperX&lt;CrmCustomerDO&gt; { @@ -27,4 +43,54 @@ public interface CrmCustomerMapper extends BaseMapperX&lt;CrmCustomerDO&gt; {
27 .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource())); 43 .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource()));
28 } 44 }
29 45
  46 + default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO pageReqVO, Long userId) {
  47 + // 情况二:获取当前用户能看的分页数据
  48 + IPage<CrmCustomerDO> mpPage = MyBatisUtils.buildPage(pageReqVO);
  49 + MPJLambdaWrapperX<CrmCustomerDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>();
  50 + // 构建数据权限连表条件
  51 + mpjLambdaWrapperX
  52 + .innerJoin(CrmPermissionDO.class, CrmPermissionDO::getBizId, CrmCustomerDO::getId)
  53 + .eq(CrmPermissionDO::getBizType, CrmBizTypeEnum.CRM_CUSTOMER.getType())
  54 + .eq(CrmPermissionDO::getUserId, userId);
  55 + appendQueryParams(mpjLambdaWrapperX, pageReqVO, userId);
  56 + mpjLambdaWrapperX
  57 + .selectAll(CrmCustomerDO.class)
  58 + .likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName())
  59 + .eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile())
  60 + .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId())
  61 + .eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel())
  62 + .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource());
  63 + // 特殊:不分页,直接查询全部
  64 + if (PageParam.PAGE_SIZE_NONE.equals(pageReqVO.getPageNo())) {
  65 + List<CrmCustomerDO> list = selectJoinList(CrmCustomerDO.class, mpjLambdaWrapperX);
  66 + return new PageResult<>(list, (long) list.size());
  67 + }
  68 + mpPage = selectJoinPage(mpPage, CrmCustomerDO.class, mpjLambdaWrapperX);
  69 + return new PageResult<>(mpPage.getRecords(), mpPage.getTotal());
  70 + }
  71 +
  72 + static void appendQueryParams(MPJLambdaWrapperX<CrmCustomerDO> mpjLambdaWrapperX, CrmCustomerPageReqVO pageReqVO, Long userId) {
  73 + if (pageReqVO.getPool()) { // 情况一:公海
  74 + mpjLambdaWrapperX.isNull(CrmCustomerDO::getOwnerUserId);
  75 + } else { // 情况二:不是公海
  76 + mpjLambdaWrapperX.isNotNull(CrmCustomerDO::getOwnerUserId);
  77 + }
  78 + // TODO 场景数据过滤
  79 + if (CrmSceneEnum.isOwner(pageReqVO.getSceneType())) { // 场景一:我负责的数据
  80 + mpjLambdaWrapperX.eq(CrmCustomerDO::getOwnerUserId, userId);
  81 + }
  82 + }
  83 +
  84 + static void appendQueryParams(LambdaQueryWrapperX<CrmCustomerDO> lambdaQueryWrapperX, CrmCustomerPageReqVO pageReqVO, Long userId) {
  85 + if (pageReqVO.getPool()) { // 情况一:公海
  86 + lambdaQueryWrapperX.isNull(CrmCustomerDO::getOwnerUserId);
  87 + } else { // 情况二:不是公海
  88 + lambdaQueryWrapperX.isNotNull(CrmCustomerDO::getOwnerUserId);
  89 + }
  90 + // TODO 场景数据过滤
  91 + if (CrmSceneEnum.isOwner(pageReqVO.getSceneType())) { // 场景一:我负责的数据
  92 + lambdaQueryWrapperX.eq(CrmCustomerDO::getOwnerUserId, userId);
  93 + }
  94 + }
  95 +
30 } 96 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customerlimitconfig/CrmCustomerLimitConfigMapper.java
@@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig; @@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig;
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigPageReqVO;  
7 -import cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig.CrmCustomerLimitConfigDO; 6 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO;
  7 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
8 import org.apache.ibatis.annotations.Mapper; 8 import org.apache.ibatis.annotations.Mapper;
9 9
10 /** 10 /**
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java
@@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; @@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
5 import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; 5 import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
6 import org.apache.ibatis.annotations.Mapper; 6 import org.apache.ibatis.annotations.Mapper;
7 7
8 -import java.util.Collection;  
9 import java.util.List; 8 import java.util.List;
10 9
11 /** 10 /**
@@ -35,10 +34,10 @@ public interface CrmPermissionMapper extends BaseMapperX&lt;CrmPermissionDO&gt; { @@ -35,10 +34,10 @@ public interface CrmPermissionMapper extends BaseMapperX&lt;CrmPermissionDO&gt; {
35 .eq(CrmPermissionDO::getUserId, userId)); 34 .eq(CrmPermissionDO::getUserId, userId));
36 } 35 }
37 36
38 - default List<CrmPermissionDO> selectListByBizTypeAndBizIdsAndLevel(Integer bizType, Collection<Long> bizIds, Integer level) { 37 + default List<CrmPermissionDO> selectListByBizTypeAndBizIdAndLevel(Integer bizType, Long bizId, Integer level) {
39 return selectList(new LambdaQueryWrapperX<CrmPermissionDO>() 38 return selectList(new LambdaQueryWrapperX<CrmPermissionDO>()
40 .eq(CrmPermissionDO::getBizType, bizType) 39 .eq(CrmPermissionDO::getBizType, bizType)
41 - .in(CrmPermissionDO::getBizId, bizIds) 40 + .eq(CrmPermissionDO::getBizId, bizId)
42 .eq(CrmPermissionDO::getLevel, level)); 41 .eq(CrmPermissionDO::getLevel, level));
43 } 42 }
44 43
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/annotations/CrmPermission.java
1 package cn.iocoder.yudao.module.crm.framework.core.annotations; 1 package cn.iocoder.yudao.module.crm.framework.core.annotations;
2 2
3 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;  
4 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 3 +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
  4 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
5 5
6 import java.lang.annotation.Documented; 6 import java.lang.annotation.Documented;
7 import java.lang.annotation.Retention; 7 import java.lang.annotation.Retention;
@@ -24,7 +24,7 @@ public @interface CrmPermission { @@ -24,7 +24,7 @@ public @interface CrmPermission {
24 /** 24 /**
25 * CRM 类型 25 * CRM 类型
26 */ 26 */
27 - CrmBizTypeEnum bizType(); 27 + CrmBizTypeEnum[] bizType() default {};
28 28
29 /** 29 /**
30 * CRM 类型扩展,通过 Spring EL 表达式获取到 {@link #bizType()} 30 * CRM 类型扩展,通过 Spring EL 表达式获取到 {@link #bizType()}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java
@@ -2,32 +2,29 @@ package cn.iocoder.yudao.module.crm.framework.core.aop; @@ -2,32 +2,29 @@ package cn.iocoder.yudao.module.crm.framework.core.aop;
2 2
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 import cn.hutool.core.util.ObjUtil; 4 import cn.hutool.core.util.ObjUtil;
5 -import cn.iocoder.yudao.framework.common.core.KeyValue; 5 +import cn.hutool.core.util.StrUtil;
  6 +import cn.iocoder.yudao.framework.common.util.spring.SpringExpressionUtils;
6 import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; 7 import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
7 import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; 8 import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
8 import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; 9 import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
9 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;  
10 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 10 +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
  11 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
11 import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; 12 import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
12 import lombok.extern.slf4j.Slf4j; 13 import lombok.extern.slf4j.Slf4j;
13 import org.aspectj.lang.JoinPoint; 14 import org.aspectj.lang.JoinPoint;
14 import org.aspectj.lang.annotation.Aspect; 15 import org.aspectj.lang.annotation.Aspect;
15 import org.aspectj.lang.annotation.Before; 16 import org.aspectj.lang.annotation.Before;
16 -import org.aspectj.lang.reflect.MethodSignature;  
17 -import org.springframework.core.LocalVariableTableParameterNameDiscoverer;  
18 -import org.springframework.expression.EvaluationContext;  
19 -import org.springframework.expression.Expression;  
20 -import org.springframework.expression.spel.standard.SpelExpressionParser;  
21 -import org.springframework.expression.spel.support.StandardEvaluationContext;  
22 import org.springframework.stereotype.Component; 17 import org.springframework.stereotype.Component;
23 18
24 import javax.annotation.Resource; 19 import javax.annotation.Resource;
25 -import java.lang.reflect.Method; 20 +import java.util.ArrayList;
26 import java.util.List; 21 import java.util.List;
  22 +import java.util.Map;
27 23
28 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 24 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
29 import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; 25 import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
30 import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSION_DENIED; 26 import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSION_DENIED;
  27 +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSION_MODEL_NOT_EXISTS;
31 28
32 /** 29 /**
33 * Crm 数据权限校验 AOP 切面 30 * Crm 数据权限校验 AOP 切面
@@ -40,31 +37,19 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSIO @@ -40,31 +37,19 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSIO
40 public class CrmPermissionAspect { 37 public class CrmPermissionAspect {
41 38
42 @Resource 39 @Resource
43 - private LocalVariableTableParameterNameDiscoverer discoverer;  
44 - @Resource  
45 - private SpelExpressionParser parser;  
46 -  
47 - @Resource  
48 private CrmPermissionService crmPermissionService; 40 private CrmPermissionService crmPermissionService;
49 41
50 - /**  
51 - * 获得用户编号  
52 - *  
53 - * @return 用户编号  
54 - */  
55 - private static Long getUserId() {  
56 - return WebFrameworkUtils.getLoginUserId();  
57 - }  
58 -  
59 @Before("@annotation(crmPermission)") 42 @Before("@annotation(crmPermission)")
60 - public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) throws NoSuchMethodException { 43 + public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) {
61 // TODO 芋艿:临时,方便大家调试 44 // TODO 芋艿:临时,方便大家调试
62 - if (true) {  
63 - return;  
64 - }  
65 - KeyValue<Long, Integer> bizIdAndBizType = getBizIdAndBizType(joinPoint, crmPermission);  
66 - Integer bizType = bizIdAndBizType.getValue(); // 模块类型  
67 - Long bizId = bizIdAndBizType.getKey(); // 模块数据编号 45 + //if (true) {
  46 + // return;
  47 + //}
  48 + // 获取相关属性值
  49 + Map<String, Object> expressionValues = parseExpressions(joinPoint, crmPermission);
  50 + Integer bizType = StrUtil.isEmpty(crmPermission.bizTypeValue()) ?
  51 + crmPermission.bizType()[0].getType() : (Integer) expressionValues.get(crmPermission.bizTypeValue()); // 模块类型
  52 + Long bizId = (Long) expressionValues.get(crmPermission.bizId()); // 模块数据编号
68 Integer permissionLevel = crmPermission.level().getLevel(); // 需要的权限级别 53 Integer permissionLevel = crmPermission.level().getLevel(); // 需要的权限级别
69 54
70 // TODO 如果是超级管理员则直接通过 55 // TODO 如果是超级管理员则直接通过
@@ -73,94 +58,55 @@ public class CrmPermissionAspect { @@ -73,94 +58,55 @@ public class CrmPermissionAspect {
73 //} 58 //}
74 59
75 // 1. 获取数据权限 60 // 1. 获取数据权限
76 - List<CrmPermissionDO> bizPermissions = crmPermissionService.getPermissionByBizTypeAndBizId(bizType, bizId);  
77 - // 2.1 情况一:如果自己是负责人,则默认有所有权限  
78 - // TODO @puhui999:会不会存在空指针的问题?  
79 - CrmPermissionDO userPermission = CollUtil.findOne(bizPermissions, item -> ObjUtil.equal(item.getUserId(), getUserId()));  
80 - if (CrmPermissionLevelEnum.isOwner(userPermission.getLevel())) {  
81 - return; 61 + List<CrmPermissionDO> bizPermissions = crmPermissionService.getPermissionListByBiz(bizType, bizId);
  62 + if (CollUtil.isEmpty(bizPermissions)) { // 数据权限不存存那么数据也不存在
  63 + throw exception(CRM_PERMISSION_MODEL_NOT_EXISTS, CrmBizTypeEnum.getNameByType(bizType));
82 } 64 }
83 - // 2.2 情况二:校验自己是否有读权限  
84 - if (CrmPermissionLevelEnum.isRead(permissionLevel)) {  
85 - // 如果没有数据权限或没有负责人则表示此记录为公海数据所有人都有只读权限可以领取成为负责人(团队成员领取的)  
86 - // TODO @puhui999:89 到 92 这块的逻辑,感觉可以不用 @CrmPermission,公海那自己 check 即可;  
87 - if (CollUtil.isEmpty(bizPermissions) || CollUtil.anyMatch(bizPermissions,  
88 - item -> ObjUtil.equal(item.getUserId(), CrmPermissionDO.POOL_USER_ID))) { // 详见 CrmPermissionDO.POOL_USER_ID 注释  
89 - return;  
90 - }  
91 - if (CrmPermissionLevelEnum.isRead(userPermission.getLevel())) { // 校验当前用户是否有读权限 65 + // 2.1 情况一:如果自己是负责人,则默认有所有权限
  66 + CrmPermissionDO userPermission = CollUtil.findOne(bizPermissions, permission -> ObjUtil.equal(permission.getUserId(), getUserId()));
  67 + if (userPermission != null) {
  68 + if (CrmPermissionLevelEnum.isOwner(userPermission.getLevel())) {
92 return; 69 return;
93 } 70 }
94 - // 如果查询数据的话拥有写权限的也能查询  
95 - if (CrmPermissionLevelEnum.isWrite(userPermission.getLevel())) { // 校验当前用户是否有写权限  
96 - return; 71 + // 2.2 情况二:校验自己是否有读权限
  72 + if (CrmPermissionLevelEnum.isRead(permissionLevel)) {
  73 + if (CrmPermissionLevelEnum.isRead(userPermission.getLevel()) // 校验当前用户是否有读权限
  74 + || CrmPermissionLevelEnum.isWrite(userPermission.getLevel())) { // 校验当前用户是否有写权限
  75 + return;
  76 + }
97 } 77 }
98 - }  
99 - // 2.3 情况三:校验自己是否有写权限  
100 - if (CrmPermissionLevelEnum.isWrite(permissionLevel)) {  
101 - if (CrmPermissionLevelEnum.isWrite(userPermission.getLevel())) { // 校验当前用户是否有写权限  
102 - return; 78 + // 2.3 情况三:校验自己是否有写权限
  79 + if (CrmPermissionLevelEnum.isWrite(permissionLevel)) {
  80 + if (CrmPermissionLevelEnum.isWrite(userPermission.getLevel())) { // 校验当前用户是否有写权限
  81 + return;
  82 + }
103 } 83 }
104 } 84 }
105 -  
106 - // 打个 info 日志,方便后续排查问题、审计;  
107 - log.info("[doBefore][crmPermission({}) 数据校验错误]", toJsonString(userPermission));  
108 - throw exception(CRM_PERMISSION_DENIED, crmPermission.bizType().getName());  
109 - }  
110 -  
111 -  
112 - // TODO @puhui999:这块看看能不能用 SpringExpressionUtils 工具类;  
113 - private KeyValue<Long, Integer> getBizIdAndBizType(JoinPoint joinPoint, CrmPermission crmPermission) throws NoSuchMethodException {  
114 - Method method = getMethod(joinPoint);  
115 - // 1. 获取方法的参数值  
116 - Object[] args = joinPoint.getArgs();  
117 - EvaluationContext context = bindParam(method, args);  
118 -  
119 - // 2. 根据spel表达式获取值  
120 - KeyValue<Long, Integer> keyValue = new KeyValue<>();  
121 - // 2.1 获取模块数据编号  
122 - Expression expression = parser.parseExpression(crmPermission.bizId());  
123 - keyValue.setKey(expression.getValue(context, Long.class));  
124 - // 2.2 获取模块类型  
125 - if (ObjUtil.equal(crmPermission.bizType().getType(), CrmBizTypeEnum.CRM_PERMISSION.getType())) {  
126 - // 情况一:用于 CrmPermissionController 中数据权限校验  
127 - Expression expression2 = parser.parseExpression(crmPermission.bizTypeValue());  
128 - keyValue.setValue(expression2.getValue(context, Integer.class));  
129 - return keyValue;  
130 - }  
131 - // 情况二:正常数据权限校验  
132 - keyValue.setValue(crmPermission.bizType().getType());  
133 - return keyValue; 85 + // 2.4 没有权限!
  86 + // 打个 info 日志,方便后续排查问题、审计
  87 + log.info("[doBefore][userId({}) 要求权限({}) 实际权限({}) 数据校验错误]",
  88 + getUserId(), permissionLevel, toJsonString(userPermission));
  89 + throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.getNameByType(bizType));
134 } 90 }
135 91
136 /** 92 /**
137 - * 获取当前执行的方法  
138 - */  
139 - private Method getMethod(JoinPoint joinPoint) throws NoSuchMethodException {  
140 - MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();  
141 - Method method = methodSignature.getMethod();  
142 - return joinPoint.getTarget().getClass().getMethod(method.getName(), method.getParameterTypes());  
143 - }  
144 -  
145 - /**  
146 - * 将方法的参数名和参数值绑定 93 + * 获得用户编号
147 * 94 *
148 - * @param method 方法,根据方法获取参数名  
149 - * @param args 方法的参数值  
150 - * @return 求值上下文 95 + * @return 用户编号
151 */ 96 */
152 - private EvaluationContext bindParam(Method method, Object[] args) {  
153 - //获取方法的参数名  
154 - String[] params = discoverer.getParameterNames(method); 97 + private static Long getUserId() {
  98 + return WebFrameworkUtils.getLoginUserId();
  99 + }
155 100
156 - //将参数名与参数值对应起来  
157 - EvaluationContext context = new StandardEvaluationContext();  
158 - if (params != null) {  
159 - for (int len = 0; len < params.length; len++) {  
160 - context.setVariable(params[len], args[len]);  
161 - } 101 + private static Map<String, Object> parseExpressions(JoinPoint joinPoint, CrmPermission crmPermission) {
  102 + // 1. 需要解析的表达式
  103 + List<String> expressionStrings = new ArrayList<>(2);
  104 + expressionStrings.add(crmPermission.bizId());
  105 + if (StrUtil.isNotEmpty(crmPermission.bizTypeValue())) { // 为空则表示 bizType 有值
  106 + expressionStrings.add(crmPermission.bizTypeValue());
162 } 107 }
163 - return context; 108 + // 2. 执行解析
  109 + return SpringExpressionUtils.parseExpressions(joinPoint, expressionStrings);
164 } 110 }
165 111
166 } 112 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/config/SpelConfig.java deleted
1 -package cn.iocoder.yudao.module.crm.framework.core.config;  
2 -  
3 -import org.springframework.context.annotation.Bean;  
4 -import org.springframework.context.annotation.Configuration;  
5 -import org.springframework.expression.spel.standard.SpelExpressionParser;  
6 -  
7 -// TODO @puhui999:SpringExpressionUtils  
8 -/**  
9 - * 注册 Spel 所需 Bean  
10 - *  
11 - * @author HUIHUI  
12 - */  
13 -@Configuration  
14 -public class SpelConfig {  
15 -  
16 - @Bean  
17 - public SpelExpressionParser spelExpressionParser() {  
18 - return new SpelExpressionParser();  
19 - }  
20 -  
21 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java
1 package cn.iocoder.yudao.module.crm.service.business; 1 package cn.iocoder.yudao.module.crm.service.business;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; 4 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessCreateReqVO;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO;
  8 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
5 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; 9 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
  10 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
6 11
7 import javax.validation.Valid; 12 import javax.validation.Valid;
8 import java.util.Collection; 13 import java.util.Collection;
@@ -57,6 +62,8 @@ public interface CrmBusinessService { @@ -57,6 +62,8 @@ public interface CrmBusinessService {
57 /** 62 /**
58 * 获得商机分页 63 * 获得商机分页
59 * 64 *
  65 + * 数据权限:基于 {@link CrmBusinessDO}
  66 + *
60 * @param pageReqVO 分页查询 67 * @param pageReqVO 分页查询
61 * @param userId 用户编号 68 * @param userId 用户编号
62 * @return 商机分页 69 * @return 商机分页
@@ -64,12 +71,14 @@ public interface CrmBusinessService { @@ -64,12 +71,14 @@ public interface CrmBusinessService {
64 PageResult<CrmBusinessDO> getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId); 71 PageResult<CrmBusinessDO> getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId);
65 72
66 /** 73 /**
67 - * 获得商机列表, 用于 Excel 导出 74 + * 获得商机分页,基于指定客户
68 * 75 *
69 - * @param exportReqVO 查询条件  
70 - * @return 商机列表 76 + * 数据权限:基于 {@link CrmCustomerDO} 读取
  77 + *
  78 + * @param pageReqVO 分页查询
  79 + * @return 联系人分页
71 */ 80 */
72 - List<CrmBusinessDO> getBusinessList(CrmBusinessExportReqVO exportReqVO); 81 + PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmContractPageReqVO pageReqVO);
73 82
74 /** 83 /**
75 * 商机转移 84 * 商机转移
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
@@ -3,14 +3,15 @@ package cn.iocoder.yudao.module.crm.service.business; @@ -3,14 +3,15 @@ package cn.iocoder.yudao.module.crm.service.business;
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 import cn.hutool.core.collection.ListUtil; 4 import cn.hutool.core.collection.ListUtil;
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; 6 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
7 import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; 8 import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
8 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; 9 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
9 import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; 10 import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
10 import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; 11 import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper;
11 import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; 12 import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
12 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;  
13 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 13 +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
  14 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
14 import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; 15 import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
15 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; 16 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
16 import org.springframework.stereotype.Service; 17 import org.springframework.stereotype.Service;
@@ -116,8 +117,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { @@ -116,8 +117,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
116 } 117 }
117 118
118 @Override 119 @Override
119 - public List<CrmBusinessDO> getBusinessList(CrmBusinessExportReqVO exportReqVO) {  
120 - return businessMapper.selectPage(exportReqVO); 120 + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ)
  121 + public PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmContractPageReqVO pageReqVO) {
  122 + return businessMapper.selectPageByCustomer(pageReqVO);
121 } 123 }
122 124
123 @Override 125 @Override
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusService.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java
1 -package cn.iocoder.yudao.module.crm.service.businessstatus; 1 +package cn.iocoder.yudao.module.crm.service.business;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusCreateReqVO;  
5 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusExportReqVO;  
6 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusPageReqVO;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusUpdateReqVO;  
8 -import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; 4 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusPageReqVO;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO;
  7 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
9 8
10 import javax.validation.Valid; 9 import javax.validation.Valid;
11 -import java.util.Collection;  
12 import java.util.List; 10 import java.util.List;
13 11
14 /** 12 /**
@@ -24,14 +22,14 @@ public interface CrmBusinessStatusService { @@ -24,14 +22,14 @@ public interface CrmBusinessStatusService {
24 * @param createReqVO 创建信息 22 * @param createReqVO 创建信息
25 * @return 编号 23 * @return 编号
26 */ 24 */
27 - Long createBusinessStatus(@Valid CrmBusinessStatusCreateReqVO createReqVO); 25 + Long createBusinessStatus(@Valid CrmBusinessStatusSaveReqVO createReqVO);
28 26
29 /** 27 /**
30 * 更新商机状态 28 * 更新商机状态
31 * 29 *
32 * @param updateReqVO 更新信息 30 * @param updateReqVO 更新信息
33 */ 31 */
34 - void updateBusinessStatus(@Valid CrmBusinessStatusUpdateReqVO updateReqVO); 32 + void updateBusinessStatus(@Valid CrmBusinessStatusSaveReqVO updateReqVO);
35 33
36 /** 34 /**
37 * 删除商机状态 35 * 删除商机状态
@@ -49,14 +47,6 @@ public interface CrmBusinessStatusService { @@ -49,14 +47,6 @@ public interface CrmBusinessStatusService {
49 CrmBusinessStatusDO getBusinessStatus(Long id); 47 CrmBusinessStatusDO getBusinessStatus(Long id);
50 48
51 /** 49 /**
52 - * 获得商机状态列表  
53 - *  
54 - * @param ids 编号  
55 - * @return 商机状态列表  
56 - */  
57 - List<CrmBusinessStatusDO> getBusinessStatusList(Collection<Long> ids);  
58 -  
59 - /**  
60 * 获得商机状态分页 50 * 获得商机状态分页
61 * 51 *
62 * @param pageReqVO 分页查询 52 * @param pageReqVO 分页查询
@@ -64,27 +54,14 @@ public interface CrmBusinessStatusService { @@ -64,27 +54,14 @@ public interface CrmBusinessStatusService {
64 */ 54 */
65 PageResult<CrmBusinessStatusDO> getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO); 55 PageResult<CrmBusinessStatusDO> getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO);
66 56
  57 + // TODO @ljlleo 常用的 ids 之类的查询,可以封装单独的方法,不用走类似 QueryVO,用起来更方便。
  58 + // TODO @ljlleo 方法名用 getBusinessStatusList
67 /** 59 /**
68 - * 获得商机状态列表, 用于 Excel 导出  
69 - *  
70 - * @param exportReqVO 查询条件  
71 - * @return 商机状态列表  
72 - */  
73 - List<CrmBusinessStatusDO> getBusinessStatusList(CrmBusinessStatusExportReqVO exportReqVO);  
74 -  
75 - /**  
76 - * 根据类型 ID 获得商机状态列表  
77 - *  
78 - * @param typeId 商机状态类型 ID  
79 - * @return 商机状态列表  
80 - */  
81 - List<CrmBusinessStatusDO> getBusinessStatusListByTypeId(Integer typeId);  
82 -  
83 - /**  
84 - * 获得商机状态列表 60 + * 获得商机状态分页
85 * 61 *
86 - * @return 商机状态列表 62 + * @param queryVO 查询参数
  63 + * @return 商机状态分页
87 */ 64 */
88 - List<CrmBusinessStatusDO> getBusinessStatusList(); 65 + List<CrmBusinessStatusDO> selectList(CrmBusinessStatusQueryVO queryVO);
89 66
90 } 67 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImpl.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java
1 -package cn.iocoder.yudao.module.crm.service.businessstatus; 1 +package cn.iocoder.yudao.module.crm.service.business;
2 2
3 -import cn.hutool.core.collection.CollUtil;  
4 -import cn.hutool.core.collection.ListUtil;  
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusCreateReqVO;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusExportReqVO;  
8 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusPageReqVO;  
9 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusUpdateReqVO;  
10 -import cn.iocoder.yudao.module.crm.convert.businessstatus.CrmBusinessStatusConvert;  
11 -import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO;  
12 -import cn.iocoder.yudao.module.crm.dal.mysql.businessstatus.CrmBusinessStatusMapper; 4 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusPageReqVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO;
  8 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
  9 +import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusMapper;
13 import org.springframework.stereotype.Service; 10 import org.springframework.stereotype.Service;
14 import org.springframework.validation.annotation.Validated; 11 import org.springframework.validation.annotation.Validated;
15 12
16 import javax.annotation.Resource; 13 import javax.annotation.Resource;
17 -import java.util.Collection; 14 +
18 import java.util.List; 15 import java.util.List;
19 16
20 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 17 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@@ -33,20 +30,20 @@ public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService { @@ -33,20 +30,20 @@ public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService {
33 private CrmBusinessStatusMapper businessStatusMapper; 30 private CrmBusinessStatusMapper businessStatusMapper;
34 31
35 @Override 32 @Override
36 - public Long createBusinessStatus(CrmBusinessStatusCreateReqVO createReqVO) { 33 + public Long createBusinessStatus(CrmBusinessStatusSaveReqVO createReqVO) {
37 // 插入 34 // 插入
38 - CrmBusinessStatusDO businessStatus = CrmBusinessStatusConvert.INSTANCE.convert(createReqVO); 35 + CrmBusinessStatusDO businessStatus = BeanUtils.toBean(createReqVO, CrmBusinessStatusDO.class);
39 businessStatusMapper.insert(businessStatus); 36 businessStatusMapper.insert(businessStatus);
40 // 返回 37 // 返回
41 return businessStatus.getId(); 38 return businessStatus.getId();
42 } 39 }
43 40
44 @Override 41 @Override
45 - public void updateBusinessStatus(CrmBusinessStatusUpdateReqVO updateReqVO) { 42 + public void updateBusinessStatus(CrmBusinessStatusSaveReqVO updateReqVO) {
46 // 校验存在 43 // 校验存在
47 validateBusinessStatusExists(updateReqVO.getId()); 44 validateBusinessStatusExists(updateReqVO.getId());
48 // 更新 45 // 更新
49 - CrmBusinessStatusDO updateObj = CrmBusinessStatusConvert.INSTANCE.convert(updateReqVO); 46 + CrmBusinessStatusDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessStatusDO.class);
50 businessStatusMapper.updateById(updateObj); 47 businessStatusMapper.updateById(updateObj);
51 } 48 }
52 49
@@ -54,6 +51,7 @@ public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService { @@ -54,6 +51,7 @@ public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService {
54 public void deleteBusinessStatus(Long id) { 51 public void deleteBusinessStatus(Long id) {
55 // 校验存在 52 // 校验存在
56 validateBusinessStatusExists(id); 53 validateBusinessStatusExists(id);
  54 + // TODO @ljlleo 这里可以考虑,如果有商机在使用,不允许删除
57 // 删除 55 // 删除
58 businessStatusMapper.deleteById(id); 56 businessStatusMapper.deleteById(id);
59 } 57 }
@@ -70,30 +68,13 @@ public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService { @@ -70,30 +68,13 @@ public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService {
70 } 68 }
71 69
72 @Override 70 @Override
73 - public List<CrmBusinessStatusDO> getBusinessStatusList(Collection<Long> ids) {  
74 - if (CollUtil.isEmpty(ids)) {  
75 - return ListUtil.empty();  
76 - }  
77 - return businessStatusMapper.selectBatchIds(ids);  
78 - }  
79 -  
80 - @Override  
81 public PageResult<CrmBusinessStatusDO> getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO) { 71 public PageResult<CrmBusinessStatusDO> getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO) {
82 return businessStatusMapper.selectPage(pageReqVO); 72 return businessStatusMapper.selectPage(pageReqVO);
83 } 73 }
84 74
85 @Override 75 @Override
86 - public List<CrmBusinessStatusDO> getBusinessStatusList(CrmBusinessStatusExportReqVO exportReqVO) {  
87 - return businessStatusMapper.selectList(exportReqVO); 76 + public List<CrmBusinessStatusDO> selectList(CrmBusinessStatusQueryVO queryVO) {
  77 + return businessStatusMapper.selectList(queryVO);
88 } 78 }
89 79
90 - @Override  
91 - public List<CrmBusinessStatusDO> getBusinessStatusListByTypeId(Integer typeId) {  
92 - return businessStatusMapper.getBusinessStatusListByTypeId(typeId);  
93 - }  
94 -  
95 - @Override  
96 - public List<CrmBusinessStatusDO> getBusinessStatusList() {  
97 - return businessStatusMapper.selectList();  
98 - }  
99 } 80 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeService.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeService.java
1 -package cn.iocoder.yudao.module.crm.service.businessstatustype; 1 +package cn.iocoder.yudao.module.crm.service.business;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeCreateReqVO;  
5 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeExportReqVO;  
6 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypePageReqVO;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeUpdateReqVO;  
8 -import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; 4 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO;
  7 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
9 8
10 import javax.validation.Valid; 9 import javax.validation.Valid;
11 -import java.util.Collection;  
12 import java.util.List; 10 import java.util.List;
13 11
14 /** 12 /**
@@ -24,14 +22,14 @@ public interface CrmBusinessStatusTypeService { @@ -24,14 +22,14 @@ public interface CrmBusinessStatusTypeService {
24 * @param createReqVO 创建信息 22 * @param createReqVO 创建信息
25 * @return 编号 23 * @return 编号
26 */ 24 */
27 - Long createBusinessStatusType(@Valid CrmBusinessStatusTypeCreateReqVO createReqVO); 25 + Long createBusinessStatusType(@Valid CrmBusinessStatusTypeSaveReqVO createReqVO);
28 26
29 /** 27 /**
30 * 更新商机状态类型 28 * 更新商机状态类型
31 * 29 *
32 * @param updateReqVO 更新信息 30 * @param updateReqVO 更新信息
33 */ 31 */
34 - void updateBusinessStatusType(@Valid CrmBusinessStatusTypeUpdateReqVO updateReqVO); 32 + void updateBusinessStatusType(@Valid CrmBusinessStatusTypeSaveReqVO updateReqVO);
35 33
36 /** 34 /**
37 * 删除商机状态类型 35 * 删除商机状态类型
@@ -49,14 +47,6 @@ public interface CrmBusinessStatusTypeService { @@ -49,14 +47,6 @@ public interface CrmBusinessStatusTypeService {
49 CrmBusinessStatusTypeDO getBusinessStatusType(Long id); 47 CrmBusinessStatusTypeDO getBusinessStatusType(Long id);
50 48
51 /** 49 /**
52 - * 获得商机状态类型列表  
53 - *  
54 - * @param ids 编号  
55 - * @return 商机状态类型列表  
56 - */  
57 - List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(Collection<Long> ids);  
58 -  
59 - /**  
60 * 获得商机状态类型分页 50 * 获得商机状态类型分页
61 * 51 *
62 * @param pageReqVO 分页查询 52 * @param pageReqVO 分页查询
@@ -64,20 +54,13 @@ public interface CrmBusinessStatusTypeService { @@ -64,20 +54,13 @@ public interface CrmBusinessStatusTypeService {
64 */ 54 */
65 PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO); 55 PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO);
66 56
67 - /**  
68 - * 获得商机状态类型列表, 用于 Excel 导出  
69 - *  
70 - * @param exportReqVO 查询条件  
71 - * @return 商机状态类型列表  
72 - */  
73 - List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(CrmBusinessStatusTypeExportReqVO exportReqVO);  
74 - 57 + // TODO @ljlleo 常用的 ids 之类的查询,可以封装单独的方法,不用走类似 QueryVO,用起来更方便。
75 /** 58 /**
76 * 获得商机状态类型列表 59 * 获得商机状态类型列表
77 * 60 *
78 - * @param status 状态 61 + * @param queryVO 查询参数
79 * @return 商机状态类型列表 62 * @return 商机状态类型列表
80 */ 63 */
81 - List<CrmBusinessStatusTypeDO> getBusinessStatusTypeListByStatus(Integer status); 64 + List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeQueryVO queryVO);
82 65
83 } 66 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.service.business;
  2 +
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  6 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO;
  8 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
  9 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO;
  10 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
  11 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
  12 +import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusMapper;
  13 +import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusTypeMapper;
  14 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  15 +import org.springframework.stereotype.Service;
  16 +import org.springframework.transaction.annotation.Transactional;
  17 +import org.springframework.validation.annotation.Validated;
  18 +
  19 +import javax.annotation.Resource;
  20 +import java.util.List;
  21 +
  22 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  23 +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NOT_EXISTS;
  24 +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NAME_EXISTS;
  25 +
  26 +/**
  27 + * 商机状态类型 Service 实现类
  28 + *
  29 + * @author ljlleo
  30 + */
  31 +@Service
  32 +@Validated
  33 +public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeService {
  34 +
  35 + @Resource
  36 + private CrmBusinessStatusTypeMapper businessStatusTypeMapper;
  37 +
  38 + @Resource
  39 + private CrmBusinessStatusMapper businessStatusMapper;
  40 +
  41 + @Override
  42 + @Transactional(rollbackFor = Exception.class)
  43 + public Long createBusinessStatusType(CrmBusinessStatusTypeSaveReqVO createReqVO) {
  44 + //检验名称是否存在
  45 + validateBusinessStatusTypeExists(createReqVO.getName(), null);
  46 + // 插入类型
  47 + CrmBusinessStatusTypeDO businessStatusType = BeanUtils.toBean(createReqVO, CrmBusinessStatusTypeDO.class);
  48 + businessStatusTypeMapper.insert(businessStatusType);
  49 + // 插入状态
  50 + if (CollUtil.isNotEmpty(createReqVO.getStatusList())) {
  51 + createReqVO.getStatusList().forEach(status -> status.setTypeId(businessStatusType.getId()));
  52 + businessStatusMapper.insertBatch(BeanUtils.toBean(createReqVO.getStatusList(), CrmBusinessStatusDO.class));
  53 + }
  54 + return businessStatusType.getId();
  55 + }
  56 +
  57 + @Override
  58 + @Transactional(rollbackFor = Exception.class)
  59 + public void updateBusinessStatusType(CrmBusinessStatusTypeSaveReqVO updateReqVO) {
  60 + // 校验存在
  61 + validateBusinessStatusTypeExists(updateReqVO.getId());
  62 + // 校验名称是否存在
  63 + validateBusinessStatusTypeExists(updateReqVO.getName(), updateReqVO.getId());
  64 + // 更新类型
  65 + CrmBusinessStatusTypeDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessStatusTypeDO.class);
  66 + businessStatusTypeMapper.updateById(updateObj);
  67 + // 更新状态(删除 + 更新)
  68 + // TODO @ljlleo 可以参考 DeliveryExpressTemplateServiceImpl 的 updateExpressTemplateFree 方法;主要没变化的,还是不删除了哈。
  69 + businessStatusMapper.delete(updateReqVO.getId());
  70 + updateReqVO.getStatusList().forEach(status -> status.setTypeId(updateReqVO.getId()));
  71 + businessStatusMapper.insertBatch(BeanUtils.toBean(updateReqVO.getStatusList(), CrmBusinessStatusDO.class));
  72 + }
  73 +
  74 + @Override
  75 + @Transactional(rollbackFor = Exception.class)
  76 + public void deleteBusinessStatusType(Long id) {
  77 + // TODO 待添加被引用校验
  78 + //...
  79 +
  80 + // 校验存在
  81 + validateBusinessStatusTypeExists(id);
  82 + // 删除类型
  83 + businessStatusTypeMapper.deleteById(id);
  84 + // 删除状态
  85 + businessStatusMapper.delete(id);
  86 + }
  87 +
  88 + private void validateBusinessStatusTypeExists(Long id) {
  89 + if (businessStatusTypeMapper.selectById(id) == null) {
  90 + throw exception(BUSINESS_STATUS_TYPE_NOT_EXISTS);
  91 + }
  92 + }
  93 +
  94 + // TODO @ljlleo 这个方法,这个参考 validateDeptNameUnique 实现。
  95 + private void validateBusinessStatusTypeExists(String name, Long id) {
  96 + LambdaQueryWrapper<CrmBusinessStatusTypeDO> wrapper = new LambdaQueryWrapperX<>();
  97 + if(null != id) {
  98 + wrapper.ne(CrmBusinessStatusTypeDO::getId, id);
  99 + }
  100 + long cnt = businessStatusTypeMapper.selectCount(wrapper.eq(CrmBusinessStatusTypeDO::getName, name));
  101 + if (cnt > 0) {
  102 + throw exception(BUSINESS_STATUS_TYPE_NAME_EXISTS);
  103 + }
  104 + }
  105 +
  106 + @Override
  107 + public CrmBusinessStatusTypeDO getBusinessStatusType(Long id) {
  108 + return businessStatusTypeMapper.selectById(id);
  109 + }
  110 +
  111 + @Override
  112 + public PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO) {
  113 + return businessStatusTypeMapper.selectPage(pageReqVO);
  114 + }
  115 +
  116 + @Override
  117 + public List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeQueryVO queryVO) {
  118 + return businessStatusTypeMapper.selectList(queryVO);
  119 + }
  120 +
  121 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImpl.java deleted
1 -package cn.iocoder.yudao.module.crm.service.businessstatustype;  
2 -  
3 -import cn.hutool.core.collection.CollUtil;  
4 -import cn.hutool.core.collection.ListUtil;  
5 -import cn.iocoder.yudao.framework.common.pojo.PageResult;  
6 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeCreateReqVO;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeExportReqVO;  
8 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypePageReqVO;  
9 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeUpdateReqVO;  
10 -import cn.iocoder.yudao.module.crm.convert.businessstatustype.CrmBusinessStatusTypeConvert;  
11 -import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO;  
12 -import cn.iocoder.yudao.module.crm.dal.mysql.businessstatustype.CrmBusinessStatusTypeMapper;  
13 -import org.springframework.stereotype.Service;  
14 -import org.springframework.validation.annotation.Validated;  
15 -  
16 -import javax.annotation.Resource;  
17 -import java.util.Collection;  
18 -import java.util.List;  
19 -  
20 -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;  
21 -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NOT_EXISTS;  
22 -  
23 -/**  
24 - * 商机状态类型 Service 实现类  
25 - *  
26 - * @author ljlleo  
27 - */  
28 -@Service  
29 -@Validated  
30 -public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeService {  
31 -  
32 - @Resource  
33 - private CrmBusinessStatusTypeMapper businessStatusTypeMapper;  
34 -  
35 - @Override  
36 - public Long createBusinessStatusType(CrmBusinessStatusTypeCreateReqVO createReqVO) {  
37 - // TODO ljlleo:name 应该需要唯一哈;  
38 - // 插入  
39 - CrmBusinessStatusTypeDO businessStatusType = CrmBusinessStatusTypeConvert.INSTANCE.convert(createReqVO);  
40 - businessStatusTypeMapper.insert(businessStatusType);  
41 - // 返回  
42 - return businessStatusType.getId();  
43 - }  
44 -  
45 - @Override  
46 - public void updateBusinessStatusType(CrmBusinessStatusTypeUpdateReqVO updateReqVO) {  
47 - // TODO ljlleo:name 应该需要唯一哈;  
48 - // 校验存在  
49 - validateBusinessStatusTypeExists(updateReqVO.getId());  
50 - // 更新  
51 - CrmBusinessStatusTypeDO updateObj = CrmBusinessStatusTypeConvert.INSTANCE.convert(updateReqVO);  
52 - businessStatusTypeMapper.updateById(updateObj);  
53 - }  
54 -  
55 - @Override  
56 - public void deleteBusinessStatusType(Long id) {  
57 - // 校验存在  
58 - validateBusinessStatusTypeExists(id);  
59 - // TODO 艿艿:这里在看看,是不是要校验业务是否在使用;  
60 - // 删除  
61 - businessStatusTypeMapper.deleteById(id);  
62 - }  
63 -  
64 - private void validateBusinessStatusTypeExists(Long id) {  
65 - if (businessStatusTypeMapper.selectById(id) == null) {  
66 - throw exception(BUSINESS_STATUS_TYPE_NOT_EXISTS);  
67 - }  
68 - }  
69 -  
70 - @Override  
71 - public CrmBusinessStatusTypeDO getBusinessStatusType(Long id) {  
72 - return businessStatusTypeMapper.selectById(id);  
73 - }  
74 -  
75 - @Override  
76 - public List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(Collection<Long> ids) {  
77 - if (CollUtil.isEmpty(ids)) {  
78 - return ListUtil.empty();  
79 - }  
80 - return businessStatusTypeMapper.selectBatchIds(ids);  
81 - }  
82 -  
83 - @Override  
84 - public PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO) {  
85 - return businessStatusTypeMapper.selectPage(pageReqVO);  
86 - }  
87 -  
88 - @Override  
89 - public List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(CrmBusinessStatusTypeExportReqVO exportReqVO) {  
90 - return businessStatusTypeMapper.selectList(exportReqVO);  
91 - }  
92 -  
93 - @Override  
94 - public List<CrmBusinessStatusTypeDO> getBusinessStatusTypeListByStatus(Integer status) {  
95 - return businessStatusTypeMapper.getBusinessStatusTypeListByStatus(status);  
96 - }  
97 -  
98 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java deleted
1 -package cn.iocoder.yudao.module.crm.service.contact;  
2 -  
3 -import cn.hutool.core.collection.CollUtil;  
4 -import cn.hutool.core.collection.ListUtil;  
5 -import cn.iocoder.yudao.framework.common.pojo.PageResult;  
6 -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactCreateReqVO;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactExportReqVO;  
8 -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactPageReqVO;  
9 -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactUpdateReqVO;  
10 -import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;  
11 -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO;  
12 -import cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper;  
13 -import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;  
14 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;  
15 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum;  
16 -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;  
17 -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;  
18 -import org.springframework.stereotype.Service;  
19 -import org.springframework.transaction.annotation.Transactional;  
20 -import org.springframework.validation.annotation.Validated;  
21 -  
22 -import javax.annotation.Resource;  
23 -import java.util.Collection;  
24 -import java.util.List;  
25 -  
26 -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;  
27 -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_NOT_EXISTS;  
28 -  
29 -/**  
30 - * crm联系人 Service 实现类  
31 - *  
32 - * @author 芋道源码  
33 - */  
34 -@Service  
35 -@Validated  
36 -public class ContactServiceImpl implements ContactService {  
37 -  
38 - @Resource  
39 - private ContactMapper contactMapper;  
40 -  
41 - @Resource  
42 - private CrmPermissionService crmPermissionService;  
43 -  
44 - @Override // TODO @zyna:新增和修改时,关联字段要校验,例如说 直属上级,是不是真的存在;  
45 - public Long createContact(ContactCreateReqVO createReqVO, Long userId) {  
46 - // 插入  
47 - ContactDO contact = ContactConvert.INSTANCE.convert(createReqVO);  
48 - contactMapper.insert(contact);  
49 -  
50 - // 创建数据权限  
51 - crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CONTACTS.getType())  
52 - .setBizId(contact.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人  
53 -  
54 - // 返回  
55 - return contact.getId();  
56 - }  
57 -  
58 - @Override  
59 - @Transactional(rollbackFor = Exception.class)  
60 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, level = CrmPermissionLevelEnum.WRITE)  
61 - public void updateContact(ContactUpdateReqVO updateReqVO) {  
62 - // 校验存在  
63 - validateContactExists(updateReqVO.getId());  
64 - // 更新  
65 - ContactDO updateObj = ContactConvert.INSTANCE.convert(updateReqVO);  
66 - contactMapper.updateById(updateObj);  
67 - }  
68 -  
69 - @Override  
70 - @Transactional(rollbackFor = Exception.class)  
71 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, level = CrmPermissionLevelEnum.WRITE)  
72 - public void deleteContact(Long id) {  
73 - // 校验存在  
74 - validateContactExists(id);  
75 - // 删除  
76 - contactMapper.deleteById(id);  
77 - }  
78 -  
79 - private void validateContactExists(Long id) {  
80 - if (contactMapper.selectById(id) == null) {  
81 - throw exception(CONTACT_NOT_EXISTS);  
82 - }  
83 - }  
84 -  
85 - @Override  
86 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, level = CrmPermissionLevelEnum.READ)  
87 - public ContactDO getContact(Long id) {  
88 - return contactMapper.selectById(id);  
89 - }  
90 -  
91 - @Override  
92 - public List<ContactDO> getContactList(Collection<Long> ids) {  
93 - if (CollUtil.isEmpty(ids)) {  
94 - return ListUtil.empty();  
95 - }  
96 - return contactMapper.selectBatchIds(ids);  
97 - }  
98 -  
99 - @Override  
100 - public PageResult<ContactDO> getContactPage(ContactPageReqVO pageReqVO) {  
101 - return contactMapper.selectPage(pageReqVO);  
102 - }  
103 -  
104 - @Override  
105 - public List<ContactDO> getContactList(ContactExportReqVO exportReqVO) {  
106 - return contactMapper.selectList(exportReqVO);  
107 - }  
108 -  
109 - @Override  
110 - public List<ContactDO> allContactList() {  
111 - return contactMapper.selectList();  
112 - }  
113 -  
114 -}  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java
1 package cn.iocoder.yudao.module.crm.service.contact; 1 package cn.iocoder.yudao.module.crm.service.contact;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactCreateReqVO;  
5 -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactExportReqVO;  
6 -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactPageReqVO;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactUpdateReqVO;  
8 -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; 4 +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactCreateReqVO;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactUpdateReqVO;
  7 +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
  8 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
9 9
10 import javax.validation.Valid; 10 import javax.validation.Valid;
11 import java.util.Collection; 11 import java.util.Collection;
12 import java.util.List; 12 import java.util.List;
13 13
14 /** 14 /**
15 - * crm联系人 Service 接口 15 + * CRM 联系人 Service 接口
16 * 16 *
17 * @author 芋道源码 17 * @author 芋道源码
18 */ 18 */
19 -public interface ContactService { 19 +public interface CrmContactService {
20 20
21 /** 21 /**
22 - * 创建crm联系人 22 + * 创建联系人
23 * 23 *
24 * @param createReqVO 创建信息 24 * @param createReqVO 创建信息
25 * @param userId 用户编号 25 * @param userId 用户编号
26 * @return 编号 26 * @return 编号
27 */ 27 */
28 - Long createContact(@Valid ContactCreateReqVO createReqVO, Long userId); 28 + Long createContact(@Valid CrmContactCreateReqVO createReqVO, Long userId);
29 29
30 /** 30 /**
31 - * 更新crm联系人 31 + * 更新联系人
32 * 32 *
33 * @param updateReqVO 更新信息 33 * @param updateReqVO 更新信息
34 */ 34 */
35 - void updateContact(@Valid ContactUpdateReqVO updateReqVO); 35 + void updateContact(@Valid CrmContactUpdateReqVO updateReqVO);
36 36
37 /** 37 /**
38 - * 删除crm联系人 38 + * 删除联系人
39 * 39 *
40 * @param id 编号 40 * @param id 编号
41 */ 41 */
42 void deleteContact(Long id); 42 void deleteContact(Long id);
43 43
44 /** 44 /**
45 - * 获得crm联系人 45 + * 获得联系人
46 * 46 *
47 * @param id 编号 47 * @param id 编号
48 - * @return crm联系人 48 + * @return 联系人
49 */ 49 */
50 - ContactDO getContact(Long id); 50 + CrmContactDO getContact(Long id);
51 51
52 /** 52 /**
53 - * 获得crm联系人列表 53 + * 获得联系人列表
54 * 54 *
55 * @param ids 编号 55 * @param ids 编号
56 - * @return crm联系人列表 56 + * @return 联系人列表
57 */ 57 */
58 - List<ContactDO> getContactList(Collection<Long> ids); 58 + List<CrmContactDO> getContactList(Collection<Long> ids);
59 59
60 /** 60 /**
61 - * 获得crm联系人分页 61 + * 获得联系人分页
  62 + *
  63 + * 数据权限:基于 {@link CrmContactDO}
62 * 64 *
63 * @param pageReqVO 分页查询 65 * @param pageReqVO 分页查询
64 - * @return crm联系人分页 66 + * @return 联系人分页
65 */ 67 */
66 - PageResult<ContactDO> getContactPage(ContactPageReqVO pageReqVO); 68 + PageResult<CrmContactDO> getContactPage(CrmContactPageReqVO pageReqVO);
67 69
68 /** 70 /**
69 - * 获得crm联系人列表, 用于 Excel 导出 71 + * 获得联系人分页,基于指定客户
  72 + *
  73 + * 数据权限:基于 {@link CrmCustomerDO} 读取
70 * 74 *
71 - * @param exportReqVO 查询条件  
72 - * @return crm联系人列表 75 + * @param pageReqVO 分页查询
  76 + * @return 联系人分页
73 */ 77 */
74 - List<ContactDO> getContactList(ContactExportReqVO exportReqVO); 78 + PageResult<CrmContactDO> getContactPageByCustomer(CrmContactPageReqVO pageReqVO);
75 79
76 /** 80 /**
77 - * 获取所有联系人列表,只返回姓名和id 81 + * 获取所有联系人列表
  82 + *
78 * @return 所有联系人列表 83 * @return 所有联系人列表
79 */ 84 */
80 - List<ContactDO> allContactList(); 85 + List<CrmContactDO> getContactList();
  86 +
81 } 87 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.service.contact;
  2 +
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBaseVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactCreateReqVO;
  8 +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO;
  9 +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactUpdateReqVO;
  10 +import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;
  11 +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
  12 +import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper;
  13 +import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
  14 +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
  15 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
  16 +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
  17 +import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
  18 +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
  19 +import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
  20 +import org.springframework.stereotype.Service;
  21 +import org.springframework.transaction.annotation.Transactional;
  22 +import org.springframework.validation.annotation.Validated;
  23 +
  24 +import javax.annotation.Resource;
  25 +import java.util.Collection;
  26 +import java.util.List;
  27 +
  28 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  29 +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_NOT_EXISTS;
  30 +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
  31 +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS;
  32 +
  33 +/**
  34 + * CRM 联系人 Service 实现类
  35 + *
  36 + * @author 芋道源码
  37 + */
  38 +@Service
  39 +@Validated
  40 +public class CrmContactServiceImpl implements CrmContactService {
  41 +
  42 + @Resource
  43 + private CrmContactMapper contactMapper;
  44 +
  45 + @Resource
  46 + private CrmCustomerService customerService;
  47 + @Resource
  48 + private CrmPermissionService crmPermissionService;
  49 +
  50 + @Resource
  51 + private AdminUserApi adminUserApi;
  52 +
  53 + @Override
  54 + @Transactional(rollbackFor = Exception.class)
  55 + public Long createContact(CrmContactCreateReqVO createReqVO, Long userId) {
  56 + // 1.1 校验
  57 + validateRelationDataExists(createReqVO);
  58 + // 1.2 插入
  59 + CrmContactDO contact = ContactConvert.INSTANCE.convert(createReqVO);
  60 + contactMapper.insert(contact);
  61 +
  62 + // 2. 创建数据权限
  63 + crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(userId)
  64 + .setBizType(CrmBizTypeEnum.CRM_CONTACT.getType()).setBizId(contact.getId())
  65 + .setLevel(CrmPermissionLevelEnum.OWNER.getLevel()));
  66 + return contact.getId();
  67 + }
  68 +
  69 + @Override
  70 + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
  71 + public void updateContact(CrmContactUpdateReqVO updateReqVO) {
  72 + // 1. 校验存在
  73 + validateContactExists(updateReqVO.getId());
  74 + validateRelationDataExists(updateReqVO);
  75 + // 2. 更新
  76 + CrmContactDO updateObj = ContactConvert.INSTANCE.convert(updateReqVO);
  77 + contactMapper.updateById(updateObj);
  78 + }
  79 +
  80 + /**
  81 + * 校验关联的数据都存在
  82 + *
  83 + * @param saveReqVO 新增/修改请求 VO
  84 + */
  85 + private void validateRelationDataExists(CrmContactBaseVO saveReqVO){
  86 + // 1. 校验客户
  87 + if (saveReqVO.getCustomerId() != null && customerService.getCustomer(saveReqVO.getCustomerId()) == null) {
  88 + throw exception(CUSTOMER_NOT_EXISTS);
  89 + }
  90 + // 2. 校验负责人
  91 + if (saveReqVO.getOwnerUserId() != null && adminUserApi.getUser(saveReqVO.getOwnerUserId()) == null) {
  92 + throw exception(USER_NOT_EXISTS);
  93 + }
  94 + // 3. 直属上级
  95 + if (saveReqVO.getParentId() != null && contactMapper.selectById(saveReqVO.getParentId()) == null) {
  96 + throw exception(CONTACT_NOT_EXISTS);
  97 + }
  98 + }
  99 +
  100 + @Override
  101 + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE)
  102 + public void deleteContact(Long id) {
  103 + // 校验存在
  104 + validateContactExists(id);
  105 + // 删除
  106 + contactMapper.deleteById(id);
  107 + }
  108 +
  109 + private void validateContactExists(Long id) {
  110 + if (contactMapper.selectById(id) == null) {
  111 + throw exception(CONTACT_NOT_EXISTS);
  112 + }
  113 + }
  114 +
  115 + // TODO 芋艿:是否要做数据权限的校验???
  116 + @Override
  117 + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.READ)
  118 + public CrmContactDO getContact(Long id) {
  119 + return contactMapper.selectById(id);
  120 + }
  121 +
  122 + @Override
  123 + public List<CrmContactDO> getContactList(Collection<Long> ids) {
  124 + if (CollUtil.isEmpty(ids)) {
  125 + return ListUtil.empty();
  126 + }
  127 + return contactMapper.selectBatchIds(ids);
  128 + }
  129 +
  130 + @Override
  131 + public PageResult<CrmContactDO> getContactPage(CrmContactPageReqVO pageReqVO) {
  132 + // TODO puhui999:后面要改成,基于数据权限的查询
  133 + return contactMapper.selectPage(pageReqVO);
  134 + }
  135 +
  136 + @Override
  137 + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ)
  138 + public PageResult<CrmContactDO> getContactPageByCustomer(CrmContactPageReqVO pageReqVO) {
  139 + return contactMapper.selectPageByCustomer(pageReqVO);
  140 + }
  141 +
  142 + @Override
  143 + public List<CrmContactDO> getContactList() {
  144 + return contactMapper.selectList();
  145 + }
  146 +
  147 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/package-info.java deleted
1 -/**  
2 - * 联系人  
3 - */  
4 -package cn.iocoder.yudao.module.crm.service.contact;  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractService.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java
1 package cn.iocoder.yudao.module.crm.service.contract; 1 package cn.iocoder.yudao.module.crm.service.contract;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*;  
5 -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; 4 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO;
  8 +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
  9 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
6 10
7 import javax.validation.Valid; 11 import javax.validation.Valid;
8 import java.util.Collection; 12 import java.util.Collection;
9 import java.util.List; 13 import java.util.List;
10 14
11 /** 15 /**
12 - * 合同 Service 接口 16 + * CRM 合同 Service 接口
13 * 17 *
14 * @author dhb52 18 * @author dhb52
15 */ 19 */
16 -public interface ContractService { 20 +public interface CrmContractService {
17 21
18 /** 22 /**
19 * 创建合同 23 * 创建合同
@@ -22,14 +26,14 @@ public interface ContractService { @@ -22,14 +26,14 @@ public interface ContractService {
22 * @param userId 用户编号 26 * @param userId 用户编号
23 * @return 编号 27 * @return 编号
24 */ 28 */
25 - Long createContract(@Valid ContractCreateReqVO createReqVO, Long userId); 29 + Long createContract(@Valid CrmContractCreateReqVO createReqVO, Long userId);
26 30
27 /** 31 /**
28 * 更新合同 32 * 更新合同
29 * 33 *
30 * @param updateReqVO 更新信息 34 * @param updateReqVO 更新信息
31 */ 35 */
32 - void updateContract(@Valid ContractUpdateReqVO updateReqVO); 36 + void updateContract(@Valid CrmContractUpdateReqVO updateReqVO);
33 37
34 /** 38 /**
35 * 删除合同 39 * 删除合同
@@ -44,7 +48,7 @@ public interface ContractService { @@ -44,7 +48,7 @@ public interface ContractService {
44 * @param id 编号 48 * @param id 编号
45 * @return 合同 49 * @return 合同
46 */ 50 */
47 - ContractDO getContract(Long id); 51 + CrmContractDO getContract(Long id);
48 52
49 /** 53 /**
50 * 获得合同列表 54 * 获得合同列表
@@ -52,23 +56,27 @@ public interface ContractService { @@ -52,23 +56,27 @@ public interface ContractService {
52 * @param ids 编号 56 * @param ids 编号
53 * @return 合同列表 57 * @return 合同列表
54 */ 58 */
55 - List<ContractDO> getContractList(Collection<Long> ids); 59 + List<CrmContractDO> getContractList(Collection<Long> ids);
56 60
57 /** 61 /**
58 * 获得合同分页 62 * 获得合同分页
59 * 63 *
  64 + * 数据权限:基于 {@link CrmContractDO} 读取
  65 + *
60 * @param pageReqVO 分页查询 66 * @param pageReqVO 分页查询
61 * @return 合同分页 67 * @return 合同分页
62 */ 68 */
63 - PageResult<ContractDO> getContractPage(ContractPageReqVO pageReqVO); 69 + PageResult<CrmContractDO> getContractPage(CrmContractPageReqVO pageReqVO);
64 70
65 /** 71 /**
66 - * 获得合同列表, 用于 Excel 导出 72 + * 获得合同分页,基于指定客户
67 * 73 *
68 - * @param exportReqVO 查询条件  
69 - * @return 合同列表 74 + * 数据权限:基于 {@link CrmCustomerDO} 读取
  75 + *
  76 + * @param pageReqVO 分页查询
  77 + * @return 联系人分页
70 */ 78 */
71 - List<ContractDO> getContractList(ContractExportReqVO exportReqVO); 79 + PageResult<CrmContractDO> getContractPageByCustomer(CrmContractPageReqVO pageReqVO);
72 80
73 /** 81 /**
74 * 合同转移 82 * 合同转移
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImpl.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java
@@ -3,13 +3,16 @@ package cn.iocoder.yudao.module.crm.service.contract; @@ -3,13 +3,16 @@ package cn.iocoder.yudao.module.crm.service.contract;
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 import cn.hutool.core.collection.ListUtil; 4 import cn.hutool.core.collection.ListUtil;
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; 6 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
  8 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO;
  9 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO;
7 import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert; 10 import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert;
8 -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO;  
9 -import cn.iocoder.yudao.module.crm.dal.mysql.contract.ContractMapper; 11 +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
  12 +import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;
  13 +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
  14 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
10 import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; 15 import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
11 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;  
12 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum;  
13 import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; 16 import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
14 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; 17 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
15 import org.springframework.stereotype.Service; 18 import org.springframework.stereotype.Service;
@@ -24,48 +27,47 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU @@ -24,48 +27,47 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
24 import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS; 27 import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS;
25 28
26 /** 29 /**
27 - * 合同 Service 实现类 30 + * CRM 合同 Service 实现类
28 * 31 *
29 * @author dhb52 32 * @author dhb52
30 */ 33 */
31 @Service 34 @Service
32 @Validated 35 @Validated
33 -public class ContractServiceImpl implements ContractService { 36 +public class CrmContractServiceImpl implements CrmContractService {
34 37
35 @Resource 38 @Resource
36 - private ContractMapper contractMapper; 39 + private CrmContractMapper contractMapper;
37 40
38 @Resource 41 @Resource
39 private CrmPermissionService crmPermissionService; 42 private CrmPermissionService crmPermissionService;
40 43
41 @Override 44 @Override
42 - public Long createContract(ContractCreateReqVO createReqVO, Long userId) { 45 + public Long createContract(CrmContractCreateReqVO createReqVO, Long userId) {
43 // 插入 46 // 插入
44 - ContractDO contract = ContractConvert.INSTANCE.convert(createReqVO); 47 + CrmContractDO contract = ContractConvert.INSTANCE.convert(createReqVO);
45 contractMapper.insert(contract); 48 contractMapper.insert(contract);
46 49
47 // 创建数据权限 50 // 创建数据权限
48 - crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CONTRACT.getType())  
49 - .setBizId(contract.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人  
50 -  
51 - // 返回 51 + crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(userId)
  52 + .setBizType(CrmBizTypeEnum.CRM_CONTRACT.getType()).setBizId(contract.getId())
  53 + .setLevel(CrmPermissionLevelEnum.OWNER.getLevel()));
52 return contract.getId(); 54 return contract.getId();
53 } 55 }
54 56
55 @Override 57 @Override
56 @Transactional(rollbackFor = Exception.class) 58 @Transactional(rollbackFor = Exception.class)
57 @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, level = CrmPermissionLevelEnum.WRITE) 59 @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, level = CrmPermissionLevelEnum.WRITE)
58 - public void updateContract(ContractUpdateReqVO updateReqVO) { 60 + public void updateContract(CrmContractUpdateReqVO updateReqVO) {
59 // 校验存在 61 // 校验存在
60 validateContractExists(updateReqVO.getId()); 62 validateContractExists(updateReqVO.getId());
61 // 更新 63 // 更新
62 - ContractDO updateObj = ContractConvert.INSTANCE.convert(updateReqVO); 64 + CrmContractDO updateObj = ContractConvert.INSTANCE.convert(updateReqVO);
63 contractMapper.updateById(updateObj); 65 contractMapper.updateById(updateObj);
64 } 66 }
65 67
66 @Override 68 @Override
67 @Transactional(rollbackFor = Exception.class) 69 @Transactional(rollbackFor = Exception.class)
68 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, level = CrmPermissionLevelEnum.WRITE) 70 + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE)
69 public void deleteContract(Long id) { 71 public void deleteContract(Long id) {
70 // 校验存在 72 // 校验存在
71 validateContractExists(id); 73 validateContractExists(id);
@@ -73,22 +75,23 @@ public class ContractServiceImpl implements ContractService { @@ -73,22 +75,23 @@ public class ContractServiceImpl implements ContractService {
73 contractMapper.deleteById(id); 75 contractMapper.deleteById(id);
74 } 76 }
75 77
76 - private ContractDO validateContractExists(Long id) {  
77 - ContractDO contract = contractMapper.selectById(id); 78 + private CrmContractDO validateContractExists(Long id) {
  79 + CrmContractDO contract = contractMapper.selectById(id);
78 if (contract == null) { 80 if (contract == null) {
79 throw exception(CONTRACT_NOT_EXISTS); 81 throw exception(CONTRACT_NOT_EXISTS);
80 } 82 }
81 return contract; 83 return contract;
82 } 84 }
83 85
  86 + // TODO 芋艿:是否要做数据权限的校验???
84 @Override 87 @Override
85 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, level = CrmPermissionLevelEnum.READ)  
86 - public ContractDO getContract(Long id) { 88 + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.READ)
  89 + public CrmContractDO getContract(Long id) {
87 return contractMapper.selectById(id); 90 return contractMapper.selectById(id);
88 } 91 }
89 92
90 @Override 93 @Override
91 - public List<ContractDO> getContractList(Collection<Long> ids) { 94 + public List<CrmContractDO> getContractList(Collection<Long> ids) {
92 if (CollUtil.isEmpty(ids)) { 95 if (CollUtil.isEmpty(ids)) {
93 return ListUtil.empty(); 96 return ListUtil.empty();
94 } 97 }
@@ -96,13 +99,14 @@ public class ContractServiceImpl implements ContractService { @@ -96,13 +99,14 @@ public class ContractServiceImpl implements ContractService {
96 } 99 }
97 100
98 @Override 101 @Override
99 - public PageResult<ContractDO> getContractPage(ContractPageReqVO pageReqVO) { 102 + public PageResult<CrmContractDO> getContractPage(CrmContractPageReqVO pageReqVO) {
100 return contractMapper.selectPage(pageReqVO); 103 return contractMapper.selectPage(pageReqVO);
101 } 104 }
102 105
103 @Override 106 @Override
104 - public List<ContractDO> getContractList(ContractExportReqVO exportReqVO) {  
105 - return contractMapper.selectList(exportReqVO); 107 + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ)
  108 + public PageResult<CrmContractDO> getContractPageByCustomer(CrmContractPageReqVO pageReqVO) {
  109 + return contractMapper.selectPageByCustomer(pageReqVO);
106 } 110 }
107 111
108 @Override 112 @Override
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/package-info.java deleted
1 -/**  
2 - * 合同  
3 - */  
4 -package cn.iocoder.yudao.module.crm.service.contract;  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigService.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigService.java
1 -package cn.iocoder.yudao.module.crm.service.customerlimitconfig; 1 +package cn.iocoder.yudao.module.crm.service.customer;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigCreateReqVO;  
5 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigPageReqVO;  
6 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigUpdateReqVO;  
7 -import cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig.CrmCustomerLimitConfigDO; 4 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO;
  7 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
8 8
9 import javax.validation.Valid; 9 import javax.validation.Valid;
10 10
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImpl.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java
1 -package cn.iocoder.yudao.module.crm.service.customerlimitconfig; 1 +package cn.iocoder.yudao.module.crm.service.customer;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigCreateReqVO;  
5 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigPageReqVO;  
6 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigUpdateReqVO; 4 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO;
7 import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert; 7 import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert;
8 -import cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig.CrmCustomerLimitConfigDO; 8 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
9 import cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig.CrmCustomerLimitConfigMapper; 9 import cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig.CrmCustomerLimitConfigMapper;
10 import cn.iocoder.yudao.module.system.api.dept.DeptApi; 10 import cn.iocoder.yudao.module.system.api.dept.DeptApi;
11 import cn.iocoder.yudao.module.system.api.user.AdminUserApi; 11 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigService.java
1 package cn.iocoder.yudao.module.crm.service.customer; 1 package cn.iocoder.yudao.module.crm.service.customer;
2 2
3 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPoolConfigUpdateReqVO; 3 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO;
4 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; 4 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
5 5
6 import javax.validation.Valid; 6 import javax.validation.Valid;
@@ -24,6 +24,6 @@ public interface CrmCustomerPoolConfigService { @@ -24,6 +24,6 @@ public interface CrmCustomerPoolConfigService {
24 * 24 *
25 * @param saveReqVO 更新信息 25 * @param saveReqVO 更新信息
26 */ 26 */
27 - void updateCustomerPoolConfig(@Valid CrmCustomerPoolConfigUpdateReqVO saveReqVO); 27 + void saveCustomerPoolConfig(@Valid CrmCustomerPoolConfigSaveReqVO saveReqVO);
28 28
29 } 29 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java
1 package cn.iocoder.yudao.module.crm.service.customer; 1 package cn.iocoder.yudao.module.crm.service.customer;
2 2
3 -import cn.hutool.core.util.BooleanUtil;  
4 -import cn.hutool.core.util.ObjectUtil;  
5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 3 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPoolConfigUpdateReqVO; 4 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO;
7 import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; 5 import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert;
8 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; 6 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
9 import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerPoolConfigMapper; 7 import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerPoolConfigMapper;
@@ -13,9 +11,6 @@ import org.springframework.validation.annotation.Validated; @@ -13,9 +11,6 @@ import org.springframework.validation.annotation.Validated;
13 import javax.annotation.Resource; 11 import javax.annotation.Resource;
14 import java.util.Objects; 12 import java.util.Objects;
15 13
16 -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;  
17 -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_POOL_CONFIG_ERROR;  
18 -  
19 /** 14 /**
20 * 客户公海配置 Service 实现类 15 * 客户公海配置 Service 实现类
21 * 16 *
@@ -43,15 +38,7 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe @@ -43,15 +38,7 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe
43 * @param saveReqVO 更新信息 38 * @param saveReqVO 更新信息
44 */ 39 */
45 @Override 40 @Override
46 - public void updateCustomerPoolConfig(CrmCustomerPoolConfigUpdateReqVO saveReqVO) {  
47 - // TODO @wanwan:看下 @AssertTrue 的逻辑;  
48 - if (BooleanUtil.isTrue(saveReqVO.getEnabled()) && (ObjectUtil.hasNull(saveReqVO.getContactExpireDays(), saveReqVO.getDealExpireDays()))) {  
49 - throw exception(CUSTOMER_POOL_CONFIG_ERROR);  
50 - }  
51 - if (BooleanUtil.isTrue(saveReqVO.getNotifyEnabled()) && (Objects.isNull(saveReqVO.getNotifyDays()))) {  
52 - throw exception(CUSTOMER_POOL_CONFIG_ERROR);  
53 - }  
54 - 41 + public void saveCustomerPoolConfig(CrmCustomerPoolConfigSaveReqVO saveReqVO) {
55 // 存在,则进行更新 42 // 存在,则进行更新
56 CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig(); 43 CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig();
57 if (Objects.nonNull(dbConfig)) { 44 if (Objects.nonNull(dbConfig)) {
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java
1 package cn.iocoder.yudao.module.crm.service.customer; 1 package cn.iocoder.yudao.module.crm.service.customer;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; 4 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO;
5 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; 8 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
6 9
7 import javax.validation.Valid; 10 import javax.validation.Valid;
  11 +import java.util.Collection;
8 import java.util.List; 12 import java.util.List;
9 13
10 /** 14 /**
@@ -46,6 +50,15 @@ public interface CrmCustomerService { @@ -46,6 +50,15 @@ public interface CrmCustomerService {
46 CrmCustomerDO getCustomer(Long id); 50 CrmCustomerDO getCustomer(Long id);
47 51
48 /** 52 /**
  53 + * 获得客户列表
  54 + *
  55 + * @param ids 客户编号数组
  56 + * @return 客户列表
  57 + * @author ljlleo
  58 + */
  59 + List<CrmCustomerDO> getCustomerList(Collection<Long> ids);
  60 +
  61 + /**
49 * 获得客户分页 62 * 获得客户分页
50 * 63 *
51 * @param pageReqVO 分页查询 64 * @param pageReqVO 分页查询
@@ -55,14 +68,6 @@ public interface CrmCustomerService { @@ -55,14 +68,6 @@ public interface CrmCustomerService {
55 PageResult<CrmCustomerDO> getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId); 68 PageResult<CrmCustomerDO> getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId);
56 69
57 /** 70 /**
58 - * 获得客户列表, 用于 Excel 导出  
59 - *  
60 - * @param exportReqVO 查询条件  
61 - * @return 客户列表  
62 - */  
63 - List<CrmCustomerDO> getCustomerList(CrmCustomerExportReqVO exportReqVO);  
64 -  
65 - /**  
66 * 校验客户是否存在 71 * 校验客户是否存在
67 * 72 *
68 * @param customerId 客户 id 73 * @param customerId 客户 id
@@ -85,22 +90,27 @@ public interface CrmCustomerService { @@ -85,22 +90,27 @@ public interface CrmCustomerService {
85 */ 90 */
86 void lockCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO); 91 void lockCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO);
87 92
88 - // TODO @xiaqing:根据 controller 的建议,改下 93 + // ==================== 公海相关操作 ====================
  94 +
89 /** 95 /**
90 - * 领取公海客户 96 + * 客户放入公海
91 * 97 *
92 - * @param ids 要领取的客户 id 98 + * @param id 客户编号
93 */ 99 */
94 - void receive(List<Long>ids); 100 + void putCustomerPool(Long id);
95 101
96 - // TODO @xiaqing:根据 controller 的建议,改下  
97 /** 102 /**
98 - * 分配公海客户 103 + * 领取公海客户
99 * 104 *
100 - * @param cIds 要分配的客户 id  
101 - * @param ownerId 分配的负责人id  
102 - * @author xiaqing 105 + * @param ids 要领取的客户编号数组
  106 + * @param ownerUserId 负责人
103 */ 107 */
104 - void distributeByIds(List<Long>cIds,Long ownerId); 108 + void receiveCustomer(List<Long> ids, Long ownerUserId);
105 109
  110 + /**
  111 + * 获取客户列表
  112 + * @return 客户列表
  113 + * @author zyna
  114 + */
  115 + List<CrmCustomerDO> getCustomerList();
106 } 116 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
1 package cn.iocoder.yudao.module.crm.service.customer; 1 package cn.iocoder.yudao.module.crm.service.customer;
2 2
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 -import cn.hutool.core.util.ObjUtil;  
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;  
7 -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;  
8 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; 5 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO;
  8 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO;
9 import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; 9 import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert;
10 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; 10 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
11 -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;  
12 import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; 11 import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper;
13 -import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerSceneEnum;  
14 import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; 12 import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
15 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;  
16 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 13 +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
  14 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
17 import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; 15 import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
18 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; 16 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
  17 +import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
19 import org.springframework.stereotype.Service; 18 import org.springframework.stereotype.Service;
20 import org.springframework.transaction.annotation.Transactional; 19 import org.springframework.transaction.annotation.Transactional;
21 import org.springframework.validation.annotation.Validated; 20 import org.springframework.validation.annotation.Validated;
@@ -24,8 +23,8 @@ import javax.annotation.Resource; @@ -24,8 +23,8 @@ import javax.annotation.Resource;
24 import java.util.*; 23 import java.util.*;
25 24
26 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 25 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
27 -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;  
28 import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; 26 import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
  27 +import static java.util.Collections.singletonList;
29 28
30 /** 29 /**
31 * 客户 Service 实现类 30 * 客户 Service 实现类
@@ -38,10 +37,15 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @@ -38,10 +37,15 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
38 37
39 @Resource 38 @Resource
40 private CrmCustomerMapper customerMapper; 39 private CrmCustomerMapper customerMapper;
  40 +
41 @Resource 41 @Resource
42 private CrmPermissionService crmPermissionService; 42 private CrmPermissionService crmPermissionService;
43 43
  44 + @Resource
  45 + private AdminUserApi adminUserApi;
  46 +
44 @Override 47 @Override
  48 + @Transactional(rollbackFor = Exception.class)
45 public Long createCustomer(CrmCustomerCreateReqVO createReqVO, Long userId) { 49 public Long createCustomer(CrmCustomerCreateReqVO createReqVO, Long userId) {
46 // 插入 50 // 插入
47 CrmCustomerDO customer = CrmCustomerConvert.INSTANCE.convert(createReqVO); 51 CrmCustomerDO customer = CrmCustomerConvert.INSTANCE.convert(createReqVO);
@@ -50,8 +54,6 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @@ -50,8 +54,6 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
50 // 创建数据权限 54 // 创建数据权限
51 crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) 55 crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType())
52 .setBizId(customer.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 56 .setBizId(customer.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人
53 -  
54 - // 返回  
55 return customer.getId(); 57 return customer.getId();
56 } 58 }
57 59
@@ -91,33 +93,21 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @@ -91,33 +93,21 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
91 } 93 }
92 94
93 @Override 95 @Override
94 - public PageResult<CrmCustomerDO> getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId) {  
95 - // 1.1 TODO 如果是超级管理员  
96 - boolean admin = false;  
97 - if (admin && ObjUtil.notEqual(userId, CrmPermissionDO.POOL_USER_ID)) {  
98 - return customerMapper.selectPage(pageReqVO, Collections.emptyList()); 96 + public List<CrmCustomerDO> getCustomerList(Collection<Long> ids) {
  97 + if (CollUtil.isEmpty(ids)) {
  98 + return Collections.emptyList();
99 } 99 }
100 - // 1.2 获取当前用户能看的分页数据  
101 - // TODO @puhui999:如果业务的数据量比较大,in 太多可能有性能问题噢;看看是不是搞成 join 连表了;可以微信讨论下;  
102 - List<CrmPermissionDO> permissions = crmPermissionService.getPermissionListByBizTypeAndUserId(  
103 - CrmBizTypeEnum.CRM_CUSTOMER.getType(), userId);  
104 - // 1.3 TODO 场景数据过滤  
105 - if (CrmCustomerSceneEnum.isOwner(pageReqVO.getSceneType())) { // 场景一:我负责的数据  
106 - permissions = CollectionUtils.filterList(permissions, item -> CrmPermissionLevelEnum.isOwner(item.getLevel()));  
107 - }  
108 - Set<Long> ids = convertSet(permissions, CrmPermissionDO::getBizId);  
109 - if (CollUtil.isEmpty(ids)) { // 没得说明没有什么给他看的  
110 - return PageResult.empty();  
111 - }  
112 -  
113 - // 2. 获取客户分页数据  
114 - return customerMapper.selectPage(pageReqVO, ids); 100 + return customerMapper.selectBatchIds(ids);
115 } 101 }
116 102
117 @Override 103 @Override
118 - public List<CrmCustomerDO> getCustomerList(CrmCustomerExportReqVO exportReqVO) {  
119 - //return customerMapper.selectList(exportReqVO);  
120 - return Collections.emptyList(); 104 + public PageResult<CrmCustomerDO> getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId) {
  105 + boolean admin = false;
  106 + if (admin) { // 1.1. 情况一: TODO 如果是管理员; TODO @puhui999:要不如果是超管,就复用 selectPage;
  107 + customerMapper.selectPageWithAdmin(pageReqVO, userId);
  108 + }
  109 + // 1.2. 情况二:获取当前用户能看的分页数据
  110 + return customerMapper.selectPage(pageReqVO, userId);
121 } 111 }
122 112
123 /** 113 /**
@@ -137,8 +127,9 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @@ -137,8 +127,9 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
137 127
138 @Override 128 @Override
139 @Transactional(rollbackFor = Exception.class) 129 @Transactional(rollbackFor = Exception.class)
  130 + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER)
140 public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) { 131 public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) {
141 - // 1. 校验合同是否存在 132 + // 1. 校验客户是否存在
142 validateCustomer(reqVO.getId()); 133 validateCustomer(reqVO.getId());
143 134
144 // 2. 数据权限转移 135 // 2. 数据权限转移
@@ -162,55 +153,94 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @@ -162,55 +153,94 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
162 153
163 @Override 154 @Override
164 @Transactional(rollbackFor = Exception.class) 155 @Transactional(rollbackFor = Exception.class)
165 - public void receive(List <Long> ids) {  
166 - transferCustomerOwner(ids,SecurityFrameworkUtils.getLoginUserId()); 156 + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
  157 + public void putCustomerPool(Long id) {
  158 + // 1. 校验存在
  159 + CrmCustomerDO customer = customerMapper.selectById(id);
  160 + if (customer == null) {
  161 + throw exception(CUSTOMER_NOT_EXISTS);
  162 + }
  163 + // 1.2. 校验是否为公海数据
  164 + validateCustomerOwnerExists(customer, true);
  165 + // 1.3. 校验客户是否锁定
  166 + validateCustomerIsLocked(customer, true);
  167 +
  168 + // 2. 设置负责人为 NULL
  169 + int updateOwnerUserIncr = customerMapper.updateOwnerUserIdById(customer.getId(), null);
  170 + if (updateOwnerUserIncr == 0) {
  171 + throw exception(CUSTOMER_UPDATE_OWNER_USER_FAIL);
  172 + }
  173 + // 3. 删除负责人数据权限
  174 + crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customer.getId(),
  175 + CrmPermissionLevelEnum.OWNER.getLevel());
167 } 176 }
168 177
169 @Override 178 @Override
170 - public void distributeByIds(List <Long> cIds, Long ownerId) {  
171 - transferCustomerOwner(cIds,ownerId);  
172 - }  
173 -  
174 - private void transferCustomerOwner(List <Long> cIds, Long ownerId){  
175 - // 先一次性校验完成客户是否可用  
176 - // TODO @xiaqing:批量一次性加载客户列表,然后去逐个校验;  
177 - for (Long cId : cIds) {  
178 - //校验是否存在  
179 - validateCustomerExists(cId);  
180 - //todo 校验是否已有负责人  
181 - validCustomerOwnerExist(cId);  
182 - //todo 校验是否锁定  
183 - validCustomerIsLocked(cId);  
184 - //todo 校验成交状态  
185 - validCustomerDeal(cId); 179 + @Transactional(rollbackFor = Exception.class)
  180 + public void receiveCustomer(List<Long> ids, Long ownerUserId) {
  181 + // 1.1 校验存在
  182 + List<CrmCustomerDO> customers = customerMapper.selectBatchIds(ids);
  183 + if (customers.size() != ids.size()) {
  184 + throw exception(CUSTOMER_NOT_EXISTS);
186 } 185 }
187 - // TODO @xiaqing:每个客户更新的时候,where 条件,加上 owner_user_id is null,防止并发问题;  
188 - List<CrmCustomerDO> updateDos = new ArrayList <>();  
189 - for (Long cId : cIds){  
190 - CrmCustomerDO customerDO = new CrmCustomerDO();  
191 - customerDO.setId(cId);  
192 - customerDO.setOwnerUserId(SecurityFrameworkUtils.getLoginUserId()); 186 + // 1.2. 校验负责人是否存在
  187 + adminUserApi.validateUserList(singletonList(ownerUserId));
  188 + // 1.3. 校验状态
  189 + customers.forEach(customer -> {
  190 + // 校验是否已有负责人
  191 + validateCustomerOwnerExists(customer, false);
  192 + // 校验是否锁定
  193 + validateCustomerIsLocked(customer, false);
  194 + // 校验成交状态
  195 + validateCustomerDeal(customer);
  196 + });
  197 +
  198 + // 2. 领取公海数据
  199 + List<CrmCustomerDO> updateCustomers = new ArrayList<>();
  200 + List<CrmPermissionCreateReqBO> createPermissions = new ArrayList<>();
  201 + customers.forEach(customer -> {
  202 + // 2.1. 设置负责人
  203 + updateCustomers.add(new CrmCustomerDO().setId(customer.getId()).setOwnerUserId(ownerUserId));
  204 + // 2.2. 创建负责人数据权限
  205 + createPermissions.add(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType())
  206 + .setBizId(customer.getId()).setUserId(ownerUserId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel()));
  207 + });
  208 +
  209 + // 3.1 更新客户负责人
  210 + customerMapper.updateBatch(updateCustomers);
  211 + // 3.2 创建负责人数据权限
  212 + crmPermissionService.createPermissionBatch(createPermissions);
  213 + }
  214 +
  215 + private void validateCustomerOwnerExists(CrmCustomerDO customer, Boolean pool) {
  216 + if (customer == null) { // 防御一下
  217 + throw exception(CUSTOMER_NOT_EXISTS);
193 } 218 }
194 - // 统一修改状态  
195 - customerMapper.updateBatch(updateDos);  
196 - }  
197 -  
198 - private void validCustomerOwnerExist(Long id) {  
199 - if (customerMapper.selectById(id).getOwnerUserId()!=null) {  
200 - throw exception(CUSTOMER_OWNER_EXISTS); 219 + // 校验是否为公海数据
  220 + if (pool && customer.getOwnerUserId() == null) {
  221 + throw exception(CUSTOMER_IN_POOL, customer.getName());
  222 + }
  223 + // 负责人已存在
  224 + if (customer.getOwnerUserId() != null) {
  225 + throw exception(CUSTOMER_OWNER_EXISTS, customer.getName());
201 } 226 }
202 } 227 }
203 228
204 - private void validCustomerIsLocked(Long id) {  
205 - if (customerMapper.selectById(id).getLockStatus() ==true) {  
206 - throw exception(CUSTOMER_LOCKED); 229 + private void validateCustomerIsLocked(CrmCustomerDO customer, Boolean pool) {
  230 + if (customer.getLockStatus()) {
  231 + throw exception(pool ? CUSTOMER_LOCKED_PUT_POOL_FAIL : CUSTOMER_LOCKED, customer.getName());
207 } 232 }
208 } 233 }
209 234
210 - private void validCustomerDeal(Long id) {  
211 - if (customerMapper.selectById(id).getDealStatus() ==true) { 235 + private void validateCustomerDeal(CrmCustomerDO customer) {
  236 + if (customer.getDealStatus()) {
212 throw exception(CUSTOMER_ALREADY_DEAL); 237 throw exception(CUSTOMER_ALREADY_DEAL);
213 } 238 }
214 } 239 }
215 240
  241 + @Override
  242 + public List<CrmCustomerDO> getCustomerList() {
  243 + return customerMapper.selectList();
  244 + }
  245 +
216 } 246 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/package-info.java deleted
1 -/**  
2 - * 客户  
3 - */  
4 -package cn.iocoder.yudao.module.crm.service.customer;  
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java
@@ -3,7 +3,8 @@ package cn.iocoder.yudao.module.crm.service.permission; @@ -3,7 +3,8 @@ package cn.iocoder.yudao.module.crm.service.permission;
3 3
4 import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO; 4 import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO;
5 import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; 5 import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
6 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum; 6 +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
  7 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
7 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; 8 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
8 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; 9 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
9 10
@@ -21,10 +22,17 @@ public interface CrmPermissionService { @@ -21,10 +22,17 @@ public interface CrmPermissionService {
21 /** 22 /**
22 * 创建数据权限 23 * 创建数据权限
23 * 24 *
24 - * @param createBO 创建信息 25 + * @param createReqBO 创建信息
25 * @return 编号 26 * @return 编号
26 */ 27 */
27 - Long createPermission(@Valid CrmPermissionCreateReqBO createBO); 28 + Long createPermission(@Valid CrmPermissionCreateReqBO createReqBO);
  29 +
  30 + /**
  31 + * 创建数据权限
  32 + *
  33 + * @param createReqBOs 创建信息
  34 + */
  35 + void createPermissionBatch(@Valid List<CrmPermissionCreateReqBO> createReqBOs);
28 36
29 /** 37 /**
30 * 更新数据权限 38 * 更新数据权限
@@ -34,56 +42,45 @@ public interface CrmPermissionService { @@ -34,56 +42,45 @@ public interface CrmPermissionService {
34 void updatePermission(CrmPermissionUpdateReqVO updateReqVO); 42 void updatePermission(CrmPermissionUpdateReqVO updateReqVO);
35 43
36 /** 44 /**
37 - * 删除数据权限 45 + * 数据权限转移
38 * 46 *
39 - * @param ids 编号 47 + * @param crmPermissionTransferReqBO 数据权限转移请求
40 */ 48 */
41 - void deletePermission(Collection<Long> ids); 49 + void transferPermission(@Valid CrmPermissionTransferReqBO crmPermissionTransferReqBO);
42 50
43 /** 51 /**
44 - * 获取用户数据权限通过 数据类型 x 某个数据 x 用户编号 52 + * 删除数据权限
45 * 53 *
46 * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} 54 * @param bizType 数据类型,关联 {@link CrmBizTypeEnum}
47 * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() 55 * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId()
48 - * @param userId 用户编号,AdminUser#id  
49 - * @return Crm 数据权限 56 + * @param level 数据权限级别,关联 {@link CrmPermissionLevelEnum}
50 */ 57 */
51 - CrmPermissionDO getPermissionByBizTypeAndBizIdAndUserId(Integer bizType, Long bizId, Long userId); 58 + void deletePermission(Integer bizType, Long bizId, Integer level);
52 59
53 /** 60 /**
54 - * 获取用户数据权限通过 权限编号 x 用户编号 61 + * 批量删除数据权限
55 * 62 *
56 - * @param id 权限编号 63 + * @param ids 权限编号
57 * @param userId 用户编号 64 * @param userId 用户编号
58 - * @return 数据权限  
59 */ 65 */
60 - CrmPermissionDO getPermissionByIdAndUserId(Long id, Long userId); 66 + void deletePermissionBatch(Collection<Long> ids, Long userId);
61 67
62 /** 68 /**
63 - * 获取数据权限列表,通过 数据类型 x 某个数据 69 + * 删除指定用户数据权限
64 * 70 *
65 - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum}  
66 - * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId()  
67 - * @return Crm 数据权限列表 71 + * @param id 权限编号
  72 + * @param userId 用户编号
68 */ 73 */
69 - List<CrmPermissionDO> getPermissionByBizTypeAndBizId(Integer bizType, Long bizId); 74 + void deleteSelfPermission(Long id, Long userId);
70 75
71 /** 76 /**
72 * 获取数据权限列表,通过 数据类型 x 某个数据 77 * 获取数据权限列表,通过 数据类型 x 某个数据
73 * 78 *
74 * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} 79 * @param bizType 数据类型,关联 {@link CrmBizTypeEnum}
75 - * @param bizIds 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId()  
76 - * @param level 权限级别 80 + * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId()
77 * @return Crm 数据权限列表 81 * @return Crm 数据权限列表
78 */ 82 */
79 - List<CrmPermissionDO> getPermissionByBizTypeAndBizIdsAndLevel(Integer bizType, Collection<Long> bizIds, Integer level);  
80 -  
81 - /**  
82 - * 数据权限转移  
83 - *  
84 - * @param crmPermissionTransferReqBO 数据权限转移请求  
85 - */  
86 - void transferPermission(@Valid CrmPermissionTransferReqBO crmPermissionTransferReqBO); 83 + List<CrmPermissionDO> getPermissionListByBiz(Integer bizType, Long bizId);
87 84
88 /** 85 /**
89 * 获取用户参与的模块数据列表 86 * 获取用户参与的模块数据列表
@@ -94,22 +91,4 @@ public interface CrmPermissionService { @@ -94,22 +91,4 @@ public interface CrmPermissionService {
94 */ 91 */
95 List<CrmPermissionDO> getPermissionListByBizTypeAndUserId(Integer bizType, Long userId); 92 List<CrmPermissionDO> getPermissionListByBizTypeAndUserId(Integer bizType, Long userId);
96 93
97 - /**  
98 - * 领取公海数据  
99 - *  
100 - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum}  
101 - * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId()  
102 - * @param userId 用户编号,AdminUser#id  
103 - */  
104 - void receiveBiz(Integer bizType, Long bizId, Long userId);  
105 -  
106 - /**  
107 - * 数据放入公海  
108 - *  
109 - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum}  
110 - * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId()  
111 - * @param userId 用户编号,AdminUser#id  
112 - */  
113 - void putPool(Integer bizType, Long bizId, Long userId);  
114 -  
115 } 94 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java
@@ -6,8 +6,8 @@ import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionU @@ -6,8 +6,8 @@ import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionU
6 import cn.iocoder.yudao.module.crm.convert.permission.CrmPermissionConvert; 6 import cn.iocoder.yudao.module.crm.convert.permission.CrmPermissionConvert;
7 import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; 7 import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
8 import cn.iocoder.yudao.module.crm.dal.mysql.permission.CrmPermissionMapper; 8 import cn.iocoder.yudao.module.crm.dal.mysql.permission.CrmPermissionMapper;
9 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;  
10 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 9 +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
  10 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
11 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; 11 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
12 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; 12 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
13 import cn.iocoder.yudao.module.system.api.user.AdminUserApi; 13 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
@@ -21,10 +21,10 @@ import java.util.Collections; @@ -21,10 +21,10 @@ import java.util.Collections;
21 import java.util.List; 21 import java.util.List;
22 22
23 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 23 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  24 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
24 import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; 25 import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
25 -import static cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum.isOwner; 26 +import static cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum.isOwner;
26 27
27 -// TODO @puhui999:尽量规避用“团队”这个词哈;这个只是我们给前端展示用的;  
28 /** 28 /**
29 * CRM 数据权限 Service 接口实现类 29 * CRM 数据权限 Service 接口实现类
30 * 30 *
@@ -42,59 +42,41 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { @@ -42,59 +42,41 @@ public class CrmPermissionServiceImpl implements CrmPermissionService {
42 42
43 @Override 43 @Override
44 @Transactional(rollbackFor = Exception.class) 44 @Transactional(rollbackFor = Exception.class)
45 - public Long createPermission(CrmPermissionCreateReqBO createBO) { 45 + public Long createPermission(CrmPermissionCreateReqBO createReqBO) {
  46 + // TODO @puhui999:排重
46 // 1. 校验用户是否存在 47 // 1. 校验用户是否存在
47 - adminUserApi.validateUserList(Collections.singletonList(createBO.getUserId())); 48 + adminUserApi.validateUserList(Collections.singletonList(createReqBO.getUserId()));
48 49
49 // 2. 创建 50 // 2. 创建
50 - CrmPermissionDO permission = CrmPermissionConvert.INSTANCE.convert(createBO); 51 + CrmPermissionDO permission = CrmPermissionConvert.INSTANCE.convert(createReqBO);
51 crmPermissionMapper.insert(permission); 52 crmPermissionMapper.insert(permission);
52 return permission.getId(); 53 return permission.getId();
53 } 54 }
54 55
55 @Override 56 @Override
56 - @Transactional(rollbackFor = Exception.class)  
57 - public void updatePermission(CrmPermissionUpdateReqVO updateReqVO) {  
58 - // 校验存在  
59 - validateCrmPermissionExists(updateReqVO.getIds()); 57 + public void createPermissionBatch(List<CrmPermissionCreateReqBO> createReqBOs) {
  58 + // TODO @puhui999:排重
  59 + // 1. 校验用户是否存在
  60 + adminUserApi.validateUserList(convertSet(createReqBOs, CrmPermissionCreateReqBO::getUserId));
60 61
61 - List<CrmPermissionDO> updateDO = CrmPermissionConvert.INSTANCE.convertList(updateReqVO);  
62 - crmPermissionMapper.updateBatch(updateDO); 62 + // 2. 创建
  63 + List<CrmPermissionDO> permissions = CrmPermissionConvert.INSTANCE.convertList(createReqBOs);
  64 + crmPermissionMapper.insertBatch(permissions);
63 } 65 }
64 66
65 @Override 67 @Override
66 @Transactional(rollbackFor = Exception.class) 68 @Transactional(rollbackFor = Exception.class)
67 - public void deletePermission(Collection<Long> ids) {  
68 - // 校验存在  
69 - validateCrmPermissionExists(ids);  
70 -  
71 - // 删除  
72 - crmPermissionMapper.deleteBatchIds(ids);  
73 - }  
74 -  
75 - @Override  
76 - public CrmPermissionDO getPermissionByBizTypeAndBizIdAndUserId(Integer bizType, Long bizId, Long userId) {  
77 - return crmPermissionMapper.selectByBizTypeAndBizIdByUserId(bizType, bizId, userId);  
78 - }  
79 -  
80 - @Override  
81 - public CrmPermissionDO getPermissionByIdAndUserId(Long id, Long userId) {  
82 - return crmPermissionMapper.selectByIdAndUserId(id, userId);  
83 - }  
84 -  
85 - @Override  
86 - public List<CrmPermissionDO> getPermissionByBizTypeAndBizId(Integer bizType, Long bizId) {  
87 - return crmPermissionMapper.selectByBizTypeAndBizId(bizType, bizId);  
88 - }  
89 -  
90 - @Override  
91 - public List<CrmPermissionDO> getPermissionByBizTypeAndBizIdsAndLevel(Integer bizType, Collection<Long> bizIds, Integer level) {  
92 - return crmPermissionMapper.selectListByBizTypeAndBizIdsAndLevel(bizType, bizIds, level); 69 + public void updatePermission(CrmPermissionUpdateReqVO updateReqVO) {
  70 + // TODO @puhui999:排重
  71 + // 1. 校验存在
  72 + validateCrmPermissionExists(updateReqVO.getIds());
  73 + // 2. 更新
  74 + List<CrmPermissionDO> updateDO = CrmPermissionConvert.INSTANCE.convertList(updateReqVO);
  75 + crmPermissionMapper.updateBatch(updateDO);
93 } 76 }
94 77
95 private void validateCrmPermissionExists(Collection<Long> ids) { 78 private void validateCrmPermissionExists(Collection<Long> ids) {
96 List<CrmPermissionDO> permissionList = crmPermissionMapper.selectBatchIds(ids); 79 List<CrmPermissionDO> permissionList = crmPermissionMapper.selectBatchIds(ids);
97 - // 校验存在  
98 if (ObjUtil.notEqual(permissionList.size(), ids.size())) { 80 if (ObjUtil.notEqual(permissionList.size(), ids.size())) {
99 throw exception(CRM_PERMISSION_NOT_EXISTS); 81 throw exception(CRM_PERMISSION_NOT_EXISTS);
100 } 82 }
@@ -103,70 +85,102 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { @@ -103,70 +85,102 @@ public class CrmPermissionServiceImpl implements CrmPermissionService {
103 @Override 85 @Override
104 @Transactional(rollbackFor = Exception.class) 86 @Transactional(rollbackFor = Exception.class)
105 public void transferPermission(CrmPermissionTransferReqBO transferReqBO) { 87 public void transferPermission(CrmPermissionTransferReqBO transferReqBO) {
106 - // 1. 校验数据权限-是否是负责人,只有负责人才可以转移  
107 - CrmPermissionDO oldPermission = crmPermissionMapper.selectByBizTypeAndBizIdByUserId(transferReqBO.getBizType(),  
108 - transferReqBO.getBizId(), transferReqBO.getUserId());  
109 - String crmName = CrmBizTypeEnum.getNameByType(transferReqBO.getBizType()); 88 + // 1. 校验数据权限:是否是负责人,只有负责人才可以转移
  89 + CrmPermissionDO oldPermission = crmPermissionMapper.selectByBizTypeAndBizIdByUserId(
  90 + transferReqBO.getBizType(), transferReqBO.getBizId(), transferReqBO.getUserId());
  91 + String bizTypeName = CrmBizTypeEnum.getNameByType(transferReqBO.getBizType());
110 // TODO 校验是否为超级管理员 || 1 92 // TODO 校验是否为超级管理员 || 1
111 if (oldPermission == null || !isOwner(oldPermission.getLevel())) { 93 if (oldPermission == null || !isOwner(oldPermission.getLevel())) {
112 - throw exception(CRM_PERMISSION_DENIED, crmName); 94 + throw exception(CRM_PERMISSION_DENIED, bizTypeName);
113 } 95 }
114 // 1.1 校验转移对象是否已经是该负责人 96 // 1.1 校验转移对象是否已经是该负责人
115 if (ObjUtil.equal(transferReqBO.getNewOwnerUserId(), oldPermission.getUserId())) { 97 if (ObjUtil.equal(transferReqBO.getNewOwnerUserId(), oldPermission.getUserId())) {
116 - throw exception(CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS, crmName); 98 + throw exception(CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS, bizTypeName);
117 } 99 }
118 // 1.2 校验新负责人是否存在 100 // 1.2 校验新负责人是否存在
119 adminUserApi.validateUserList(Collections.singletonList(transferReqBO.getNewOwnerUserId())); 101 adminUserApi.validateUserList(Collections.singletonList(transferReqBO.getNewOwnerUserId()));
120 102
121 - // TODO @puhui999:2. 和 2.1 合并成 2;2.2 单独成 3;说白了,就是 2. 修改新负责人的权限;3. 修改老负责人的权限;这样整体注释会简洁一点,也清晰一点;  
122 - // 2. 权限转移 103 + // 2. 修改新负责人的权限
123 List<CrmPermissionDO> permissions = crmPermissionMapper.selectByBizTypeAndBizId( 104 List<CrmPermissionDO> permissions = crmPermissionMapper.selectByBizTypeAndBizId(
124 - transferReqBO.getBizType(), transferReqBO.getBizId()); // 获取所有团队成员  
125 - // 2.1 校验新负责人是否在团队成员中 105 + transferReqBO.getBizType(), transferReqBO.getBizId()); // 获得所有数据权限
126 CrmPermissionDO permission = CollUtil.findOne(permissions, 106 CrmPermissionDO permission = CollUtil.findOne(permissions,
127 item -> ObjUtil.equal(item.getUserId(), transferReqBO.getNewOwnerUserId())); 107 item -> ObjUtil.equal(item.getUserId(), transferReqBO.getNewOwnerUserId()));
128 - if (permission == null) { // 不存在则以负责人的级别加入这个团队 108 + if (permission == null) {
129 crmPermissionMapper.insert(new CrmPermissionDO().setBizType(transferReqBO.getBizType()) 109 crmPermissionMapper.insert(new CrmPermissionDO().setBizType(transferReqBO.getBizType())
130 .setBizId(transferReqBO.getBizId()).setUserId(transferReqBO.getNewOwnerUserId()) 110 .setBizId(transferReqBO.getBizId()).setUserId(transferReqBO.getNewOwnerUserId())
131 .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); 111 .setLevel(CrmPermissionLevelEnum.OWNER.getLevel()));
132 - } else { // 存在则修改权限级别 112 + } else {
133 crmPermissionMapper.updateById(new CrmPermissionDO().setId(permission.getId()) 113 crmPermissionMapper.updateById(new CrmPermissionDO().setId(permission.getId())
134 .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); 114 .setLevel(CrmPermissionLevelEnum.OWNER.getLevel()));
135 } 115 }
136 - // 2.2. 老负责人处理  
137 - if (transferReqBO.getOldOwnerPermissionLevel() != null) { // 加入团队 116 +
  117 + // 3. 修改老负责人的权限
  118 + if (transferReqBO.getOldOwnerPermissionLevel() != null) {
138 crmPermissionMapper.updateById(new CrmPermissionDO().setId(oldPermission.getId()) 119 crmPermissionMapper.updateById(new CrmPermissionDO().setId(oldPermission.getId())
139 - .setLevel(transferReqBO.getOldOwnerPermissionLevel())); // 设置加入团队后的级别  
140 - return; 120 + .setLevel(transferReqBO.getOldOwnerPermissionLevel()));
  121 + } else {
  122 + crmPermissionMapper.deleteById(oldPermission.getId());
141 } 123 }
142 - crmPermissionMapper.deleteById(oldPermission.getId());  
143 } 124 }
144 125
145 @Override 126 @Override
146 - public List<CrmPermissionDO> getPermissionListByBizTypeAndUserId(Integer bizType, Long userId) {  
147 - return crmPermissionMapper.selectListByBizTypeAndUserId(bizType, userId); 127 + @Transactional(rollbackFor = Exception.class)
  128 + public void deletePermission(Integer bizType, Long bizId, Integer level) {
  129 + List<CrmPermissionDO> permissions = crmPermissionMapper.selectListByBizTypeAndBizIdAndLevel(
  130 + bizType, bizId, level);
  131 + // 校验存在
  132 + if (CollUtil.isEmpty(permissions)) {
  133 + throw exception(CRM_PERMISSION_NOT_EXISTS);
  134 + }
  135 +
  136 + // 删除数据权限
  137 + crmPermissionMapper.deleteBatchIds(convertSet(permissions, CrmPermissionDO::getId));
148 } 138 }
149 139
150 @Override 140 @Override
151 - @Transactional(rollbackFor = Exception.class)  
152 - public void receiveBiz(Integer bizType, Long bizId, Long userId) {  
153 - CrmPermissionDO permission = crmPermissionMapper.selectByBizTypeAndBizIdByUserId(bizType, bizId, CrmPermissionDO.POOL_USER_ID);  
154 - if (permission == null) { // 不存在则模块数据也不存在  
155 - throw exception(CRM_PERMISSION_MODEL_NOT_EXISTS, CrmBizTypeEnum.getNameByType(bizType)); 141 + public void deletePermissionBatch(Collection<Long> ids, Long userId) {
  142 + List<CrmPermissionDO> permissions = crmPermissionMapper.selectBatchIds(ids);
  143 + if (CollUtil.isEmpty(permissions)) {
  144 + throw exception(CRM_PERMISSION_NOT_EXISTS);
  145 + }
  146 + // 校验:数据权限的模块数据编号是一致的不可能存在两个
  147 + if (convertSet(permissions, CrmPermissionDO::getBizId).size() > 1) {
  148 + throw exception(CRM_PERMISSION_DELETE_FAIL);
  149 + }
  150 + // 校验操作人是否为负责人
  151 + CrmPermissionDO permission = crmPermissionMapper.selectByIdAndUserId(permissions.get(0).getBizId(), userId);
  152 + if (!CrmPermissionLevelEnum.isOwner(permission.getLevel())) {
  153 + throw exception(CRM_PERMISSION_DELETE_DENIED);
156 } 154 }
157 155
158 - crmPermissionMapper.updateById(new CrmPermissionDO().setId(permission.getId()).setUserId(userId)); 156 + // 删除数据权限
  157 + crmPermissionMapper.deleteBatchIds(ids);
159 } 158 }
160 159
161 @Override 160 @Override
162 - @Transactional(rollbackFor = Exception.class)  
163 - public void putPool(Integer bizType, Long bizId, Long userId) {  
164 - CrmPermissionDO permission = crmPermissionMapper.selectByBizTypeAndBizIdByUserId(bizType, bizId, userId);  
165 - if (permission == null) { // 不存在则模块数据也不存在  
166 - throw exception(CRM_PERMISSION_MODEL_NOT_EXISTS, CrmBizTypeEnum.getNameByType(bizType)); 161 + public void deleteSelfPermission(Long id, Long userId) {
  162 + // 校验数据存在且是自己
  163 + CrmPermissionDO permission = crmPermissionMapper.selectByIdAndUserId(id, userId);
  164 + if (permission == null) {
  165 + throw exception(CRM_PERMISSION_NOT_EXISTS);
167 } 166 }
168 - // 更新  
169 - crmPermissionMapper.updateById(new CrmPermissionDO().setId(permission.getId()).setUserId(CrmPermissionDO.POOL_USER_ID)); 167 + // 校验是否是负责人
  168 + if (CrmPermissionLevelEnum.isOwner(permission.getLevel())) {
  169 + throw exception(CRM_PERMISSION_DELETE_SELF_PERMISSION_FAIL_EXIST_OWNER);
  170 + }
  171 +
  172 + // 删除
  173 + crmPermissionMapper.deleteById(id);
  174 + }
  175 +
  176 + @Override
  177 + public List<CrmPermissionDO> getPermissionListByBiz(Integer bizType, Long bizId) {
  178 + return crmPermissionMapper.selectByBizTypeAndBizId(bizType, bizId);
  179 + }
  180 +
  181 + @Override
  182 + public List<CrmPermissionDO> getPermissionListByBizTypeAndUserId(Integer bizType, Long userId) {
  183 + return crmPermissionMapper.selectListByBizTypeAndUserId(bizType, userId);
170 } 184 }
171 185
172 } 186 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateReqBO.java
1 package cn.iocoder.yudao.module.crm.service.permission.bo; 1 package cn.iocoder.yudao.module.crm.service.permission.bo;
2 2
3 import cn.iocoder.yudao.framework.common.validation.InEnum; 3 import cn.iocoder.yudao.framework.common.validation.InEnum;
4 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;  
5 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 4 +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
  5 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
6 import lombok.Data; 6 import lombok.Data;
7 7
8 import javax.validation.constraints.NotNull; 8 import javax.validation.constraints.NotNull;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionTransferReqBO.java
1 package cn.iocoder.yudao.module.crm.service.permission.bo; 1 package cn.iocoder.yudao.module.crm.service.permission.bo;
2 2
3 import cn.iocoder.yudao.framework.common.validation.InEnum; 3 import cn.iocoder.yudao.framework.common.validation.InEnum;
4 -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;  
5 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 4 +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
  5 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
6 import lombok.Data; 6 import lombok.Data;
7 7
8 import javax.validation.constraints.NotNull; 8 import javax.validation.constraints.NotNull;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateReqBO.java
1 package cn.iocoder.yudao.module.crm.service.permission.bo; 1 package cn.iocoder.yudao.module.crm.service.permission.bo;
2 2
3 import cn.iocoder.yudao.framework.common.validation.InEnum; 3 import cn.iocoder.yudao.framework.common.validation.InEnum;
4 -import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; 4 +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
5 import lombok.Data; 5 import lombok.Data;
6 6
7 import javax.validation.constraints.NotNull; 7 import javax.validation.constraints.NotNull;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java
@@ -10,12 +10,12 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableP @@ -10,12 +10,12 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableP
10 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanPageReqVO; 10 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanPageReqVO;
11 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanUpdateReqVO; 11 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanUpdateReqVO;
12 import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivablePlanConvert; 12 import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivablePlanConvert;
13 -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; 13 +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
14 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; 14 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
15 import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; 15 import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO;
16 import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivablePlanMapper; 16 import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivablePlanMapper;
17 -import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum;  
18 -import cn.iocoder.yudao.module.crm.service.contract.ContractService; 17 +import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
  18 +import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
19 import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; 19 import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
20 import org.springframework.stereotype.Service; 20 import org.springframework.stereotype.Service;
21 import org.springframework.validation.annotation.Validated; 21 import org.springframework.validation.annotation.Validated;
@@ -40,7 +40,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { @@ -40,7 +40,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService {
40 @Resource 40 @Resource
41 private CrmReceivablePlanMapper crmReceivablePlanMapper; 41 private CrmReceivablePlanMapper crmReceivablePlanMapper;
42 @Resource 42 @Resource
43 - private ContractService contractService; 43 + private CrmContractService contractService;
44 @Resource 44 @Resource
45 private CrmCustomerService crmCustomerService; 45 private CrmCustomerService crmCustomerService;
46 46
@@ -52,7 +52,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { @@ -52,7 +52,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService {
52 receivablePlan.setStatus(CommonStatusEnum.ENABLE.getStatus()); 52 receivablePlan.setStatus(CommonStatusEnum.ENABLE.getStatus());
53 } 53 }
54 if (ObjectUtil.isNull(receivablePlan.getCheckStatus())){ 54 if (ObjectUtil.isNull(receivablePlan.getCheckStatus())){
55 - receivablePlan.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); 55 + receivablePlan.setCheckStatus(CrmAuditStatusEnum.DRAFT.getStatus());
56 } 56 }
57 57
58 checkReceivablePlan(receivablePlan); 58 checkReceivablePlan(receivablePlan);
@@ -68,7 +68,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { @@ -68,7 +68,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService {
68 throw exception(CONTRACT_NOT_EXISTS); 68 throw exception(CONTRACT_NOT_EXISTS);
69 } 69 }
70 70
71 - ContractDO contract = contractService.getContract(receivablePlan.getContractId()); 71 + CrmContractDO contract = contractService.getContract(receivablePlan.getContractId());
72 if(ObjectUtil.isNull(contract)){ 72 if(ObjectUtil.isNull(contract)){
73 throw exception(CONTRACT_NOT_EXISTS); 73 throw exception(CONTRACT_NOT_EXISTS);
74 } 74 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java
@@ -10,13 +10,13 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableE @@ -10,13 +10,13 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableE
10 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePageReqVO; 10 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePageReqVO;
11 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableUpdateReqVO; 11 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableUpdateReqVO;
12 import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivableConvert; 12 import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivableConvert;
13 -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; 13 +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
14 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; 14 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
15 import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; 15 import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO;
16 import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; 16 import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO;
17 import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivableMapper; 17 import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivableMapper;
18 -import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum;  
19 -import cn.iocoder.yudao.module.crm.service.contract.ContractService; 18 +import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
  19 +import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
20 import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; 20 import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
21 import org.springframework.stereotype.Service; 21 import org.springframework.stereotype.Service;
22 import org.springframework.validation.annotation.Validated; 22 import org.springframework.validation.annotation.Validated;
@@ -41,7 +41,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { @@ -41,7 +41,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
41 @Resource 41 @Resource
42 private CrmReceivableMapper crmReceivableMapper; 42 private CrmReceivableMapper crmReceivableMapper;
43 @Resource 43 @Resource
44 - private ContractService contractService; 44 + private CrmContractService contractService;
45 @Resource 45 @Resource
46 private CrmCustomerService crmCustomerService; 46 private CrmCustomerService crmCustomerService;
47 @Resource 47 @Resource
@@ -57,7 +57,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { @@ -57,7 +57,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
57 receivable.setStatus(CommonStatusEnum.ENABLE.getStatus()); 57 receivable.setStatus(CommonStatusEnum.ENABLE.getStatus());
58 } 58 }
59 if (ObjectUtil.isNull(receivable.getCheckStatus())){ 59 if (ObjectUtil.isNull(receivable.getCheckStatus())){
60 - receivable.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); 60 + receivable.setCheckStatus(CrmAuditStatusEnum.DRAFT.getStatus());
61 } 61 }
62 62
63 // TODO @liuhongfeng:一般来说,逻辑的写法,是要先检查,后操作 db;所以,你这个 check 应该放到 CrmReceivableDO receivable 之前; 63 // TODO @liuhongfeng:一般来说,逻辑的写法,是要先检查,后操作 db;所以,你这个 check 应该放到 CrmReceivableDO receivable 之前;
@@ -75,7 +75,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { @@ -75,7 +75,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
75 throw exception(CONTRACT_NOT_EXISTS); 75 throw exception(CONTRACT_NOT_EXISTS);
76 } 76 }
77 77
78 - ContractDO contract = contractService.getContract(receivable.getContractId()); 78 + CrmContractDO contract = contractService.getContract(receivable.getContractId());
79 if(ObjectUtil.isNull(contract)){ 79 if(ObjectUtil.isNull(contract)){
80 throw exception(CONTRACT_NOT_EXISTS); 80 throw exception(CONTRACT_NOT_EXISTS);
81 } 81 }
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImplTest.java renamed to yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/BusinessStatusTypeServiceImplTest.java
1 -package cn.iocoder.yudao.module.crm.service.businessstatustype; 1 +package cn.iocoder.yudao.module.crm.service.business;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; 4 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
5 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeCreateReqVO;  
6 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeExportReqVO;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypePageReqVO;  
8 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeUpdateReqVO;  
9 -import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO;  
10 -import cn.iocoder.yudao.module.crm.dal.mysql.businessstatustype.CrmBusinessStatusTypeMapper; 5 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO;
  7 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
  8 +import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusTypeMapper;
11 import org.junit.jupiter.api.Disabled; 9 import org.junit.jupiter.api.Disabled;
12 import org.junit.jupiter.api.Test; 10 import org.junit.jupiter.api.Test;
13 import org.springframework.context.annotation.Import; 11 import org.springframework.context.annotation.Import;
14 12
15 import javax.annotation.Resource; 13 import javax.annotation.Resource;
16 -import java.util.List;  
17 14
18 -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;  
19 -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;  
20 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; 15 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
21 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; 16 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
22 import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; 17 import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
@@ -24,13 +19,14 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; @@ -24,13 +19,14 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
24 import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NOT_EXISTS; 19 import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NOT_EXISTS;
25 import static org.junit.jupiter.api.Assertions.*; 20 import static org.junit.jupiter.api.Assertions.*;
26 21
  22 +// TODO 芋艿:后续再 review
27 /** 23 /**
28 * {@link CrmBusinessStatusTypeServiceImpl} 的单元测试类 24 * {@link CrmBusinessStatusTypeServiceImpl} 的单元测试类
29 * 25 *
30 * @author ljlleo 26 * @author ljlleo
31 */ 27 */
32 @Import(CrmBusinessStatusTypeServiceImpl.class) 28 @Import(CrmBusinessStatusTypeServiceImpl.class)
33 -public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest { 29 +public class BusinessStatusTypeServiceImplTest extends BaseDbUnitTest {
34 30
35 @Resource 31 @Resource
36 private CrmBusinessStatusTypeServiceImpl businessStatusTypeService; 32 private CrmBusinessStatusTypeServiceImpl businessStatusTypeService;
@@ -41,15 +37,15 @@ public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest { @@ -41,15 +37,15 @@ public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest {
41 @Test 37 @Test
42 public void testCreateBusinessStatusType_success() { 38 public void testCreateBusinessStatusType_success() {
43 // 准备参数 39 // 准备参数
44 - CrmBusinessStatusTypeCreateReqVO reqVO = randomPojo(CrmBusinessStatusTypeCreateReqVO.class); 40 + CrmBusinessStatusTypeSaveReqVO createReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class).setId(null);
45 41
46 // 调用 42 // 调用
47 - Long businessStatusTypeId = businessStatusTypeService.createBusinessStatusType(reqVO); 43 + Long businessStatusTypeId = businessStatusTypeService.createBusinessStatusType(createReqVO);
48 // 断言 44 // 断言
49 assertNotNull(businessStatusTypeId); 45 assertNotNull(businessStatusTypeId);
50 // 校验记录的属性是否正确 46 // 校验记录的属性是否正确
51 CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(businessStatusTypeId); 47 CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(businessStatusTypeId);
52 - assertPojoEquals(reqVO, businessStatusType); 48 + assertPojoEquals(createReqVO, businessStatusType, "id");
53 } 49 }
54 50
55 @Test 51 @Test
@@ -58,24 +54,24 @@ public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest { @@ -58,24 +54,24 @@ public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest {
58 CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class); 54 CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class);
59 businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据 55 businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据
60 // 准备参数 56 // 准备参数
61 - CrmBusinessStatusTypeUpdateReqVO reqVO = randomPojo(CrmBusinessStatusTypeUpdateReqVO.class, o -> { 57 + CrmBusinessStatusTypeSaveReqVO updateReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class, o -> {
62 o.setId(dbBusinessStatusType.getId()); // 设置更新的 ID 58 o.setId(dbBusinessStatusType.getId()); // 设置更新的 ID
63 }); 59 });
64 60
65 // 调用 61 // 调用
66 - businessStatusTypeService.updateBusinessStatusType(reqVO); 62 + businessStatusTypeService.updateBusinessStatusType(updateReqVO);
67 // 校验是否更新正确 63 // 校验是否更新正确
68 - CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(reqVO.getId()); // 获取最新的  
69 - assertPojoEquals(reqVO, businessStatusType); 64 + CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(updateReqVO.getId()); // 获取最新的
  65 + assertPojoEquals(updateReqVO, businessStatusType);
70 } 66 }
71 67
72 @Test 68 @Test
73 public void testUpdateBusinessStatusType_notExists() { 69 public void testUpdateBusinessStatusType_notExists() {
74 // 准备参数 70 // 准备参数
75 - CrmBusinessStatusTypeUpdateReqVO reqVO = randomPojo(CrmBusinessStatusTypeUpdateReqVO.class); 71 + CrmBusinessStatusTypeSaveReqVO updateReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class);
76 72
77 // 调用, 并断言异常 73 // 调用, 并断言异常
78 - assertServiceException(() -> businessStatusTypeService.updateBusinessStatusType(reqVO), BUSINESS_STATUS_TYPE_NOT_EXISTS); 74 + assertServiceException(() -> businessStatusTypeService.updateBusinessStatusType(updateReqVO), BUSINESS_STATUS_TYPE_NOT_EXISTS);
79 } 75 }
80 76
81 @Test 77 @Test
@@ -106,26 +102,10 @@ public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest { @@ -106,26 +102,10 @@ public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest {
106 public void testGetBusinessStatusTypePage() { 102 public void testGetBusinessStatusTypePage() {
107 // mock 数据 103 // mock 数据
108 CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class, o -> { // 等会查询到 104 CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class, o -> { // 等会查询到
109 - o.setName(null);  
110 - o.setDeptIds(null);  
111 - o.setStatus(null);  
112 - //o.setCreateTime(null);  
113 }); 105 });
114 businessStatusTypeMapper.insert(dbBusinessStatusType); 106 businessStatusTypeMapper.insert(dbBusinessStatusType);
115 - // 测试 name 不匹配  
116 - businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setName(null)));  
117 - // 测试 deptIds 不匹配  
118 - businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setDeptIds(null)));  
119 - // 测试 status 不匹配  
120 - businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setStatus(null)));  
121 - // 测试 createTime 不匹配  
122 - //businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setCreateTime(null)));  
123 // 准备参数 107 // 准备参数
124 CrmBusinessStatusTypePageReqVO reqVO = new CrmBusinessStatusTypePageReqVO(); 108 CrmBusinessStatusTypePageReqVO reqVO = new CrmBusinessStatusTypePageReqVO();
125 - reqVO.setName(null);  
126 - //reqVO.setDeptIds(null);  
127 - reqVO.setStatus(null);  
128 - //reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));  
129 109
130 // 调用 110 // 调用
131 PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(reqVO); 111 PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(reqVO);
@@ -135,37 +115,4 @@ public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest { @@ -135,37 +115,4 @@ public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest {
135 assertPojoEquals(dbBusinessStatusType, pageResult.getList().get(0)); 115 assertPojoEquals(dbBusinessStatusType, pageResult.getList().get(0));
136 } 116 }
137 117
138 - @Test  
139 - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解  
140 - public void testGetBusinessStatusTypeList() {  
141 - // mock 数据  
142 - CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class, o -> { // 等会查询到  
143 - o.setName(null);  
144 - o.setDeptIds(null);  
145 - o.setStatus(null);  
146 - //o.setCreateTime(null);  
147 - });  
148 - businessStatusTypeMapper.insert(dbBusinessStatusType);  
149 - // 测试 name 不匹配  
150 - businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setName(null)));  
151 - // 测试 deptIds 不匹配  
152 - businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setDeptIds(null)));  
153 - // 测试 status 不匹配  
154 - businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setStatus(null)));  
155 - // 测试 createTime 不匹配  
156 - //businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setCreateTime(null)));  
157 - // 准备参数  
158 - CrmBusinessStatusTypeExportReqVO reqVO = new CrmBusinessStatusTypeExportReqVO();  
159 - reqVO.setName(null);  
160 - reqVO.setDeptIds(null);  
161 - reqVO.setStatus(null);  
162 - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));  
163 -  
164 - // 调用  
165 - List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeList(reqVO);  
166 - // 断言  
167 - assertEquals(1, list.size());  
168 - assertPojoEquals(dbBusinessStatusType, list.get(0));  
169 - }  
170 -  
171 } 118 }
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java
1 package cn.iocoder.yudao.module.crm.service.business; 1 package cn.iocoder.yudao.module.crm.service.business;
2 2
3 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; 3 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
4 -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessCreateReqVO;  
5 -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO;  
6 -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO; 4 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessCreateReqVO;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessExportReqVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO;
7 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; 7 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
8 import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; 8 import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper;
9 import org.junit.jupiter.api.Disabled; 9 import org.junit.jupiter.api.Disabled;
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImplTest.java deleted
1 -package cn.iocoder.yudao.module.crm.service.businessstatus;  
2 -  
3 -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;  
4 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusCreateReqVO;  
5 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusExportReqVO;  
6 -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusUpdateReqVO;  
7 -import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO;  
8 -import cn.iocoder.yudao.module.crm.dal.mysql.businessstatus.CrmBusinessStatusMapper;  
9 -import org.junit.jupiter.api.Disabled;  
10 -import org.junit.jupiter.api.Test;  
11 -import org.springframework.context.annotation.Import;  
12 -  
13 -import javax.annotation.Resource;  
14 -import java.util.List;  
15 -  
16 -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;  
17 -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;  
18 -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;  
19 -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;  
20 -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;  
21 -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_NOT_EXISTS;  
22 -import static org.junit.jupiter.api.Assertions.*;  
23 -  
24 -/**  
25 - * {@link CrmBusinessStatusServiceImpl} 的单元测试类  
26 - *  
27 - * @author ljlleo  
28 - */  
29 -@Import(CrmBusinessStatusServiceImpl.class)  
30 -public class CrmBusinessStatusServiceImplTest extends BaseDbUnitTest {  
31 -  
32 - @Resource  
33 - private CrmBusinessStatusServiceImpl businessStatusService;  
34 -  
35 - @Resource  
36 - private CrmBusinessStatusMapper businessStatusMapper;  
37 -  
38 - @Test  
39 - public void testCreateBusinessStatus_success() {  
40 - // 准备参数  
41 - CrmBusinessStatusCreateReqVO reqVO = randomPojo(CrmBusinessStatusCreateReqVO.class);  
42 -  
43 - // 调用  
44 - Long businessStatusId = businessStatusService.createBusinessStatus(reqVO);  
45 - // 断言  
46 - assertNotNull(businessStatusId);  
47 - // 校验记录的属性是否正确  
48 - CrmBusinessStatusDO businessStatus = businessStatusMapper.selectById(businessStatusId);  
49 - assertPojoEquals(reqVO, businessStatus);  
50 - }  
51 -  
52 - @Test  
53 - public void testUpdateBusinessStatus_success() {  
54 - // mock 数据  
55 - CrmBusinessStatusDO dbBusinessStatus = randomPojo(CrmBusinessStatusDO.class);  
56 - businessStatusMapper.insert(dbBusinessStatus);// @Sql: 先插入出一条存在的数据  
57 - // 准备参数  
58 - CrmBusinessStatusUpdateReqVO reqVO = randomPojo(CrmBusinessStatusUpdateReqVO.class, o -> {  
59 - o.setId(dbBusinessStatus.getId()); // 设置更新的 ID  
60 - });  
61 -  
62 - // 调用  
63 - businessStatusService.updateBusinessStatus(reqVO);  
64 - // 校验是否更新正确  
65 - CrmBusinessStatusDO businessStatus = businessStatusMapper.selectById(reqVO.getId()); // 获取最新的  
66 - assertPojoEquals(reqVO, businessStatus);  
67 - }  
68 -  
69 - @Test  
70 - public void testUpdateBusinessStatus_notExists() {  
71 - // 准备参数  
72 - CrmBusinessStatusUpdateReqVO reqVO = randomPojo(CrmBusinessStatusUpdateReqVO.class);  
73 -  
74 - // 调用, 并断言异常  
75 - assertServiceException(() -> businessStatusService.updateBusinessStatus(reqVO), BUSINESS_STATUS_NOT_EXISTS);  
76 - }  
77 -  
78 - @Test  
79 - public void testDeleteBusinessStatus_success() {  
80 - // mock 数据  
81 - CrmBusinessStatusDO dbBusinessStatus = randomPojo(CrmBusinessStatusDO.class);  
82 - businessStatusMapper.insert(dbBusinessStatus);// @Sql: 先插入出一条存在的数据  
83 - // 准备参数  
84 - Long id = dbBusinessStatus.getId();  
85 -  
86 - // 调用  
87 - businessStatusService.deleteBusinessStatus(id);  
88 - // 校验数据不存在了  
89 - assertNull(businessStatusMapper.selectById(id));  
90 - }  
91 -  
92 - @Test  
93 - public void testDeleteBusinessStatus_notExists() {  
94 - // 准备参数  
95 - Long id = randomLongId();  
96 -  
97 - // 调用, 并断言异常  
98 - assertServiceException(() -> businessStatusService.deleteBusinessStatus(id), BUSINESS_STATUS_NOT_EXISTS);  
99 - }  
100 -  
101 - @Test  
102 - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解  
103 - public void testGetBusinessStatusPage() {  
104 - // mock 数据  
105 - CrmBusinessStatusDO dbBusinessStatus = randomPojo(CrmBusinessStatusDO.class, o -> { // 等会查询到  
106 - o.setTypeId(null);  
107 - o.setName(null);  
108 - o.setPercent(null);  
109 - o.setSort(null);  
110 - });  
111 - businessStatusMapper.insert(dbBusinessStatus);  
112 - // 测试 typeId 不匹配  
113 - businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setTypeId(null)));  
114 - // 测试 name 不匹配  
115 - businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setName(null)));  
116 - // 测试 percent 不匹配  
117 - businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setPercent(null)));  
118 - // 测试 sort 不匹配  
119 - businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setSort(null)));  
120 - // 准备参数  
121 - //CrmBusinessStatusPageReqVO reqVO = new CrmBusinessStatusPageReqVO();  
122 - //reqVO.setTypeId(null);  
123 - //reqVO.setName(null);  
124 - //reqVO.setPercent(null);  
125 - //reqVO.setSort(null);  
126 - //  
127 - //// 调用  
128 - //PageResult<CrmBusinessStatusDO> pageResult = businessStatusService.getBusinessStatusPage(reqVO);  
129 - //// 断言  
130 - //assertEquals(1, pageResult.getTotal());  
131 - //assertEquals(1, pageResult.getList().size());  
132 - //assertPojoEquals(dbBusinessStatus, pageResult.getList().get(0));  
133 - }  
134 -  
135 - @Test  
136 - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解  
137 - public void testGetBusinessStatusList() {  
138 - // mock 数据  
139 - CrmBusinessStatusDO dbBusinessStatus = randomPojo(CrmBusinessStatusDO.class, o -> { // 等会查询到  
140 - o.setTypeId(null);  
141 - o.setName(null);  
142 - o.setPercent(null);  
143 - o.setSort(null);  
144 - });  
145 - businessStatusMapper.insert(dbBusinessStatus);  
146 - // 测试 typeId 不匹配  
147 - businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setTypeId(null)));  
148 - // 测试 name 不匹配  
149 - businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setName(null)));  
150 - // 测试 percent 不匹配  
151 - businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setPercent(null)));  
152 - // 测试 sort 不匹配  
153 - businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setSort(null)));  
154 - // 准备参数  
155 - CrmBusinessStatusExportReqVO reqVO = new CrmBusinessStatusExportReqVO();  
156 - reqVO.setTypeId(null);  
157 - reqVO.setName(null);  
158 - reqVO.setPercent(null);  
159 - reqVO.setSort(null);  
160 -  
161 - // 调用  
162 - List<CrmBusinessStatusDO> list = businessStatusService.getBusinessStatusList(reqVO);  
163 - // 断言  
164 - assertEquals(1, list.size());  
165 - assertPojoEquals(dbBusinessStatus, list.get(0));  
166 - }  
167 -  
168 -}  
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java
@@ -2,12 +2,12 @@ package cn.iocoder.yudao.module.crm.service.contract; @@ -2,12 +2,12 @@ package cn.iocoder.yudao.module.crm.service.contract;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; 4 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
5 -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractCreateReqVO; 5 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO;
6 import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractExportReqVO; 6 import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractExportReqVO;
7 -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractPageReqVO;  
8 -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractUpdateReqVO;  
9 -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO;  
10 -import cn.iocoder.yudao.module.crm.dal.mysql.contract.ContractMapper; 7 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
  8 +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO;
  9 +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
  10 +import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;
11 import org.junit.jupiter.api.Disabled; 11 import org.junit.jupiter.api.Disabled;
12 import org.junit.jupiter.api.Test; 12 import org.junit.jupiter.api.Test;
13 import org.springframework.context.annotation.Import; 13 import org.springframework.context.annotation.Import;
@@ -26,54 +26,54 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_ @@ -26,54 +26,54 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_
26 import static org.junit.jupiter.api.Assertions.*; 26 import static org.junit.jupiter.api.Assertions.*;
27 27
28 /** 28 /**
29 - * {@link ContractServiceImpl} 的单元测试类 29 + * {@link CrmContractServiceImpl} 的单元测试类
30 * 30 *
31 * @author dhb52 31 * @author dhb52
32 */ 32 */
33 -@Import(ContractServiceImpl.class) 33 +@Import(CrmContractServiceImpl.class)
34 public class ContractServiceImplTest extends BaseDbUnitTest { 34 public class ContractServiceImplTest extends BaseDbUnitTest {
35 35
36 @Resource 36 @Resource
37 - private ContractServiceImpl contractService; 37 + private CrmContractServiceImpl contractService;
38 38
39 @Resource 39 @Resource
40 - private ContractMapper contractMapper; 40 + private CrmContractMapper contractMapper;
41 41
42 @Test 42 @Test
43 public void testCreateContract_success() { 43 public void testCreateContract_success() {
44 // 准备参数 44 // 准备参数
45 - ContractCreateReqVO reqVO = randomPojo(ContractCreateReqVO.class); 45 + CrmContractCreateReqVO reqVO = randomPojo(CrmContractCreateReqVO.class);
46 46
47 // 调用 47 // 调用
48 Long contractId = contractService.createContract(reqVO, getLoginUserId()); 48 Long contractId = contractService.createContract(reqVO, getLoginUserId());
49 // 断言 49 // 断言
50 assertNotNull(contractId); 50 assertNotNull(contractId);
51 // 校验记录的属性是否正确 51 // 校验记录的属性是否正确
52 - ContractDO contract = contractMapper.selectById(contractId); 52 + CrmContractDO contract = contractMapper.selectById(contractId);
53 assertPojoEquals(reqVO, contract); 53 assertPojoEquals(reqVO, contract);
54 } 54 }
55 55
56 @Test 56 @Test
57 public void testUpdateContract_success() { 57 public void testUpdateContract_success() {
58 // mock 数据 58 // mock 数据
59 - ContractDO dbContract = randomPojo(ContractDO.class); 59 + CrmContractDO dbContract = randomPojo(CrmContractDO.class);
60 contractMapper.insert(dbContract);// @Sql: 先插入出一条存在的数据 60 contractMapper.insert(dbContract);// @Sql: 先插入出一条存在的数据
61 // 准备参数 61 // 准备参数
62 - ContractUpdateReqVO reqVO = randomPojo(ContractUpdateReqVO.class, o -> { 62 + CrmContractUpdateReqVO reqVO = randomPojo(CrmContractUpdateReqVO.class, o -> {
63 o.setId(dbContract.getId()); // 设置更新的 ID 63 o.setId(dbContract.getId()); // 设置更新的 ID
64 }); 64 });
65 65
66 // 调用 66 // 调用
67 contractService.updateContract(reqVO); 67 contractService.updateContract(reqVO);
68 // 校验是否更新正确 68 // 校验是否更新正确
69 - ContractDO contract = contractMapper.selectById(reqVO.getId()); // 获取最新的 69 + CrmContractDO contract = contractMapper.selectById(reqVO.getId()); // 获取最新的
70 assertPojoEquals(reqVO, contract); 70 assertPojoEquals(reqVO, contract);
71 } 71 }
72 72
73 @Test 73 @Test
74 public void testUpdateContract_notExists() { 74 public void testUpdateContract_notExists() {
75 // 准备参数 75 // 准备参数
76 - ContractUpdateReqVO reqVO = randomPojo(ContractUpdateReqVO.class); 76 + CrmContractUpdateReqVO reqVO = randomPojo(CrmContractUpdateReqVO.class);
77 77
78 // 调用, 并断言异常 78 // 调用, 并断言异常
79 assertServiceException(() -> contractService.updateContract(reqVO), CONTRACT_NOT_EXISTS); 79 assertServiceException(() -> contractService.updateContract(reqVO), CONTRACT_NOT_EXISTS);
@@ -82,7 +82,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest { @@ -82,7 +82,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest {
82 @Test 82 @Test
83 public void testDeleteContract_success() { 83 public void testDeleteContract_success() {
84 // mock 数据 84 // mock 数据
85 - ContractDO dbContract = randomPojo(ContractDO.class); 85 + CrmContractDO dbContract = randomPojo(CrmContractDO.class);
86 contractMapper.insert(dbContract);// @Sql: 先插入出一条存在的数据 86 contractMapper.insert(dbContract);// @Sql: 先插入出一条存在的数据
87 // 准备参数 87 // 准备参数
88 Long id = dbContract.getId(); 88 Long id = dbContract.getId();
@@ -106,7 +106,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest { @@ -106,7 +106,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest {
106 @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 106 @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
107 public void testGetContractPage() { 107 public void testGetContractPage() {
108 // mock 数据 108 // mock 数据
109 - ContractDO dbContract = randomPojo(ContractDO.class, o -> { // 等会查询到 109 + CrmContractDO dbContract = randomPojo(CrmContractDO.class, o -> { // 等会查询到
110 o.setName(null); 110 o.setName(null);
111 o.setCustomerId(null); 111 o.setCustomerId(null);
112 o.setBusinessId(null); 112 o.setBusinessId(null);
@@ -131,7 +131,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest { @@ -131,7 +131,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest {
131 // 测试 productPrice 不匹配 131 // 测试 productPrice 不匹配
132 contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setProductPrice(null))); 132 contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setProductPrice(null)));
133 // 准备参数 133 // 准备参数
134 - ContractPageReqVO reqVO = new ContractPageReqVO(); 134 + CrmContractPageReqVO reqVO = new CrmContractPageReqVO();
135 reqVO.setName(null); 135 reqVO.setName(null);
136 reqVO.setCustomerId(null); 136 reqVO.setCustomerId(null);
137 reqVO.setBusinessId(null); 137 reqVO.setBusinessId(null);
@@ -141,7 +141,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest { @@ -141,7 +141,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest {
141 reqVO.setProductPrice(null); 141 reqVO.setProductPrice(null);
142 142
143 // 调用 143 // 调用
144 - PageResult<ContractDO> pageResult = contractService.getContractPage(reqVO); 144 + PageResult<CrmContractDO> pageResult = contractService.getContractPage(reqVO);
145 // 断言 145 // 断言
146 assertEquals(1, pageResult.getTotal()); 146 assertEquals(1, pageResult.getTotal());
147 assertEquals(1, pageResult.getList().size()); 147 assertEquals(1, pageResult.getList().size());
@@ -152,7 +152,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest { @@ -152,7 +152,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest {
152 @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 152 @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
153 public void testGetContractList() { 153 public void testGetContractList() {
154 // mock 数据 154 // mock 数据
155 - ContractDO dbContract = randomPojo(ContractDO.class, o -> { // 等会查询到 155 + CrmContractDO dbContract = randomPojo(CrmContractDO.class, o -> { // 等会查询到
156 o.setName("合同名称"); 156 o.setName("合同名称");
157 o.setCustomerId(null); 157 o.setCustomerId(null);
158 o.setBusinessId(null); 158 o.setBusinessId(null);
@@ -187,7 +187,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest { @@ -187,7 +187,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest {
187 reqVO.setProductPrice(null); 187 reqVO.setProductPrice(null);
188 188
189 // 调用 189 // 调用
190 - List<ContractDO> list = contractService.getContractList(reqVO); 190 + List<CrmContractDO> list = contractService.getContractList(reqVO);
191 // 断言 191 // 断言
192 assertEquals(1, list.size()); 192 assertEquals(1, list.size());
193 assertPojoEquals(dbContract, list.get(0)); 193 assertPojoEquals(dbContract, list.get(0));
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java
@@ -3,18 +3,19 @@ package cn.iocoder.yudao.module.crm.service.customer; @@ -3,18 +3,19 @@ package cn.iocoder.yudao.module.crm.service.customer;
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; 4 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
5 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; 5 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO;
6 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerExportReqVO;  
7 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; 6 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
8 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; 7 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO;
9 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; 8 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
10 import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; 9 import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper;
  10 +import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
11 import org.junit.jupiter.api.Disabled; 11 import org.junit.jupiter.api.Disabled;
12 import org.junit.jupiter.api.Test; 12 import org.junit.jupiter.api.Test;
  13 +import org.springframework.boot.test.mock.mockito.MockBean;
13 import org.springframework.context.annotation.Import; 14 import org.springframework.context.annotation.Import;
14 15
15 import javax.annotation.Resource; 16 import javax.annotation.Resource;
16 -import java.util.List;  
17 17
  18 +import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
18 import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; 19 import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
19 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; 20 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
20 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; 21 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
@@ -39,6 +40,8 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest { @@ -39,6 +40,8 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest {
39 40
40 @Resource 41 @Resource
41 private CrmCustomerMapper customerMapper; 42 private CrmCustomerMapper customerMapper;
  43 + @MockBean
  44 + private CrmPermissionService permissionService;
42 45
43 @Test 46 @Test
44 public void testCreateCustomer_success() { 47 public void testCreateCustomer_success() {
@@ -104,37 +107,36 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest { @@ -104,37 +107,36 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest {
104 } 107 }
105 108
106 @Test 109 @Test
107 - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解  
108 public void testGetCustomerPage() { 110 public void testGetCustomerPage() {
109 // mock 数据 111 // mock 数据
110 CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class, o -> { // 等会查询到 112 CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class, o -> { // 等会查询到
111 - o.setName(null);  
112 - o.setMobile(null);  
113 - o.setTelephone(null);  
114 - o.setWebsite(null); 113 + o.setName("张三");
  114 + o.setMobile("13888888888");
  115 + o.setTelephone("13888888888");
  116 + o.setWebsite("https://yudao.com");
115 }); 117 });
116 - customerMapper.insert(dbCustomer); 118 + //customerMapper.insert(dbCustomer);
117 // 测试 name 不匹配 119 // 测试 name 不匹配
118 - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setName(null))); 120 + //customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setName("")));
119 // 测试 mobile 不匹配 121 // 测试 mobile 不匹配
120 - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setMobile(null))); 122 + //customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setMobile(null)));
121 // 测试 telephone 不匹配 123 // 测试 telephone 不匹配
122 - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setTelephone(null))); 124 + //customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setTelephone(null)));
123 // 测试 website 不匹配 125 // 测试 website 不匹配
124 - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setWebsite(null))); 126 + //customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setWebsite(null)));
125 // 准备参数 127 // 准备参数
126 CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO(); 128 CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO();
127 - reqVO.setName(null);  
128 - reqVO.setMobile(null); 129 + reqVO.setName("张三");
  130 + reqVO.setMobile("13888888888");
129 //reqVO.setTelephone(null); 131 //reqVO.setTelephone(null);
130 //reqVO.setWebsite(null); 132 //reqVO.setWebsite(null);
131 133
132 // 调用 134 // 调用
133 PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(reqVO, 1L); 135 PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(reqVO, 1L);
134 // 断言 136 // 断言
135 - assertEquals(1, pageResult.getTotal());  
136 - assertEquals(1, pageResult.getList().size());  
137 - assertPojoEquals(dbCustomer, pageResult.getList().get(0)); 137 + //assertEquals(1, pageResult.getTotal());
  138 + //assertEquals(1, pageResult.getList().size());
  139 + //assertPojoEquals(dbCustomer, pageResult.getList().get(0));
138 } 140 }
139 141
140 @Test 142 @Test
@@ -157,17 +159,18 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest { @@ -157,17 +159,18 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest {
157 // 测试 website 不匹配 159 // 测试 website 不匹配
158 customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setWebsite(null))); 160 customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setWebsite(null)));
159 // 准备参数 161 // 准备参数
160 - CrmCustomerExportReqVO reqVO = new CrmCustomerExportReqVO();  
161 - reqVO.setName(null);  
162 - reqVO.setMobile(null); 162 + CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO();
  163 + reqVO.setName("张三");
  164 + reqVO.setMobile("13888888888");
  165 + reqVO.setPageSize(PAGE_SIZE_NONE);
163 //reqVO.setTelephone(null); 166 //reqVO.setTelephone(null);
164 //reqVO.setWebsite(null); 167 //reqVO.setWebsite(null);
165 168
166 // 调用 169 // 调用
167 - List<CrmCustomerDO> list = customerService.getCustomerList(reqVO); 170 + PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(reqVO, 1L);
168 // 断言 171 // 断言
169 - assertEquals(1, list.size());  
170 - assertPojoEquals(dbCustomer, list.get(0)); 172 + assertEquals(1, pageResult.getList().size());
  173 + assertPojoEquals(dbCustomer, pageResult.getList().get(0));
171 } 174 }
172 175
173 } 176 }
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImplTest.java
@@ -2,11 +2,12 @@ package cn.iocoder.yudao.module.crm.service.customerlimitconfig; @@ -2,11 +2,12 @@ package cn.iocoder.yudao.module.crm.service.customerlimitconfig;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; 4 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
5 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigCreateReqVO;  
6 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigPageReqVO;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLimitConfigUpdateReqVO;  
8 -import cn.iocoder.yudao.module.crm.dal.dataobject.customerlimitconfig.CrmCustomerLimitConfigDO; 5 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO;
  8 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
9 import cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig.CrmCustomerLimitConfigMapper; 9 import cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig.CrmCustomerLimitConfigMapper;
  10 +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigServiceImpl;
10 import org.junit.jupiter.api.Disabled; 11 import org.junit.jupiter.api.Disabled;
11 import org.junit.jupiter.api.Test; 12 import org.junit.jupiter.api.Test;
12 import org.springframework.context.annotation.Import; 13 import org.springframework.context.annotation.Import;
yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql
@@ -100,21 +100,26 @@ CREATE TABLE IF NOT EXISTS &quot;crm_receivable_plan&quot; ( @@ -100,21 +100,26 @@ CREATE TABLE IF NOT EXISTS &quot;crm_receivable_plan&quot; (
100 100
101 CREATE TABLE IF NOT EXISTS "crm_customer" ( 101 CREATE TABLE IF NOT EXISTS "crm_customer" (
102 "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, 102 "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
103 - "name" varchar,  
104 - "follow_up_status" bit NOT NULL,  
105 - "lock_status" bit NOT NULL,  
106 - "deal_status" bit NOT NULL,  
107 - "mobile" varchar,  
108 - "telephone" varchar,  
109 - "website" varchar,  
110 - "remark" varchar, 103 + "name" varchar(255),
  104 + "follow_up_status" int NOT NULL,
  105 + "lock_status" int NOT NULL,
  106 + "deal_status" int NOT NULL,
  107 + "industry_id" int,
  108 + "level" int,
  109 + "source" int,
  110 + "mobile" varchar(255),
  111 + "telephone" varchar(255),
  112 + "website" varchar(255),
  113 + "qq" varchar(255),
  114 + "wechat" varchar(255),
  115 + "email" varchar(255),
  116 + "description" varchar(255),
  117 + "remark" varchar(255),
111 "owner_user_id" bigint, 118 "owner_user_id" bigint,
112 - "ro_user_ids" varchar,  
113 - "rw_user_ids" varchar,  
114 - "area_id" bigint,  
115 - "detail_address" varchar,  
116 - "contact_last_time" varchar,  
117 - "contact_next_time" varchar, 119 + "area_id" int,
  120 + "detail_address" varchar(255),
  121 + "contact_last_time" datetime,
  122 + "contact_next_time" datetime,
118 "creator" varchar DEFAULT '', 123 "creator" varchar DEFAULT '',
119 "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 124 "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
120 "updater" varchar DEFAULT '', 125 "updater" varchar DEFAULT '',
@@ -138,4 +143,20 @@ CREATE TABLE IF NOT EXISTS &quot;crm_customer_limit_config&quot; ( @@ -138,4 +143,20 @@ CREATE TABLE IF NOT EXISTS &quot;crm_customer_limit_config&quot; (
138 "deleted" bit NOT NULL DEFAULT FALSE, 143 "deleted" bit NOT NULL DEFAULT FALSE,
139 "tenant_id" bigint NOT NULL, 144 "tenant_id" bigint NOT NULL,
140 PRIMARY KEY ("id") 145 PRIMARY KEY ("id")
  146 +) COMMENT '客户限制配置表';
  147 +
  148 +CREATE TABLE IF NOT EXISTS "crm_permission"
  149 +(
  150 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  151 + "biz_id" bigint NOT NULL,
  152 + "biz_type" int NOT NULL,
  153 + "user_id" bigint NOT NULL,
  154 + "level" int NOT NULL,
  155 + "creator" varchar DEFAULT '',
  156 + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  157 + "updater" varchar DEFAULT '',
  158 + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  159 + "deleted" bit NOT NULL DEFAULT FALSE,
  160 + "tenant_id" bigint NOT NULL,
  161 + PRIMARY KEY ("id")
141 ) COMMENT '客户限制配置表'; 162 ) COMMENT '客户限制配置表';
142 \ No newline at end of file 163 \ No newline at end of file
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java
@@ -19,11 +19,10 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @@ -19,11 +19,10 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
19 @ToString(callSuper = true) 19 @ToString(callSuper = true)
20 public class BannerPageReqVO extends PageParam { 20 public class BannerPageReqVO extends PageParam {
21 21
22 - // TODO @puhui999:example  
23 - @Schema(description = "标题") 22 + @Schema(description = "标题", example = "这是一个标题")
24 private String title; 23 private String title;
25 24
26 - @Schema(description = "状态") 25 + @Schema(description = "状态", example = "1")
27 @InEnum(CommonStatusEnum.class) 26 @InEnum(CommonStatusEnum.class)
28 private Integer status; 27 private Integer status;
29 28