From 410c551e0306fbbb4fde7d948744d319f49f33af Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 15 Jan 2024 13:43:15 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=96=20CRM=EF=BC=9A=E8=B7=9F=E8=BF=9B?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=9A=84=20code=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/contact/CrmContactController.java | 1 + .../admin/contract/vo/CrmContractRespVO.java | 1 + .../followup/CrmFollowUpRecordController.java | 39 ++++++------------- .../followup/CrmFollowUpRecordDO.java | 3 +- .../CrmFollowUpRecordServiceImpl.java | 4 +- 5 files changed, 18 insertions(+), 30 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java index a6c8f8427..4b3e7d1e2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java @@ -125,6 +125,7 @@ public class CrmContactController { @Operation(summary = "获得联系人的精简列表") @PreAuthorize("@ss.hasPermission('crm:contact:query')") public CommonResult> getSimpleContactList() { + // TODO @puhui999:这种还是搞个 getContactList 方法好点哈; CrmContactPageReqVO reqVO = new CrmContactPageReqVO(); reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 PageResult pageResult = contactService.getContactPage(reqVO, getLoginUserId()); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractRespVO.java index 95fb24cf2..9a1ae58f3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractRespVO.java @@ -5,6 +5,7 @@ import lombok.Data; import java.time.LocalDateTime; +// TODO @puhui999:导出注解哈 @Schema(description = "管理后台 - CRM 合同 Response VO") @Data public class CrmContractRespVO { diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java index c46bfefcb..bf63e4542 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java @@ -23,9 +23,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; -import java.util.List; import java.util.Map; -import java.util.Set; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; @@ -83,32 +81,19 @@ public class CrmFollowUpRecordController { @PreAuthorize("@ss.hasPermission('crm:follow-up-record:query')") public CommonResult> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) { PageResult pageResult = crmFollowUpRecordService.getFollowUpRecordPage(pageReqVO); - Set contactIds = convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream()); - Set businessIds = convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream()); - Map contactMap = convertMap(contactService.getContactList(contactIds), CrmContactDO::getId); - Map businessMap = convertMap(businessService.getBusinessList(businessIds), CrmBusinessDO::getId); - PageResult result = BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class); - result.getList().forEach(item -> { - setContactNames(item, contactMap); - setBusinessNames(item, businessMap); + /// 拼接数据 + Map contactMap = convertMap(contactService.getContactList( + convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream())), CrmContactDO::getId); + Map businessMap = convertMap(businessService.getBusinessList( + convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream())), CrmBusinessDO::getId); + PageResult voPageResult = BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class, record -> { + record.setContactNames(new ArrayList<>()).setBusinessNames(new ArrayList<>()); + record.getContactIds().forEach(id -> MapUtils.findAndThen(contactMap, id, + contact -> record.getContactNames().add(contact.getName()))); + record.getContactIds().forEach(id -> MapUtils.findAndThen(businessMap, id, + business -> record.getBusinessNames().add(business.getName()))); }); - return success(result); - } - - private static void setContactNames(CrmFollowUpRecordRespVO vo, Map contactMap) { - List names = new ArrayList<>(); - vo.getContactIds().forEach(id -> { - MapUtils.findAndThen(contactMap, id, contactDO -> names.add(contactDO.getName())); - }); - vo.setContactNames(names); - } - - private static void setBusinessNames(CrmFollowUpRecordRespVO vo, Map businessMap) { - List names = new ArrayList<>(); - vo.getContactIds().forEach(id -> { - MapUtils.findAndThen(businessMap, id, businessDO -> names.add(businessDO.getName())); - }); - vo.setBusinessNames(names); + return success(voPageResult); } } \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java index 8ff5a15aa..896ad0297 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java @@ -52,8 +52,9 @@ public class CrmFollowUpRecordDO extends BaseDO { private Long bizId; /** - * 跟进类型,关联字典{@link DictTypeConstants#CRM_FOLLOW_UP_TYPE} + * 跟进类型 * + * 关联 {@link DictTypeConstants#CRM_FOLLOW_UP_TYPE} 字典 */ private Integer type; /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java index 5742791e4..ab5a64d35 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java @@ -27,10 +27,10 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { @Override public Long createFollowUpRecord(CrmFollowUpRecordSaveReqVO createReqVO) { - // 插入 CrmFollowUpRecordDO followUpRecord = BeanUtils.toBean(createReqVO, CrmFollowUpRecordDO.class); crmFollowUpRecordMapper.insert(followUpRecord); - // 返回 + // TODO @puhui999:需要更新 bizId 对应的记录; + // TODO @puhui999:需要更新 businessIds、contactIds 对应的记录; return followUpRecord.getId(); }