Commit bf8bfef8cbb4b5c1c7e1dcaf36b808f2a85c7fa0

Authored by 芋道源码
Committed by Gitee
2 parents 8efdf314 7af80ba2

!727 crm联系人字段修改

Merge pull request !727 from zyna/feature/crm
Showing 15 changed files with 336 additions and 210 deletions
sql/mysql/crm.sql
1 SET NAMES utf8mb4; 1 SET NAMES utf8mb4;
  2 +
  3 +CREATE TABLE `crm_contact` (
  4 + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  5 + `name` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '联系人名称',
  6 + `next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
  7 + `mobile` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机号',
  8 + `telephone` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电话',
  9 + `email` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电子邮箱',
  10 + `post` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '职务',
  11 + `customer_id` bigint(20) DEFAULT NULL COMMENT '客户编号',
  12 + `address` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址',
  13 + `remark` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  14 + `creator` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  15 + `owner_user_id` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '负责人用户编号',
  16 + `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  17 + `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  18 + `last_time` timestamp NULL DEFAULT NULL COMMENT '最后跟进时间',
  19 + `updater` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  20 + `deleted` bit(1) NOT NULL DEFAULT b'0',
  21 + `tenant_id` bigint(20) DEFAULT NULL,
  22 + `parent_id` bigint(20) DEFAULT NULL COMMENT '直系上属',
  23 + `qq` int(11) DEFAULT NULL,
  24 + `webchat` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  25 + `sex` int(1) DEFAULT NULL COMMENT '性别',
  26 + `policy_makers` bit(1) DEFAULT NULL COMMENT '是否关键决策人',
  27 + PRIMARY KEY (`id`) USING BTREE
  28 +) ENGINE=InnoDB AUAUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='crm联系人';
2 \ No newline at end of file 29 \ No newline at end of file
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.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.iocoder.yudao.framework.common.pojo.CommonResult; 3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.util.NumberUtil;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerExportReqVO;
  6 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
  7 +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
  8 +import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
  9 +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
  10 +import com.google.common.collect.Lists;
  11 +import org.springframework.web.bind.annotation.*;
  12 +import javax.annotation.Resource;
  13 +import org.springframework.validation.annotation.Validated;
  14 +import org.springframework.security.access.prepost.PreAuthorize;
  15 +import io.swagger.v3.oas.annotations.tags.Tag;
  16 +import io.swagger.v3.oas.annotations.Parameter;
  17 +import io.swagger.v3.oas.annotations.Operation;
  18 +
  19 +import javax.validation.constraints.*;
  20 +import javax.validation.*;
  21 +import javax.servlet.http.*;
  22 +import java.util.*;
  23 +import java.io.IOException;
  24 +import java.util.stream.Collectors;
  25 +
4 import cn.iocoder.yudao.framework.common.pojo.PageResult; 26 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  27 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  28 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  29 +
5 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; 30 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
  31 +
6 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; 32 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
  33 +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
  34 +
7 import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; 35 import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
8 -import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;  
9 import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; 36 import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO;
  37 +import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;
10 import cn.iocoder.yudao.module.crm.service.contact.ContactService; 38 import cn.iocoder.yudao.module.crm.service.contact.ContactService;
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 39
25 -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;  
26 -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;  
27 -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;  
28 -  
29 -@Tag(name = "管理后台 - CRM 联系人") 40 +@Tag(name = "管理后台 - crm联系人")
30 @RestController 41 @RestController
31 @RequestMapping("/crm/contact") 42 @RequestMapping("/crm/contact")
32 @Validated 43 @Validated
@@ -34,12 +45,16 @@ public class ContactController { @@ -34,12 +45,16 @@ public class ContactController {
34 45
35 @Resource 46 @Resource
36 private ContactService contactService; 47 private ContactService contactService;
  48 + @Resource
  49 + private AdminUserApi adminUserApi;
  50 + @Resource
  51 + private CrmCustomerService crmCustomerService;
37 52
38 @PostMapping("/create") 53 @PostMapping("/create")
39 @Operation(summary = "创建crm联系人") 54 @Operation(summary = "创建crm联系人")
40 @PreAuthorize("@ss.hasPermission('crm:contact:create')") 55 @PreAuthorize("@ss.hasPermission('crm:contact:create')")
41 public CommonResult<Long> createContact(@Valid @RequestBody ContactCreateReqVO createReqVO) { 56 public CommonResult<Long> createContact(@Valid @RequestBody ContactCreateReqVO createReqVO) {
42 - return success(contactService.createContact(createReqVO, getLoginUserId())); 57 + return success(contactService.createContact(createReqVO));
43 } 58 }
44 59
45 @PutMapping("/update") 60 @PutMapping("/update")
@@ -65,7 +80,12 @@ public class ContactController { @@ -65,7 +80,12 @@ public class ContactController {
65 @PreAuthorize("@ss.hasPermission('crm:contact:query')") 80 @PreAuthorize("@ss.hasPermission('crm:contact:query')")
66 public CommonResult<ContactRespVO> getContact(@RequestParam("id") Long id) { 81 public CommonResult<ContactRespVO> getContact(@RequestParam("id") Long id) {
67 ContactDO contact = contactService.getContact(id); 82 ContactDO contact = contactService.getContact(id);
68 - return success(ContactConvert.INSTANCE.convert(contact)); 83 + ContactRespVO contactRespVO = ContactConvert.INSTANCE.convert(contact);
  84 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(CollUtil.removeNull(Lists.newArrayList(
  85 + NumberUtil.parseLong(contact.getCreator()))));
  86 + contactRespVO.setCreatorName(Optional.ofNullable(userMap.get(NumberUtil.parseLong(contact.getCreator()))).map(AdminUserRespDTO::getNickname).orElse(null));
  87 + contactRespVO.setCustomerName(Optional.ofNullable(crmCustomerService.getCustomer(contact.getCustomerId())).map(CrmCustomerDO::getName).orElse(null));
  88 + return success(contactRespVO);
69 } 89 }
70 90
71 @GetMapping("/list") 91 @GetMapping("/list")
@@ -76,13 +96,26 @@ public class ContactController { @@ -76,13 +96,26 @@ public class ContactController {
76 List<ContactDO> list = contactService.getContactList(ids); 96 List<ContactDO> list = contactService.getContactList(ids);
77 return success(ContactConvert.INSTANCE.convertList(list)); 97 return success(ContactConvert.INSTANCE.convertList(list));
78 } 98 }
79 - 99 + @GetMapping("/simpleAlllist")
  100 + @Operation(summary = "获得crm联系人列表")
  101 + @PreAuthorize("@ss.hasPermission('crm:contact:query')")
  102 + public CommonResult<List<ContactSimpleRespVO>> simpleAlllist() {
  103 + List<ContactDO> list = contactService.allContactList();
  104 + return success(ContactConvert.INSTANCE.convertAllList(list));
  105 + }
80 @GetMapping("/page") 106 @GetMapping("/page")
81 @Operation(summary = "获得crm联系人分页") 107 @Operation(summary = "获得crm联系人分页")
82 @PreAuthorize("@ss.hasPermission('crm:contact:query')") 108 @PreAuthorize("@ss.hasPermission('crm:contact:query')")
83 public CommonResult<PageResult<ContactRespVO>> getContactPage(@Valid ContactPageReqVO pageVO) { 109 public CommonResult<PageResult<ContactRespVO>> getContactPage(@Valid ContactPageReqVO pageVO) {
84 - PageResult<ContactDO> pageResult = contactService.getContactPage(pageVO);  
85 - return success(ContactConvert.INSTANCE.convertPage(pageResult)); 110 + PageResult<ContactDO> pageData = contactService.getContactPage(pageVO);
  111 + PageResult<ContactRespVO> pageResult =ContactConvert.INSTANCE.convertPage(pageData);
  112 + //待接口实现后修改
  113 + List<CrmCustomerDO> crmCustomerDOList = crmCustomerService.getCustomerList(new CrmCustomerExportReqVO());
  114 + Map<Long,CrmCustomerDO> crmCustomerDOMap = crmCustomerDOList.stream().collect(Collectors.toMap(CrmCustomerDO::getId,v->v));
  115 + pageResult.getList().forEach(item -> {
  116 + item.setCustomerName(Optional.ofNullable(crmCustomerDOMap.get(item.getCustomerId())).map(CrmCustomerDO::getName).orElse(null));
  117 + });
  118 + return success(pageResult);
86 } 119 }
87 120
88 @GetMapping("/export-excel") 121 @GetMapping("/export-excel")
@@ -97,12 +130,4 @@ public class ContactController { @@ -97,12 +130,4 @@ public class ContactController {
97 ExcelUtils.write(response, "crm联系人.xls", "数据", ContactExcelVO.class, datas); 130 ExcelUtils.write(response, "crm联系人.xls", "数据", ContactExcelVO.class, datas);
98 } 131 }
99 132
100 - @PutMapping("/transfer")  
101 - @Operation(summary = "联系人转移")  
102 - @PreAuthorize("@ss.hasPermission('crm:contact:update')")  
103 - public CommonResult<Boolean> transfer(@Valid @RequestBody CrmContactTransferReqVO reqVO) {  
104 - contactService.transferContact(reqVO, getLoginUserId());  
105 - return success(true);  
106 - }  
107 -  
108 } 133 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.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 io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 -import lombok.Data;  
5 -import org.springframework.format.annotation.DateTimeFormat; 4 +import lombok.*;
6 5
7 -import javax.validation.constraints.NotNull; 6 +import java.time.LocalDate;
  7 +import java.util.*;
  8 +import java.time.LocalDateTime;
  9 +import java.time.LocalDateTime;
8 import java.time.LocalDateTime; 10 import java.time.LocalDateTime;
  11 +import javax.validation.constraints.*;
  12 +import org.springframework.format.annotation.DateTimeFormat;
9 13
  14 +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; 15 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
11 16
12 /** 17 /**
@@ -16,31 +21,19 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @@ -16,31 +21,19 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
16 @Data 21 @Data
17 public class ContactBaseVO { 22 public class ContactBaseVO {
18 23
19 - // TODO @zyna:部分字段,缺少 example,需要补充;  
20 -  
21 - @Schema(description = "联系人名称", example = "张三")  
22 - @NotNull(message = "姓名不能为空")  
23 - private String name;  
24 -  
25 @Schema(description = "下次联系时间") 24 @Schema(description = "下次联系时间")
  25 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
26 private LocalDateTime nextTime; 26 private LocalDateTime nextTime;
27 27
28 - // TODO @zyna:缺少 validator 的校验  
29 @Schema(description = "手机号") 28 @Schema(description = "手机号")
30 private String mobile; 29 private String mobile;
31 30
32 - // TODO @zyna:缺少 validator 的校验  
33 @Schema(description = "电话") 31 @Schema(description = "电话")
34 private String telephone; 32 private String telephone;
35 33
36 - // TODO @zyna:缺少 validator 的校验  
37 @Schema(description = "电子邮箱") 34 @Schema(description = "电子邮箱")
38 private String email; 35 private String email;
39 36
40 - @Schema(description = "职务")  
41 - private String post;  
42 -  
43 - // TODO @zyna:非空校验  
44 @Schema(description = "客户编号", example = "10795") 37 @Schema(description = "客户编号", example = "10795")
45 private Long customerId; 38 private Long customerId;
46 39
@@ -50,12 +43,32 @@ public class ContactBaseVO { @@ -50,12 +43,32 @@ public class ContactBaseVO {
50 @Schema(description = "备注", example = "你说的对") 43 @Schema(description = "备注", example = "你说的对")
51 private String remark; 44 private String remark;
52 45
53 - // TODO @zyna:这个新建的时候,应该不会传递;而是后端默认设置自己为负责人;  
54 - @Schema(description = "负责人用户编号", example = "7648")  
55 - private Long ownerUserId;  
56 -  
57 @Schema(description = "最后跟进时间") 46 @Schema(description = "最后跟进时间")
58 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) 47 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
59 private LocalDateTime lastTime; 48 private LocalDateTime lastTime;
60 49
  50 + @Schema(description = "直属上级", example = "23457")
  51 + private Long parentId;
  52 +
  53 + @Schema(description = "姓名", example = "芋艿")
  54 + private String name;
  55 +
  56 + @Schema(description = "职位")
  57 + private String post;
  58 +
  59 + @Schema(description = "QQ")
  60 + private Long qq;
  61 +
  62 + @Schema(description = "微信")
  63 + private String webchat;
  64 +
  65 + @Schema(description = "性别")
  66 + private Integer sex;
  67 +
  68 + @Schema(description = "是否关键决策人")
  69 + private Boolean policyMakers;
  70 +
  71 + @Schema(description = "负责人用户编号", example = "14334")
  72 + private String ownerUserId;
  73 +
61 } 74 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.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 lombok.*;
  4 +import java.util.*;
3 import io.swagger.v3.oas.annotations.media.Schema; 5 import io.swagger.v3.oas.annotations.media.Schema;
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString; 6 +import javax.validation.constraints.*;
7 7
8 -@Schema(description = "管理后台 - CRM 联系人创建 Request VO") 8 +@Schema(description = "管理后台 - crm联系人创建 Request VO")
9 @Data 9 @Data
10 @EqualsAndHashCode(callSuper = true) 10 @EqualsAndHashCode(callSuper = true)
11 @ToString(callSuper = true) 11 @ToString(callSuper = true)
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExcelVO.java
@@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
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.*;
  5 +
  6 +import java.time.LocalDate;
5 import java.util.*; 7 import java.util.*;
6 import java.time.LocalDateTime; 8 import java.time.LocalDateTime;
7 import java.time.LocalDateTime; 9 import java.time.LocalDateTime;
@@ -17,12 +19,6 @@ import com.alibaba.excel.annotation.ExcelProperty; @@ -17,12 +19,6 @@ import com.alibaba.excel.annotation.ExcelProperty;
17 @Data 19 @Data
18 public class ContactExcelVO { 20 public class ContactExcelVO {
19 21
20 - @ExcelProperty("主键")  
21 - private Long id;  
22 -  
23 - @ExcelProperty("联系人名称")  
24 - private String name;  
25 -  
26 @ExcelProperty("下次联系时间") 22 @ExcelProperty("下次联系时间")
27 private LocalDateTime nextTime; 23 private LocalDateTime nextTime;
28 24
@@ -35,9 +31,6 @@ public class ContactExcelVO { @@ -35,9 +31,6 @@ public class ContactExcelVO {
35 @ExcelProperty("电子邮箱") 31 @ExcelProperty("电子邮箱")
36 private String email; 32 private String email;
37 33
38 - @ExcelProperty("职务")  
39 - private String post;  
40 -  
41 @ExcelProperty("客户编号") 34 @ExcelProperty("客户编号")
42 private Long customerId; 35 private Long customerId;
43 36
@@ -47,13 +40,37 @@ public class ContactExcelVO { @@ -47,13 +40,37 @@ public class ContactExcelVO {
47 @ExcelProperty("备注") 40 @ExcelProperty("备注")
48 private String remark; 41 private String remark;
49 42
50 - @ExcelProperty("负责人用户编号")  
51 - private Long ownerUserId;  
52 -  
53 @ExcelProperty("创建时间") 43 @ExcelProperty("创建时间")
54 private LocalDateTime createTime; 44 private LocalDateTime createTime;
55 45
56 @ExcelProperty("最后跟进时间") 46 @ExcelProperty("最后跟进时间")
57 private LocalDateTime lastTime; 47 private LocalDateTime lastTime;
58 48
  49 + @ExcelProperty("主键")
  50 + private Long id;
  51 +
  52 + @ExcelProperty("直属上级")
  53 + private Long parentId;
  54 +
  55 + @ExcelProperty("姓名")
  56 + private String name;
  57 +
  58 + @ExcelProperty("职位")
  59 + private String post;
  60 +
  61 + @ExcelProperty("QQ")
  62 + private Long qq;
  63 +
  64 + @ExcelProperty("微信")
  65 + private String webchat;
  66 +
  67 + @ExcelProperty("性别")
  68 + private Integer sex;
  69 +
  70 + @ExcelProperty("是否关键决策人")
  71 + private Boolean policyMakers;
  72 +
  73 + @ExcelProperty("负责人用户编号")
  74 + private String ownerUserId;
  75 +
59 } 76 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.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 lombok.*; 3 import lombok.*;
  4 +
  5 +import java.time.LocalDate;
4 import java.util.*; 6 import java.util.*;
5 import io.swagger.v3.oas.annotations.media.Schema; 7 import io.swagger.v3.oas.annotations.media.Schema;
6 import cn.iocoder.yudao.framework.common.pojo.PageParam; 8 import cn.iocoder.yudao.framework.common.pojo.PageParam;
@@ -9,13 +11,10 @@ import org.springframework.format.annotation.DateTimeFormat; @@ -9,13 +11,10 @@ import org.springframework.format.annotation.DateTimeFormat;
9 11
10 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; 12 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
11 13
12 -@Schema(description = "管理后台 - CRM 联系人 Excel 导出 Request VO,参数和 ContactPageReqVO 是一致的") 14 +@Schema(description = "管理后台 - crm联系人 Excel 导出 Request VO,参数和 ContactPageReqVO 是一致的")
13 @Data 15 @Data
14 public class ContactExportReqVO { 16 public class ContactExportReqVO {
15 17
16 - @Schema(description = "联系人名称", example = "张三")  
17 - private String name;  
18 -  
19 @Schema(description = "下次联系时间") 18 @Schema(description = "下次联系时间")
20 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) 19 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
21 private LocalDateTime[] nextTime; 20 private LocalDateTime[] nextTime;
@@ -29,9 +28,6 @@ public class ContactExportReqVO { @@ -29,9 +28,6 @@ public class ContactExportReqVO {
29 @Schema(description = "电子邮箱") 28 @Schema(description = "电子邮箱")
30 private String email; 29 private String email;
31 30
32 - @Schema(description = "职务")  
33 - private String post;  
34 -  
35 @Schema(description = "客户编号", example = "10795") 31 @Schema(description = "客户编号", example = "10795")
36 private Long customerId; 32 private Long customerId;
37 33
@@ -41,9 +37,6 @@ public class ContactExportReqVO { @@ -41,9 +37,6 @@ public class ContactExportReqVO {
41 @Schema(description = "备注", example = "你说的对") 37 @Schema(description = "备注", example = "你说的对")
42 private String remark; 38 private String remark;
43 39
44 - @Schema(description = "负责人用户编号", example = "7648")  
45 - private Long ownerUserId;  
46 -  
47 @Schema(description = "创建时间") 40 @Schema(description = "创建时间")
48 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) 41 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
49 private LocalDateTime[] createTime; 42 private LocalDateTime[] createTime;
@@ -52,4 +45,28 @@ public class ContactExportReqVO { @@ -52,4 +45,28 @@ public class ContactExportReqVO {
52 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) 45 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
53 private LocalDateTime[] lastTime; 46 private LocalDateTime[] lastTime;
54 47
  48 + @Schema(description = "直属上级", example = "23457")
  49 + private Long parentId;
  50 +
  51 + @Schema(description = "姓名", example = "芋艿")
  52 + private String name;
  53 +
  54 + @Schema(description = "职位")
  55 + private String post;
  56 +
  57 + @Schema(description = "QQ")
  58 + private Long qq;
  59 +
  60 + @Schema(description = "微信")
  61 + private String webchat;
  62 +
  63 + @Schema(description = "性别")
  64 + private Integer sex;
  65 +
  66 + @Schema(description = "是否关键决策人")
  67 + private Boolean policyMakers;
  68 +
  69 + @Schema(description = "负责人用户编号", example = "14334")
  70 + private String ownerUserId;
  71 +
55 } 72 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.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.pojo.PageParam; 3 +import lombok.*;
  4 +
  5 +import java.time.LocalDate;
  6 +import java.util.*;
4 import io.swagger.v3.oas.annotations.media.Schema; 7 import io.swagger.v3.oas.annotations.media.Schema;
5 -import lombok.Data;  
6 -import lombok.EqualsAndHashCode;  
7 -import lombok.ToString; 8 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
8 import org.springframework.format.annotation.DateTimeFormat; 9 import org.springframework.format.annotation.DateTimeFormat;
9 -  
10 import java.time.LocalDateTime; 10 import java.time.LocalDateTime;
11 11
12 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; 12 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
13 13
14 -@Schema(description = "管理后台 - CRM 联系人分页 Request VO") 14 +@Schema(description = "管理后台 - crm联系人分页 Request VO")
15 @Data 15 @Data
16 @EqualsAndHashCode(callSuper = true) 16 @EqualsAndHashCode(callSuper = true)
17 @ToString(callSuper = true) 17 @ToString(callSuper = true)
18 public class ContactPageReqVO extends PageParam { 18 public class ContactPageReqVO extends PageParam {
19 19
20 - // TODO @芋艿:需要查询的字段;  
21 -  
22 - @Schema(description = "联系人名称", example = "张三")  
23 - private String name;  
24 -  
25 @Schema(description = "下次联系时间") 20 @Schema(description = "下次联系时间")
26 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) 21 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
27 private LocalDateTime[] nextTime; 22 private LocalDateTime[] nextTime;
@@ -35,9 +30,6 @@ public class ContactPageReqVO extends PageParam { @@ -35,9 +30,6 @@ public class ContactPageReqVO extends PageParam {
35 @Schema(description = "电子邮箱") 30 @Schema(description = "电子邮箱")
36 private String email; 31 private String email;
37 32
38 - @Schema(description = "职务")  
39 - private String post;  
40 -  
41 @Schema(description = "客户编号", example = "10795") 33 @Schema(description = "客户编号", example = "10795")
42 private Long customerId; 34 private Long customerId;
43 35
@@ -47,9 +39,6 @@ public class ContactPageReqVO extends PageParam { @@ -47,9 +39,6 @@ public class ContactPageReqVO extends PageParam {
47 @Schema(description = "备注", example = "你说的对") 39 @Schema(description = "备注", example = "你说的对")
48 private String remark; 40 private String remark;
49 41
50 - @Schema(description = "负责人用户编号", example = "7648")  
51 - private Long ownerUserId;  
52 -  
53 @Schema(description = "创建时间") 42 @Schema(description = "创建时间")
54 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) 43 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
55 private LocalDateTime[] createTime; 44 private LocalDateTime[] createTime;
@@ -58,4 +47,28 @@ public class ContactPageReqVO extends PageParam { @@ -58,4 +47,28 @@ public class ContactPageReqVO extends PageParam {
58 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) 47 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
59 private LocalDateTime[] lastTime; 48 private LocalDateTime[] lastTime;
60 49
  50 + @Schema(description = "直属上级", example = "23457")
  51 + private Long parentId;
  52 +
  53 + @Schema(description = "姓名", example = "芋艿")
  54 + private String name;
  55 +
  56 + @Schema(description = "职位")
  57 + private String post;
  58 +
  59 + @Schema(description = "QQ")
  60 + private Long qq;
  61 +
  62 + @Schema(description = "微信")
  63 + private String webchat;
  64 +
  65 + @Schema(description = "性别")
  66 + private Integer sex;
  67 +
  68 + @Schema(description = "是否关键决策人")
  69 + private Boolean policyMakers;
  70 +
  71 + @Schema(description = "负责人用户编号", example = "14334")
  72 + private String ownerUserId;
  73 +
61 } 74 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java
@@ -4,17 +4,19 @@ import io.swagger.v3.oas.annotations.media.Schema; @@ -4,17 +4,19 @@ import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.*; 4 import lombok.*;
5 import java.time.LocalDateTime; 5 import java.time.LocalDateTime;
6 6
7 -@Schema(description = "管理后台 - CRM 联系人 Response VO") 7 +@Schema(description = "管理后台 - crm联系人 Response VO")
8 @Data 8 @Data
9 @EqualsAndHashCode(callSuper = true) 9 @EqualsAndHashCode(callSuper = true)
10 @ToString(callSuper = true) 10 @ToString(callSuper = true)
11 public class ContactRespVO extends ContactBaseVO { 11 public class ContactRespVO extends ContactBaseVO {
12 12
13 - @Schema(description = "主键", example = "23210")  
14 - private Long id;  
15 -  
16 @Schema(description = "创建时间") 13 @Schema(description = "创建时间")
17 private LocalDateTime createTime; 14 private LocalDateTime createTime;
18 @Schema(description = "创建人") 15 @Schema(description = "创建人")
19 - private String creator; 16 + private String creatorName;
  17 + @Schema(description = "客户")
  18 + private String customerName;
  19 + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
  20 + private Long id;
  21 +
20 } 22 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactSimpleRespVO.java 0 → 100644
  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 lombok.EqualsAndHashCode;
  6 +import lombok.ToString;
  7 +
  8 +import java.time.LocalDateTime;
  9 +
  10 +@Schema(description = "管理后台 - crm联系人 Response VO")
  11 +@Data
  12 +@ToString(callSuper = true)
  13 +public class ContactSimpleRespVO {
  14 + @Schema(description = "姓名", example = "芋艿")
  15 + private String name;
  16 +
  17 + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
  18 + private Long id;
  19 +
  20 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.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 io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString; 4 +import lombok.*;
  5 +import java.util.*;
  6 +import javax.validation.constraints.*;
7 7
8 -@Schema(description = "管理后台 - CRM 联系人更新 Request VO") 8 +@Schema(description = "管理后台 - crm联系人更新 Request VO")
9 @Data 9 @Data
10 @EqualsAndHashCode(callSuper = true) 10 @EqualsAndHashCode(callSuper = true)
11 @ToString(callSuper = true) 11 @ToString(callSuper = true)
12 public class ContactUpdateReqVO extends ContactBaseVO { 12 public class ContactUpdateReqVO extends ContactBaseVO {
13 13
14 - @Schema(description = "主键", example = "23210") 14 + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
  15 + @NotNull(message = "主键不能为空")
15 private Long id; 16 private Long id;
16 17
17 } 18 }
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 java.util.*;
  4 +
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -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.service.permission.bo.CrmTransferPermissionReqBO; 6 +
7 import org.mapstruct.Mapper; 7 import org.mapstruct.Mapper;
8 -import org.mapstruct.Mapping;  
9 -import org.mapstruct.Mappings;  
10 import org.mapstruct.factory.Mappers; 8 import org.mapstruct.factory.Mappers;
11 -  
12 -import java.util.List; 9 +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
  10 +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO;
13 11
14 /** 12 /**
15 - * crm 联系人 Convert 13 + * crm联系人 Convert
16 * 14 *
17 * @author 芋道源码 15 * @author 芋道源码
18 */ 16 */
@@ -32,11 +30,6 @@ public interface ContactConvert { @@ -32,11 +30,6 @@ public interface ContactConvert {
32 PageResult<ContactRespVO> convertPage(PageResult<ContactDO> page); 30 PageResult<ContactRespVO> convertPage(PageResult<ContactDO> page);
33 31
34 List<ContactExcelVO> convertList02(List<ContactDO> list); 32 List<ContactExcelVO> convertList02(List<ContactDO> list);
35 -  
36 - @Mappings({  
37 - @Mapping(target = "bizId", source = "reqVO.id"),  
38 - @Mapping(target = "newOwnerUserId", source = "reqVO.id")  
39 - })  
40 - CrmTransferPermissionReqBO convert(CrmContactTransferReqVO reqVO, Long userId); 33 + List<ContactSimpleRespVO> convertAllList(List<ContactDO> list);
41 34
42 } 35 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java
1 package cn.iocoder.yudao.module.crm.dal.dataobject.contact; 1 package cn.iocoder.yudao.module.crm.dal.dataobject.contact;
2 2
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;  
7 import lombok.*; 3 import lombok.*;
8 4
  5 +import java.time.LocalDate;
  6 +import java.util.*;
  7 +import java.time.LocalDateTime;
  8 +import java.time.LocalDateTime;
9 import java.time.LocalDateTime; 9 import java.time.LocalDateTime;
  10 +import com.baomidou.mybatisplus.annotation.*;
  11 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
10 12
11 /** 13 /**
12 - * crm 联系人 DO 14 + * crm联系人 DO
13 * 15 *
14 * @author 芋道源码 16 * @author 芋道源码
15 */ 17 */
@@ -24,15 +26,6 @@ import java.time.LocalDateTime; @@ -24,15 +26,6 @@ import java.time.LocalDateTime;
24 public class ContactDO extends BaseDO { 26 public class ContactDO extends BaseDO {
25 27
26 /** 28 /**
27 - * 主键  
28 - */  
29 - @TableId  
30 - private Long id;  
31 - /**  
32 - * 联系人名称  
33 - */  
34 - private String name;  
35 - /**  
36 * 下次联系时间 29 * 下次联系时间
37 */ 30 */
38 private LocalDateTime nextTime; 31 private LocalDateTime nextTime;
@@ -49,13 +42,7 @@ public class ContactDO extends BaseDO { @@ -49,13 +42,7 @@ public class ContactDO extends BaseDO {
49 */ 42 */
50 private String email; 43 private String email;
51 /** 44 /**
52 - * 职务  
53 - */  
54 - private String post;  
55 - /**  
56 * 客户编号 45 * 客户编号
57 - *  
58 - * TODO @zyna:关联的字段,也要写下  
59 */ 46 */
60 private Long customerId; 47 private Long customerId;
61 /** 48 /**
@@ -70,5 +57,42 @@ public class ContactDO extends BaseDO { @@ -70,5 +57,42 @@ public class ContactDO extends BaseDO {
70 * 最后跟进时间 57 * 最后跟进时间
71 */ 58 */
72 private LocalDateTime lastTime; 59 private LocalDateTime lastTime;
  60 + /**
  61 + * 主键
  62 + */
  63 + @TableId
  64 + private Long id;
  65 + /**
  66 + * 直属上级
  67 + */
  68 + private Long parentId;
  69 + /**
  70 + * 姓名
  71 + */
  72 + private String name;
  73 + /**
  74 + * 职位
  75 + */
  76 + private String post;
  77 + /**
  78 + * QQ
  79 + */
  80 + private Long qq;
  81 + /**
  82 + * 微信
  83 + */
  84 + private String webchat;
  85 + /**
  86 + * 性别
  87 + */
  88 + private Integer sex;
  89 + /**
  90 + * 是否关键决策人
  91 + */
  92 + private Boolean policyMakers;
  93 + /**
  94 + * 负责人用户编号
  95 + */
  96 + private String ownerUserId;
73 97
74 } 98 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java
1 package cn.iocoder.yudao.module.crm.dal.mysql.contact; 1 package cn.iocoder.yudao.module.crm.dal.mysql.contact;
2 2
  3 +import java.util.*;
  4 +
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 5 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.framework.mybatis.core.query.LambdaQueryWrapperX;
6 -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactExportReqVO;  
7 -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactPageReqVO; 7 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
8 import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; 8 import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO;
9 import org.apache.ibatis.annotations.Mapper; 9 import org.apache.ibatis.annotations.Mapper;
10 -  
11 -import java.util.List; 10 +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
12 11
13 /** 12 /**
14 * crm联系人 Mapper 13 * crm联系人 Mapper
@@ -20,33 +19,45 @@ public interface ContactMapper extends BaseMapperX&lt;ContactDO&gt; { @@ -20,33 +19,45 @@ public interface ContactMapper extends BaseMapperX&lt;ContactDO&gt; {
20 19
21 default PageResult<ContactDO> selectPage(ContactPageReqVO reqVO) { 20 default PageResult<ContactDO> selectPage(ContactPageReqVO reqVO) {
22 return selectPage(reqVO, new LambdaQueryWrapperX<ContactDO>() 21 return selectPage(reqVO, new LambdaQueryWrapperX<ContactDO>()
23 - .likeIfPresent(ContactDO::getName, reqVO.getName())  
24 .betweenIfPresent(ContactDO::getNextTime, reqVO.getNextTime()) 22 .betweenIfPresent(ContactDO::getNextTime, reqVO.getNextTime())
25 .eqIfPresent(ContactDO::getMobile, reqVO.getMobile()) 23 .eqIfPresent(ContactDO::getMobile, reqVO.getMobile())
26 .eqIfPresent(ContactDO::getTelephone, reqVO.getTelephone()) 24 .eqIfPresent(ContactDO::getTelephone, reqVO.getTelephone())
27 .eqIfPresent(ContactDO::getEmail, reqVO.getEmail()) 25 .eqIfPresent(ContactDO::getEmail, reqVO.getEmail())
28 - .eqIfPresent(ContactDO::getPost, reqVO.getPost())  
29 .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId()) 26 .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId())
30 .eqIfPresent(ContactDO::getAddress, reqVO.getAddress()) 27 .eqIfPresent(ContactDO::getAddress, reqVO.getAddress())
31 .eqIfPresent(ContactDO::getRemark, reqVO.getRemark()) 28 .eqIfPresent(ContactDO::getRemark, reqVO.getRemark())
32 .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime()) 29 .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime())
33 .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime()) 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())
34 .orderByDesc(ContactDO::getId)); 39 .orderByDesc(ContactDO::getId));
35 } 40 }
36 41
37 default List<ContactDO> selectList(ContactExportReqVO reqVO) { 42 default List<ContactDO> selectList(ContactExportReqVO reqVO) {
38 return selectList(new LambdaQueryWrapperX<ContactDO>() 43 return selectList(new LambdaQueryWrapperX<ContactDO>()
39 - .likeIfPresent(ContactDO::getName, reqVO.getName())  
40 .betweenIfPresent(ContactDO::getNextTime, reqVO.getNextTime()) 44 .betweenIfPresent(ContactDO::getNextTime, reqVO.getNextTime())
41 .eqIfPresent(ContactDO::getMobile, reqVO.getMobile()) 45 .eqIfPresent(ContactDO::getMobile, reqVO.getMobile())
42 .eqIfPresent(ContactDO::getTelephone, reqVO.getTelephone()) 46 .eqIfPresent(ContactDO::getTelephone, reqVO.getTelephone())
43 .eqIfPresent(ContactDO::getEmail, reqVO.getEmail()) 47 .eqIfPresent(ContactDO::getEmail, reqVO.getEmail())
44 - .eqIfPresent(ContactDO::getPost, reqVO.getPost())  
45 .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId()) 48 .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId())
46 .eqIfPresent(ContactDO::getAddress, reqVO.getAddress()) 49 .eqIfPresent(ContactDO::getAddress, reqVO.getAddress())
47 .eqIfPresent(ContactDO::getRemark, reqVO.getRemark()) 50 .eqIfPresent(ContactDO::getRemark, reqVO.getRemark())
48 .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime()) 51 .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime())
49 .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime()) 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())
50 .orderByDesc(ContactDO::getId)); 61 .orderByDesc(ContactDO::getId));
51 } 62 }
52 63
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.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 java.util.*;
  4 +import javax.validation.*;
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.ContactDO;
6 -  
7 -import javax.validation.Valid;  
8 -import java.util.Collection;  
9 -import java.util.List; 7 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
10 8
11 /** 9 /**
12 * crm联系人 Service 接口 10 * crm联系人 Service 接口
@@ -19,10 +17,9 @@ public interface ContactService { @@ -19,10 +17,9 @@ public interface ContactService {
19 * 创建crm联系人 17 * 创建crm联系人
20 * 18 *
21 * @param createReqVO 创建信息 19 * @param createReqVO 创建信息
22 - * @param userId 用户编号  
23 * @return 编号 20 * @return 编号
24 */ 21 */
25 - Long createContact(@Valid ContactCreateReqVO createReqVO, Long userId); 22 + Long createContact(@Valid ContactCreateReqVO createReqVO);
26 23
27 /** 24 /**
28 * 更新crm联系人 25 * 更新crm联系人
@@ -71,11 +68,8 @@ public interface ContactService { @@ -71,11 +68,8 @@ public interface ContactService {
71 List<ContactDO> getContactList(ContactExportReqVO exportReqVO); 68 List<ContactDO> getContactList(ContactExportReqVO exportReqVO);
72 69
73 /** 70 /**
74 - * 联系人编号  
75 - *  
76 - * @param reqVO 请求  
77 - * @param userId 用户编号 71 + * 获取所有联系人列表,只返回姓名和id
  72 + * @return 所有联系人列表
78 */ 73 */
79 - void transferContact(CrmContactTransferReqVO reqVO, Long userId);  
80 - 74 + List<ContactDO> allContactList();
81 } 75 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java
1 package cn.iocoder.yudao.module.crm.service.contact; 1 package cn.iocoder.yudao.module.crm.service.contact;
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;  
6 -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;  
7 -import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;  
8 -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO;  
9 -import cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper;  
10 -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;  
14 -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;  
15 import org.springframework.stereotype.Service; 3 import org.springframework.stereotype.Service;
16 -import org.springframework.transaction.annotation.Transactional; 4 +import javax.annotation.Resource;
17 import org.springframework.validation.annotation.Validated; 5 import org.springframework.validation.annotation.Validated;
18 6
19 -import javax.annotation.Resource;  
20 -import java.util.Collection;  
21 -import java.util.List; 7 +import java.util.*;
  8 +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
  9 +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO;
  10 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  11 +
  12 +import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;
  13 +import cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper;
22 14
23 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 15 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
24 -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_NOT_EXISTS; 16 +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
  17 +
  18 +import cn.hutool.core.collection.CollUtil;
  19 +import cn.hutool.core.collection.ListUtil;
25 20
26 /** 21 /**
27 * crm联系人 Service 实现类 22 * crm联系人 Service 实现类
@@ -35,41 +30,25 @@ public class ContactServiceImpl implements ContactService { @@ -35,41 +30,25 @@ public class ContactServiceImpl implements ContactService {
35 @Resource 30 @Resource
36 private ContactMapper contactMapper; 31 private ContactMapper contactMapper;
37 32
38 - @Resource  
39 - private CrmPermissionService crmPermissionService;  
40 -  
41 @Override 33 @Override
42 - public Long createContact(ContactCreateReqVO createReqVO, Long userId) {  
43 - // TODO @customerId:需要校验存在 34 + public Long createContact(ContactCreateReqVO createReqVO) {
44 // 插入 35 // 插入
45 ContactDO contact = ContactConvert.INSTANCE.convert(createReqVO); 36 ContactDO contact = ContactConvert.INSTANCE.convert(createReqVO);
46 contactMapper.insert(contact); 37 contactMapper.insert(contact);
47 -  
48 - // 创建数据权限  
49 - crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CONTACTS.getType())  
50 - .setBizId(contact.getId()).setUserId(userId).setPermissionLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人  
51 -  
52 // 返回 38 // 返回
53 return contact.getId(); 39 return contact.getId();
54 } 40 }
55 41
56 @Override 42 @Override
57 - @Transactional(rollbackFor = Exception.class)  
58 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, getIdFor = ContactUpdateReqVO.class,  
59 - permissionLevel = CrmPermissionLevelEnum.WRITE)  
60 public void updateContact(ContactUpdateReqVO updateReqVO) { 43 public void updateContact(ContactUpdateReqVO updateReqVO) {
61 // 校验存在 44 // 校验存在
62 validateContactExists(updateReqVO.getId()); 45 validateContactExists(updateReqVO.getId());
63 - // TODO @customerId:需要校验存在  
64 -  
65 // 更新 46 // 更新
66 ContactDO updateObj = ContactConvert.INSTANCE.convert(updateReqVO); 47 ContactDO updateObj = ContactConvert.INSTANCE.convert(updateReqVO);
67 contactMapper.updateById(updateObj); 48 contactMapper.updateById(updateObj);
68 } 49 }
69 50
70 @Override 51 @Override
71 - @Transactional(rollbackFor = Exception.class)  
72 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, permissionLevel = CrmPermissionLevelEnum.WRITE)  
73 public void deleteContact(Long id) { 52 public void deleteContact(Long id) {
74 // 校验存在 53 // 校验存在
75 validateContactExists(id); 54 validateContactExists(id);
@@ -77,16 +56,13 @@ public class ContactServiceImpl implements ContactService { @@ -77,16 +56,13 @@ public class ContactServiceImpl implements ContactService {
77 contactMapper.deleteById(id); 56 contactMapper.deleteById(id);
78 } 57 }
79 58
80 - private ContactDO validateContactExists(Long id) {  
81 - ContactDO contact = contactMapper.selectById(id);  
82 - if (contact == null) { 59 + private void validateContactExists(Long id) {
  60 + if (contactMapper.selectById(id) == null) {
83 throw exception(CONTACT_NOT_EXISTS); 61 throw exception(CONTACT_NOT_EXISTS);
84 } 62 }
85 - return contact;  
86 } 63 }
87 64
88 @Override 65 @Override
89 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, permissionLevel = CrmPermissionLevelEnum.READ)  
90 public ContactDO getContact(Long id) { 66 public ContactDO getContact(Long id) {
91 return contactMapper.selectById(id); 67 return contactMapper.selectById(id);
92 } 68 }
@@ -110,15 +86,8 @@ public class ContactServiceImpl implements ContactService { @@ -110,15 +86,8 @@ public class ContactServiceImpl implements ContactService {
110 } 86 }
111 87
112 @Override 88 @Override
113 - public void transferContact(CrmContactTransferReqVO reqVO, Long userId) {  
114 - // 1 校验联系人是否存在  
115 - validateContactExists(reqVO.getId());  
116 -  
117 - // 2. 数据权限转移  
118 - crmPermissionService.transferPermission(  
119 - ContactConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_CONTACTS.getType()));  
120 -  
121 - // 3. TODO 记录转移日志 89 + public List<ContactDO> allContactList() {
  90 + return contactMapper.selectList();
122 } 91 }
123 92
124 } 93 }