Commit 455f8e49fb4263c015981ef9b66ba0d8c439a7b9
1 parent
16084d46
crm:code review 联系人
Showing
11 changed files
with
84 additions
and
92 deletions
sql/mysql/crm.sql
| 1 | SET NAMES utf8mb4; | 1 | SET NAMES utf8mb4; |
| 2 | -- `ruoyi-vue-pro`.crm_contact definition | 2 | -- `ruoyi-vue-pro`.crm_contact definition |
| 3 | 3 | ||
| 4 | -CREATE TABLE `crm_contact` ( | ||
| 5 | - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', | ||
| 6 | - `name` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '联系人名称', | ||
| 7 | - `next_time` datetime DEFAULT NULL COMMENT '下次联系时间', | ||
| 8 | - `mobile` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机号', | ||
| 9 | - `telephone` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电话', | ||
| 10 | - `email` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电子邮箱', | ||
| 11 | - `post` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '职务', | ||
| 12 | - `customer_id` bigint(20) DEFAULT NULL COMMENT '客户编号', | ||
| 13 | - `address` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址', | ||
| 14 | - `remark` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注', | ||
| 15 | - `creator` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人', | ||
| 16 | - `owner_user_id` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '负责人用户编号', | ||
| 17 | - `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间', | ||
| 18 | - `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间', | ||
| 19 | - `last_time` timestamp NULL DEFAULT NULL COMMENT '最后跟进时间', | ||
| 20 | - `updater` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人', | ||
| 21 | - `deleted` bit(1) NOT NULL DEFAULT b'0', | ||
| 22 | - `tenant_id` bigint(20) DEFAULT NULL, | ||
| 23 | - `parent_id` bigint(20) DEFAULT NULL COMMENT '直系上属', | ||
| 24 | - `qq` int(11) DEFAULT NULL, | ||
| 25 | - `wechat` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | ||
| 26 | - `sex` int(11) DEFAULT NULL COMMENT '性别', | ||
| 27 | - `master` bit(1) DEFAULT NULL COMMENT '是否关键决策人', | ||
| 28 | - `area_id` bigint(20) DEFAULT NULL COMMENT '地区', | ||
| 29 | - PRIMARY KEY (`id`) USING BTREE | ||
| 30 | -) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='CRM 联系人'; | ||
| 31 | \ No newline at end of file | 4 | \ 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
| @@ -86,24 +86,23 @@ public class ContactController { | @@ -86,24 +86,23 @@ public class ContactController { | ||
| 86 | @PreAuthorize("@ss.hasPermission('crm:contact:query')") | 86 | @PreAuthorize("@ss.hasPermission('crm:contact:query')") |
| 87 | public CommonResult<ContactRespVO> getContact(@RequestParam("id") Long id) { | 87 | public CommonResult<ContactRespVO> getContact(@RequestParam("id") Long id) { |
| 88 | ContactDO contact = contactService.getContact(id); | 88 | ContactDO contact = contactService.getContact(id); |
| 89 | - if(contact == null){ | 89 | + if (contact == null) { |
| 90 | throw exception(ErrorCodeConstants.CONTACT_NOT_EXISTS); | 90 | throw exception(ErrorCodeConstants.CONTACT_NOT_EXISTS); |
| 91 | } | 91 | } |
| 92 | - //1.获取用户名 | 92 | + // 1. 获取用户名 |
| 93 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(CollUtil.removeNull(Lists.newArrayList( | 93 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(CollUtil.removeNull(Lists.newArrayList( |
| 94 | - NumberUtil.parseLong(contact.getCreator()),contact.getOwnerUserId()))); | ||
| 95 | - //2.获取客户信息 | ||
| 96 | - List<CrmCustomerDO> crmCustomerDOList = crmCustomerService.getCustomerList(Collections.singletonList(contact.getCustomerId())); | ||
| 97 | - //3.直属上级 | ||
| 98 | - List<ContactDO> contactList = contactService.getContactList(Collections.singletonList(contact.getParentId())); | ||
| 99 | - ContactRespVO contactRespVO = ContactConvert.INSTANCE.convert(contact,userMap,crmCustomerDOList,contactList); | ||
| 100 | - return success(contactRespVO); | 94 | + NumberUtil.parseLong(contact.getCreator()), contact.getOwnerUserId()))); |
| 95 | + // 2. 获取客户信息 | ||
| 96 | + List<CrmCustomerDO> customerList = crmCustomerService.getCustomerList(Collections.singletonList(contact.getCustomerId())); | ||
| 97 | + // 3. 直属上级 | ||
| 98 | + List<ContactDO> parentContactList = contactService.getContactList(Collections.singletonList(contact.getParentId())); | ||
| 99 | + return success(ContactConvert.INSTANCE.convert(contact, userMap, customerList, parentContactList)); | ||
| 101 | } | 100 | } |
| 101 | + | ||
| 102 | @GetMapping("/simple-all-list") | 102 | @GetMapping("/simple-all-list") |
| 103 | @Operation(summary = "获得联系人列表") | 103 | @Operation(summary = "获得联系人列表") |
| 104 | @PreAuthorize("@ss.hasPermission('crm:contact:query')") | 104 | @PreAuthorize("@ss.hasPermission('crm:contact:query')") |
| 105 | - public CommonResult<List<ContactSimpleRespVO>> simpleAlllist() { | ||
| 106 | - // TODO @zyna:方法名改成,getContactList;方法命名,要动名词,get 动词;all 可以去掉,因为没条件,自然是全部 | 105 | + public CommonResult<List<ContactSimpleRespVO>> getContactList() { |
| 107 | List<ContactDO> list = contactService.getContactList(); | 106 | List<ContactDO> list = contactService.getContactList(); |
| 108 | return success(ContactConvert.INSTANCE.convertAllList(list)); | 107 | return success(ContactConvert.INSTANCE.convertAllList(list)); |
| 109 | } | 108 | } |
| @@ -112,11 +111,12 @@ public class ContactController { | @@ -112,11 +111,12 @@ public class ContactController { | ||
| 112 | @Operation(summary = "获得联系人分页") | 111 | @Operation(summary = "获得联系人分页") |
| 113 | @PreAuthorize("@ss.hasPermission('crm:contact:query')") | 112 | @PreAuthorize("@ss.hasPermission('crm:contact:query')") |
| 114 | public CommonResult<PageResult<ContactRespVO>> getContactPage(@Valid ContactPageReqVO pageVO) { | 113 | public CommonResult<PageResult<ContactRespVO>> getContactPage(@Valid ContactPageReqVO pageVO) { |
| 115 | - PageResult<ContactDO> pageData = contactService.getContactPage(pageVO); | ||
| 116 | - List<ContactRespVO> contactRespVOList = convertFieldValue2Name(pageData.getList()); | ||
| 117 | - PageResult<ContactRespVO> pageDataReturn = ContactConvert.INSTANCE.convertPage(pageData); | ||
| 118 | - pageDataReturn.setList(contactRespVOList); | ||
| 119 | - return success(pageDataReturn); | 114 | + PageResult<ContactDO> pageResult = contactService.getContactPage(pageVO); |
| 115 | + if (CollUtil.isEmpty(pageResult.getList())) { | ||
| 116 | + return success(PageResult.empty(pageResult.getTotal())); | ||
| 117 | + } | ||
| 118 | + List<ContactRespVO> contactVOList = convertFieldValue2Name(pageResult.getList()); | ||
| 119 | + return success(new PageResult<>(contactVOList, pageResult.getTotal())); | ||
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | // TODO @zyna:可以看下新的导出写法,这里调整下 | 122 | // TODO @zyna:可以看下新的导出写法,这里调整下 |
| @@ -127,27 +127,31 @@ public class ContactController { | @@ -127,27 +127,31 @@ public class ContactController { | ||
| 127 | public void exportContactExcel(@Valid ContactPageReqVO exportReqVO, | 127 | public void exportContactExcel(@Valid ContactPageReqVO exportReqVO, |
| 128 | HttpServletResponse response) throws IOException { | 128 | HttpServletResponse response) throws IOException { |
| 129 | List<ContactDO> list = contactService.getContactList(exportReqVO); | 129 | List<ContactDO> list = contactService.getContactList(exportReqVO); |
| 130 | + // TODO @zya:可以改成直接调用 getContactPage 方法;只要把 ContactPageReqVO 设置成不分页,PAGE_SIZE_NONE | ||
| 130 | // 导出 Excel | 131 | // 导出 Excel |
| 131 | List<ContactRespVO> contactRespVOList = convertFieldValue2Name(list); | 132 | List<ContactRespVO> contactRespVOList = convertFieldValue2Name(list); |
| 132 | - ExcelUtils.write(response, "crm联系人.xls", "数据", ContactRespVO.class, contactRespVOList); | 133 | + ExcelUtils.write(response, "crm 联系人.xls", "数据", ContactRespVO.class, contactRespVOList); |
| 133 | } | 134 | } |
| 134 | 135 | ||
| 136 | + // TODO 芋艿:后续会合并下, | ||
| 135 | /** | 137 | /** |
| 136 | * 翻译字段名称 | 138 | * 翻译字段名称 |
| 137 | * @param contactDOList 联系人List | 139 | * @param contactDOList 联系人List |
| 138 | * @return List<ContactRespVO> | 140 | * @return List<ContactRespVO> |
| 139 | */ | 141 | */ |
| 140 | private List<ContactRespVO> convertFieldValue2Name(List<ContactDO> contactDOList){ | 142 | private List<ContactRespVO> convertFieldValue2Name(List<ContactDO> contactDOList){ |
| 141 | - //1.获取客户列表 | 143 | + // 1. 获取客户列表 |
| 144 | + // TODO @zyna:简单的转换,可以使用 CollectionUtils.convertSet | ||
| 142 | List<Long> customerIdList = contactDOList.stream().map(ContactDO::getCustomerId).distinct().collect(Collectors.toList()); | 145 | List<Long> customerIdList = contactDOList.stream().map(ContactDO::getCustomerId).distinct().collect(Collectors.toList()); |
| 143 | List<CrmCustomerDO> crmCustomerDOList = crmCustomerService.getCustomerList(customerIdList); | 146 | List<CrmCustomerDO> crmCustomerDOList = crmCustomerService.getCustomerList(customerIdList); |
| 144 | - //2.获取创建人、责任人列表 | 147 | + // 2. 获取创建人、责任人列表 |
| 148 | + // TODO @zyna:简单的转换,可以使用 CollectionUtils.convertSetByFlatMap | ||
| 145 | List<Long> userIdsList = contactDOList.stream().flatMap(item-> Stream.of(Long.parseLong(item.getCreator()),item.getOwnerUserId()).distinct()).collect(Collectors.toList()); | 149 | List<Long> userIdsList = contactDOList.stream().flatMap(item-> Stream.of(Long.parseLong(item.getCreator()),item.getOwnerUserId()).distinct()).collect(Collectors.toList()); |
| 146 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIdsList); | 150 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIdsList); |
| 147 | - //3.直属上级 | 151 | + // 3. 直属上级 |
| 148 | List<Long> contactIdsList = contactDOList.stream().map(ContactDO::getParentId).distinct().collect(Collectors.toList()); | 152 | List<Long> contactIdsList = contactDOList.stream().map(ContactDO::getParentId).distinct().collect(Collectors.toList()); |
| 149 | List<ContactDO> contactList = contactService.getContactList(contactIdsList); | 153 | List<ContactDO> contactList = contactService.getContactList(contactIdsList); |
| 150 | - List<ContactRespVO> pageResult =ContactConvert.INSTANCE.converList(contactDOList,userMap,crmCustomerDOList,contactList); | ||
| 151 | - return pageResult; | 154 | + return ContactConvert.INSTANCE.converList(contactDOList,userMap,crmCustomerDOList,contactList); |
| 152 | } | 155 | } |
| 156 | + | ||
| 153 | } | 157 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java
| @@ -4,11 +4,11 @@ import cn.iocoder.yudao.framework.common.validation.Mobile; | @@ -4,11 +4,11 @@ import cn.iocoder.yudao.framework.common.validation.Mobile; | ||
| 4 | import cn.iocoder.yudao.framework.common.validation.Telephone; | 4 | import cn.iocoder.yudao.framework.common.validation.Telephone; |
| 5 | import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | 5 | import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; |
| 6 | import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | 6 | import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; |
| 7 | +import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; | ||
| 7 | import com.alibaba.excel.annotation.ExcelIgnore; | 8 | import com.alibaba.excel.annotation.ExcelIgnore; |
| 8 | import com.alibaba.excel.annotation.ExcelProperty; | 9 | import com.alibaba.excel.annotation.ExcelProperty; |
| 9 | import io.swagger.v3.oas.annotations.media.Schema; | 10 | import io.swagger.v3.oas.annotations.media.Schema; |
| 10 | import lombok.Data; | 11 | import lombok.Data; |
| 11 | -import org.apache.skywalking.apm.toolkit.trace.IgnoredException; | ||
| 12 | import org.springframework.format.annotation.DateTimeFormat; | 12 | import org.springframework.format.annotation.DateTimeFormat; |
| 13 | 13 | ||
| 14 | import javax.validation.constraints.Email; | 14 | import javax.validation.constraints.Email; |
| @@ -35,25 +35,24 @@ public class ContactBaseVO { | @@ -35,25 +35,24 @@ public class ContactBaseVO { | ||
| 35 | @ExcelIgnore | 35 | @ExcelIgnore |
| 36 | private Long customerId; | 36 | private Long customerId; |
| 37 | 37 | ||
| 38 | - @ExcelProperty(value = "性别",converter = DictConvert.class ,order = 3) | 38 | + @ExcelProperty(value = "性别", converter = DictConvert.class, order = 3) |
| 39 | @DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_SEX) | 39 | @DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_SEX) |
| 40 | @Schema(description = "性别") | 40 | @Schema(description = "性别") |
| 41 | private Integer sex; | 41 | private Integer sex; |
| 42 | 42 | ||
| 43 | @Schema(description = "职位") | 43 | @Schema(description = "职位") |
| 44 | - @ExcelProperty(value = "职位",order = 3) | 44 | + @ExcelProperty(value = "职位", order = 3) |
| 45 | private String post; | 45 | private String post; |
| 46 | 46 | ||
| 47 | @Schema(description = "是否关键决策人") | 47 | @Schema(description = "是否关键决策人") |
| 48 | - @ExcelProperty(value = "是否关键决策人",converter = DictConvert.class,order = 3) | ||
| 49 | - @DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.INFRA_BOOLEAN_STRING) | 48 | + @ExcelProperty(value = "是否关键决策人", converter = DictConvert.class, order = 3) |
| 49 | + @DictFormat(DictTypeConstants.BOOLEAN_STRING) | ||
| 50 | private Boolean master; | 50 | private Boolean master; |
| 51 | 51 | ||
| 52 | @Schema(description = "直属上级", example = "23457") | 52 | @Schema(description = "直属上级", example = "23457") |
| 53 | @ExcelIgnore | 53 | @ExcelIgnore |
| 54 | private Long parentId; | 54 | private Long parentId; |
| 55 | 55 | ||
| 56 | - | ||
| 57 | @Schema(description = "手机号",example = "1387171766") | 56 | @Schema(description = "手机号",example = "1387171766") |
| 58 | @Mobile | 57 | @Mobile |
| 59 | @ExcelProperty(value = "手机号",order = 4) | 58 | @ExcelProperty(value = "手机号",order = 4) |
| @@ -98,7 +97,7 @@ public class ContactBaseVO { | @@ -98,7 +97,7 @@ public class ContactBaseVO { | ||
| 98 | 97 | ||
| 99 | @Schema(description = "负责人用户编号", example = "14334") | 98 | @Schema(description = "负责人用户编号", example = "14334") |
| 100 | @NotNull(message = "负责人不能为空") | 99 | @NotNull(message = "负责人不能为空") |
| 101 | - @ExcelIgnore | 100 | + @ExcelIgnore // TODO @zyna:可以使用 ExcelIgnoreUnannotated |
| 102 | private Long ownerUserId; | 101 | private Long ownerUserId; |
| 103 | 102 | ||
| 104 | @Schema(description = "地区编号", example = "20158") | 103 | @Schema(description = "地区编号", example = "20158") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java
| @@ -11,13 +11,13 @@ import java.time.LocalDateTime; | @@ -11,13 +11,13 @@ 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 @zyna:筛选条件 | 20 | + // TODO @zyna:筛选条件(多余的可以删除哈)还有部分 example 少了,可以补充下; |
| 21 | // ●客户: | 21 | // ●客户: |
| 22 | // ●姓名: | 22 | // ●姓名: |
| 23 | // ●手机、电话、座机、QQ、微信、邮箱 | 23 | // ●手机、电话、座机、QQ、微信、邮箱 |
| @@ -26,13 +26,13 @@ public class ContactPageReqVO extends PageParam { | @@ -26,13 +26,13 @@ public class ContactPageReqVO extends PageParam { | ||
| 26 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | 26 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 27 | private LocalDateTime[] nextTime; | 27 | private LocalDateTime[] nextTime; |
| 28 | 28 | ||
| 29 | - @Schema(description = "手机号",example = "13898273941") | 29 | + @Schema(description = "手机号", example = "13898273941") |
| 30 | private String mobile; | 30 | private String mobile; |
| 31 | 31 | ||
| 32 | - @Schema(description = "电话",example = "021-383773") | 32 | + @Schema(description = "电话", example = "021-383773") |
| 33 | private String telephone; | 33 | private String telephone; |
| 34 | 34 | ||
| 35 | - @Schema(description = "电子邮箱",example = "111@22.com") | 35 | + @Schema(description = "电子邮箱", example = "111@22.com") |
| 36 | private String email; | 36 | private String email; |
| 37 | 37 | ||
| 38 | @Schema(description = "客户编号", example = "10795") | 38 | @Schema(description = "客户编号", example = "10795") |
| @@ -61,10 +61,10 @@ public class ContactPageReqVO extends PageParam { | @@ -61,10 +61,10 @@ public class ContactPageReqVO extends PageParam { | ||
| 61 | @Schema(description = "职位") | 61 | @Schema(description = "职位") |
| 62 | private String post; | 62 | private String post; |
| 63 | 63 | ||
| 64 | - @Schema(description = "QQ",example = "3882872") | 64 | + @Schema(description = "QQ", example = "3882872") |
| 65 | private Long qq; | 65 | private Long qq; |
| 66 | 66 | ||
| 67 | - @Schema(description = "微信",example = "zzZ98373") | 67 | + @Schema(description = "微信", example = "zzZ98373") |
| 68 | private String wechat; | 68 | private String wechat; |
| 69 | 69 | ||
| 70 | @Schema(description = "性别") | 70 | @Schema(description = "性别") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
| @@ -172,6 +172,8 @@ public class CrmCustomerController { | @@ -172,6 +172,8 @@ public class CrmCustomerController { | ||
| 172 | customerService.receiveCustomer(ids, ownerUserId); | 172 | customerService.receiveCustomer(ids, ownerUserId); |
| 173 | return success(true); | 173 | return success(true); |
| 174 | } | 174 | } |
| 175 | + | ||
| 176 | + // TODO 芋艿:这个接口要调整下 | ||
| 175 | @GetMapping("/query-all-list") | 177 | @GetMapping("/query-all-list") |
| 176 | @Operation(summary = "查询客户列表") | 178 | @Operation(summary = "查询客户列表") |
| 177 | @PreAuthorize("@ss.hasPermission('crm:customer:all')") | 179 | @PreAuthorize("@ss.hasPermission('crm:customer:all')") |
| @@ -180,4 +182,5 @@ public class CrmCustomerController { | @@ -180,4 +182,5 @@ public class CrmCustomerController { | ||
| 180 | List<CrmCustomerQueryAllRespVO> data = CrmCustomerConvert.INSTANCE.convertQueryAll(crmCustomerDOList); | 182 | List<CrmCustomerQueryAllRespVO> data = CrmCustomerConvert.INSTANCE.convertQueryAll(crmCustomerDOList); |
| 181 | return success(data); | 183 | return success(data); |
| 182 | } | 184 | } |
| 185 | + | ||
| 183 | } | 186 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerQueryAllRespVO.java
| @@ -3,13 +3,15 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; | @@ -3,13 +3,15 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; | ||
| 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 | - | 6 | +// TODO 芋艿:这块要统一下; |
| 7 | @Schema(description = "管理后台 - CRM 全部客户 Response VO") | 7 | @Schema(description = "管理后台 - CRM 全部客户 Response VO") |
| 8 | @Data | 8 | @Data |
| 9 | public class CrmCustomerQueryAllRespVO{ | 9 | public class CrmCustomerQueryAllRespVO{ |
| 10 | - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") | ||
| 11 | - private String name; | 10 | + |
| 12 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") | 11 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") |
| 13 | private Long id; | 12 | private Long id; |
| 14 | 13 | ||
| 14 | + @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") | ||
| 15 | + private String name; | ||
| 16 | + | ||
| 15 | } | 17 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java
| @@ -46,7 +46,8 @@ public interface ContactConvert { | @@ -46,7 +46,8 @@ public interface ContactConvert { | ||
| 46 | CrmPermissionTransferReqBO convert(CrmContactTransferReqVO reqVO, Long userId); | 46 | CrmPermissionTransferReqBO convert(CrmContactTransferReqVO reqVO, Long userId); |
| 47 | 47 | ||
| 48 | /** | 48 | /** |
| 49 | - * 详情信息 | 49 | + * 转换详情信息 |
| 50 | + * | ||
| 50 | * @param contactDO 联系人 | 51 | * @param contactDO 联系人 |
| 51 | * @param userMap 用户列表 | 52 | * @param userMap 用户列表 |
| 52 | * @param crmCustomerDOList 客户 | 53 | * @param crmCustomerDOList 客户 |
| @@ -54,26 +55,28 @@ public interface ContactConvert { | @@ -54,26 +55,28 @@ public interface ContactConvert { | ||
| 54 | */ | 55 | */ |
| 55 | default ContactRespVO convert(ContactDO contactDO, Map<Long, AdminUserRespDTO> userMap, List<CrmCustomerDO> crmCustomerDOList, | 56 | default ContactRespVO convert(ContactDO contactDO, Map<Long, AdminUserRespDTO> userMap, List<CrmCustomerDO> crmCustomerDOList, |
| 56 | List<ContactDO> contactList) { | 57 | List<ContactDO> contactList) { |
| 57 | - ContactRespVO contactRespVO = convert(contactDO); | ||
| 58 | - setUserInfo(contactRespVO,userMap); | ||
| 59 | - Map<Long,CrmCustomerDO> crmCustomerDOMap = crmCustomerDOList.stream().collect(Collectors.toMap(CrmCustomerDO::getId,v->v)); | ||
| 60 | - Map<Long,ContactDO> contactDOMap = contactList.stream().collect(Collectors.toMap(ContactDO::getId,v->v)); | ||
| 61 | - findAndThen(crmCustomerDOMap,contactDO.getCustomerId(),customer -> {contactRespVO.setCustomerName(customer.getName());}); | ||
| 62 | - findAndThen(contactDOMap,contactDO.getParentId(),contactDOInner -> {contactRespVO.setParentName(contactDOInner.getName());}); | ||
| 63 | - return contactRespVO; | ||
| 64 | - } | ||
| 65 | - default List<ContactRespVO> converList(List<ContactDO> contactDOList, Map<Long, AdminUserRespDTO> userMap, | ||
| 66 | - List<CrmCustomerDO> crmCustomerDOList , List<ContactDO> contactList){ | ||
| 67 | - List<ContactRespVO> result = convertList(contactDOList); | 58 | + ContactRespVO contactVO = convert(contactDO); |
| 59 | + setUserInfo(contactVO, userMap); | ||
| 60 | + Map<Long,CrmCustomerDO> ustomerMap = crmCustomerDOList.stream().collect(Collectors.toMap(CrmCustomerDO::getId,v->v)); | ||
| 68 | Map<Long,ContactDO> contactMap = contactList.stream().collect(Collectors.toMap(ContactDO::getId,v->v)); | 61 | Map<Long,ContactDO> contactMap = contactList.stream().collect(Collectors.toMap(ContactDO::getId,v->v)); |
| 69 | - Map<Long,CrmCustomerDO> customerMap = crmCustomerDOList.stream().collect(Collectors.toMap(CrmCustomerDO::getId,v->v)); | 62 | + findAndThen(ustomerMap, contactDO.getCustomerId(), customer -> contactVO.setCustomerName(customer.getName())); |
| 63 | + findAndThen(contactMap, contactDO.getParentId(), contact -> contactVO.setParentName(contact.getName())); | ||
| 64 | + return contactVO; | ||
| 65 | + } | ||
| 66 | + default List<ContactRespVO> converList(List<ContactDO> contactList, Map<Long, AdminUserRespDTO> userMap, | ||
| 67 | + List<CrmCustomerDO> customerList, List<ContactDO> parentContactList) { | ||
| 68 | + List<ContactRespVO> result = convertList(contactList); | ||
| 69 | + // TODO @zyna:简单的转换,可以使用 CollectionUtils.convertMap | ||
| 70 | + Map<Long, ContactDO> parentContactMap = parentContactList.stream().collect(Collectors.toMap(ContactDO::getId,v->v)); | ||
| 71 | + Map<Long, CrmCustomerDO> customerMap = customerList.stream().collect(Collectors.toMap(CrmCustomerDO::getId,v->v)); | ||
| 70 | result.forEach(item -> { | 72 | result.forEach(item -> { |
| 71 | setUserInfo(item, userMap); | 73 | setUserInfo(item, userMap); |
| 72 | findAndThen(customerMap,item.getCustomerId(),customer -> {item.setCustomerName(customer.getName());}); | 74 | findAndThen(customerMap,item.getCustomerId(),customer -> {item.setCustomerName(customer.getName());}); |
| 73 | - findAndThen(contactMap,item.getParentId(),contactDO -> {item.setParentName(contactDO.getName());}); | 75 | + findAndThen(parentContactMap,item.getParentId(),contactDO -> {item.setParentName(contactDO.getName());}); |
| 74 | }); | 76 | }); |
| 75 | return result; | 77 | return result; |
| 76 | } | 78 | } |
| 79 | + | ||
| 77 | /** | 80 | /** |
| 78 | * 设置用户信息 | 81 | * 设置用户信息 |
| 79 | * | 82 | * |
| @@ -87,4 +90,5 @@ public interface ContactConvert { | @@ -87,4 +90,5 @@ public interface ContactConvert { | ||
| 87 | }); | 90 | }); |
| 88 | findAndThen(userMap, Long.parseLong(contactRespVO.getCreator()), user -> contactRespVO.setCreatorName(user.getNickname())); | 91 | findAndThen(userMap, Long.parseLong(contactRespVO.getCreator()), user -> contactRespVO.setCreatorName(user.getNickname())); |
| 89 | } | 92 | } |
| 93 | + | ||
| 90 | } | 94 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java
| @@ -72,9 +72,7 @@ public interface CrmCustomerConvert { | @@ -72,9 +72,7 @@ public interface CrmCustomerConvert { | ||
| 72 | default PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> pageResult, Map<Long, AdminUserRespDTO> userMap, | 72 | default PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> pageResult, Map<Long, AdminUserRespDTO> userMap, |
| 73 | Map<Long, DeptRespDTO> deptMap) { | 73 | Map<Long, DeptRespDTO> deptMap) { |
| 74 | PageResult<CrmCustomerRespVO> result = convertPage(pageResult); | 74 | PageResult<CrmCustomerRespVO> result = convertPage(pageResult); |
| 75 | - result.getList().forEach(item -> { | ||
| 76 | - setUserInfo(item, userMap, deptMap); | ||
| 77 | - }); | 75 | + result.getList().forEach(item -> setUserInfo(item, userMap, deptMap)); |
| 78 | return result; | 76 | return result; |
| 79 | } | 77 | } |
| 80 | 78 | ||
| @@ -82,6 +80,6 @@ public interface CrmCustomerConvert { | @@ -82,6 +80,6 @@ public interface CrmCustomerConvert { | ||
| 82 | 80 | ||
| 83 | CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO); | 81 | CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO); |
| 84 | 82 | ||
| 85 | - CrmCustomerQueryAllRespVO convertQueryAll(CrmCustomerDO crmCustomerDO); | ||
| 86 | List<CrmCustomerQueryAllRespVO> convertQueryAll(List<CrmCustomerDO> crmCustomerDO); | 83 | List<CrmCustomerQueryAllRespVO> convertQueryAll(List<CrmCustomerDO> crmCustomerDO); |
| 84 | + | ||
| 87 | } | 85 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java
| @@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | @@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | import com.baomidou.mybatisplus.annotation.KeySequence; | 4 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 5 | import com.baomidou.mybatisplus.annotation.TableId; | 5 | import com.baomidou.mybatisplus.annotation.TableId; |
| 6 | import com.baomidou.mybatisplus.annotation.TableName; | 6 | import com.baomidou.mybatisplus.annotation.TableName; |
| 7 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 8 | import lombok.*; | 7 | import lombok.*; |
| 9 | 8 | ||
| 10 | import java.time.LocalDateTime; | 9 | import java.time.LocalDateTime; |
| @@ -23,6 +22,7 @@ import java.time.LocalDateTime; | @@ -23,6 +22,7 @@ import java.time.LocalDateTime; | ||
| 23 | @NoArgsConstructor | 22 | @NoArgsConstructor |
| 24 | @AllArgsConstructor | 23 | @AllArgsConstructor |
| 25 | public class ContactDO extends BaseDO { | 24 | public class ContactDO extends BaseDO { |
| 25 | + | ||
| 26 | /** | 26 | /** |
| 27 | * 主键 | 27 | * 主键 |
| 28 | */ | 28 | */ |
| @@ -61,7 +61,9 @@ public class ContactDO extends BaseDO { | @@ -61,7 +61,9 @@ public class ContactDO extends BaseDO { | ||
| 61 | */ | 61 | */ |
| 62 | private LocalDateTime lastTime; | 62 | private LocalDateTime lastTime; |
| 63 | /** | 63 | /** |
| 64 | - * 直属上级 @link ContactDO#id | 64 | + * 直属上级 |
| 65 | + * | ||
| 66 | + * 关联 {@link ContactDO#id} | ||
| 65 | */ | 67 | */ |
| 66 | private Long parentId; | 68 | private Long parentId; |
| 67 | /** | 69 | /** |
| @@ -82,7 +84,8 @@ public class ContactDO extends BaseDO { | @@ -82,7 +84,8 @@ public class ContactDO extends BaseDO { | ||
| 82 | private String wechat; | 84 | private String wechat; |
| 83 | /** | 85 | /** |
| 84 | * 性别 | 86 | * 性别 |
| 85 | - * @See 字典配置 | 87 | + * |
| 88 | + * 枚举 {@link cn.iocoder.yudao.module.system.enums.common.SexEnum} | ||
| 86 | */ | 89 | */ |
| 87 | private Integer sex; | 90 | private Integer sex; |
| 88 | /** | 91 | /** |
| @@ -91,8 +94,16 @@ public class ContactDO extends BaseDO { | @@ -91,8 +94,16 @@ public class ContactDO extends BaseDO { | ||
| 91 | private Boolean master; | 94 | private Boolean master; |
| 92 | /** | 95 | /** |
| 93 | * 负责人用户编号 | 96 | * 负责人用户编号 |
| 97 | + * | ||
| 98 | + * 关联 AdminUserDO 的 id 字段 | ||
| 94 | */ | 99 | */ |
| 95 | private Long ownerUserId; | 100 | private Long ownerUserId; |
| 96 | 101 | ||
| 102 | + /** | ||
| 103 | + * 所在地 | ||
| 104 | + * | ||
| 105 | + * 关联 {@link cn.iocoder.yudao.framework.ip.core.Area#getId()} 字段 | ||
| 106 | + */ | ||
| 97 | private Integer areaId; | 107 | private Integer areaId; |
| 108 | + | ||
| 98 | } | 109 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java
| @@ -56,7 +56,7 @@ public class ContactServiceImpl implements ContactService { | @@ -56,7 +56,7 @@ public class ContactServiceImpl implements ContactService { | ||
| 56 | 56 | ||
| 57 | @Override | 57 | @Override |
| 58 | @Transactional(rollbackFor = Exception.class) | 58 | @Transactional(rollbackFor = Exception.class) |
| 59 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS,bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) | 59 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) |
| 60 | public void updateContact(ContactUpdateReqVO updateReqVO) { | 60 | public void updateContact(ContactUpdateReqVO updateReqVO) { |
| 61 | // 校验存在 | 61 | // 校验存在 |
| 62 | validateContactExists(updateReqVO.getId()); | 62 | validateContactExists(updateReqVO.getId()); |
| @@ -67,7 +67,7 @@ public class ContactServiceImpl implements ContactService { | @@ -67,7 +67,7 @@ public class ContactServiceImpl implements ContactService { | ||
| 67 | 67 | ||
| 68 | @Override | 68 | @Override |
| 69 | @Transactional(rollbackFor = Exception.class) | 69 | @Transactional(rollbackFor = Exception.class) |
| 70 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS,bizId = "#id", level = CrmPermissionLevelEnum.WRITE) | 70 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) |
| 71 | public void deleteContact(Long id) { | 71 | public void deleteContact(Long id) { |
| 72 | // 校验存在 | 72 | // 校验存在 |
| 73 | validateContactExists(id); | 73 | validateContactExists(id); |
| @@ -82,7 +82,7 @@ public class ContactServiceImpl implements ContactService { | @@ -82,7 +82,7 @@ public class ContactServiceImpl implements ContactService { | ||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | @Override | 84 | @Override |
| 85 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS,bizId = "#id", level = CrmPermissionLevelEnum.READ) | 85 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, bizId = "#id", level = CrmPermissionLevelEnum.READ) |
| 86 | public ContactDO getContact(Long id) { | 86 | public ContactDO getContact(Long id) { |
| 87 | return contactMapper.selectById(id); | 87 | return contactMapper.selectById(id); |
| 88 | } | 88 | } |
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/DictTypeConstants.java
| @@ -26,6 +26,4 @@ public interface DictTypeConstants { | @@ -26,6 +26,4 @@ public interface DictTypeConstants { | ||
| 26 | String SMS_SEND_STATUS = "system_sms_send_status"; // 短信发送状态 | 26 | String SMS_SEND_STATUS = "system_sms_send_status"; // 短信发送状态 |
| 27 | String SMS_RECEIVE_STATUS = "system_sms_receive_status"; // 短信接收状态 | 27 | String SMS_RECEIVE_STATUS = "system_sms_receive_status"; // 短信接收状态 |
| 28 | 28 | ||
| 29 | - String INFRA_BOOLEAN_STRING = "infra_boolean_string"; // boolean字典 | ||
| 30 | - | ||
| 31 | } | 29 | } |