Commit 410c551e0306fbbb4fde7d948744d319f49f33af
1 parent
e64e60c7
📖 CRM:跟进记录的 code review
Showing
5 changed files
with
18 additions
and
30 deletions
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 { |
| 125 | 125 | @Operation(summary = "获得联系人的精简列表") |
| 126 | 126 | @PreAuthorize("@ss.hasPermission('crm:contact:query')") |
| 127 | 127 | public CommonResult<List<CrmContactRespVO>> getSimpleContactList() { |
| 128 | + // TODO @puhui999:这种还是搞个 getContactList 方法好点哈; | |
| 128 | 129 | CrmContactPageReqVO reqVO = new CrmContactPageReqVO(); |
| 129 | 130 | reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 |
| 130 | 131 | PageResult<CrmContactDO> pageResult = contactService.getContactPage(reqVO, getLoginUserId()); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractRespVO.java
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; |
| 23 | 23 | import org.springframework.web.bind.annotation.*; |
| 24 | 24 | |
| 25 | 25 | import java.util.ArrayList; |
| 26 | -import java.util.List; | |
| 27 | 26 | import java.util.Map; |
| 28 | -import java.util.Set; | |
| 29 | 27 | |
| 30 | 28 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 31 | 29 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| ... | ... | @@ -83,32 +81,19 @@ public class CrmFollowUpRecordController { |
| 83 | 81 | @PreAuthorize("@ss.hasPermission('crm:follow-up-record:query')") |
| 84 | 82 | public CommonResult<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) { |
| 85 | 83 | PageResult<CrmFollowUpRecordDO> pageResult = crmFollowUpRecordService.getFollowUpRecordPage(pageReqVO); |
| 86 | - Set<Long> contactIds = convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream()); | |
| 87 | - Set<Long> businessIds = convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream()); | |
| 88 | - Map<Long, CrmContactDO> contactMap = convertMap(contactService.getContactList(contactIds), CrmContactDO::getId); | |
| 89 | - Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList(businessIds), CrmBusinessDO::getId); | |
| 90 | - PageResult<CrmFollowUpRecordRespVO> result = BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class); | |
| 91 | - result.getList().forEach(item -> { | |
| 92 | - setContactNames(item, contactMap); | |
| 93 | - setBusinessNames(item, businessMap); | |
| 84 | + /// 拼接数据 | |
| 85 | + Map<Long, CrmContactDO> contactMap = convertMap(contactService.getContactList( | |
| 86 | + convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream())), CrmContactDO::getId); | |
| 87 | + Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList( | |
| 88 | + convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream())), CrmBusinessDO::getId); | |
| 89 | + PageResult<CrmFollowUpRecordRespVO> voPageResult = BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class, record -> { | |
| 90 | + record.setContactNames(new ArrayList<>()).setBusinessNames(new ArrayList<>()); | |
| 91 | + record.getContactIds().forEach(id -> MapUtils.findAndThen(contactMap, id, | |
| 92 | + contact -> record.getContactNames().add(contact.getName()))); | |
| 93 | + record.getContactIds().forEach(id -> MapUtils.findAndThen(businessMap, id, | |
| 94 | + business -> record.getBusinessNames().add(business.getName()))); | |
| 94 | 95 | }); |
| 95 | - return success(result); | |
| 96 | - } | |
| 97 | - | |
| 98 | - private static void setContactNames(CrmFollowUpRecordRespVO vo, Map<Long, CrmContactDO> contactMap) { | |
| 99 | - List<String> names = new ArrayList<>(); | |
| 100 | - vo.getContactIds().forEach(id -> { | |
| 101 | - MapUtils.findAndThen(contactMap, id, contactDO -> names.add(contactDO.getName())); | |
| 102 | - }); | |
| 103 | - vo.setContactNames(names); | |
| 104 | - } | |
| 105 | - | |
| 106 | - private static void setBusinessNames(CrmFollowUpRecordRespVO vo, Map<Long, CrmBusinessDO> businessMap) { | |
| 107 | - List<String> names = new ArrayList<>(); | |
| 108 | - vo.getContactIds().forEach(id -> { | |
| 109 | - MapUtils.findAndThen(businessMap, id, businessDO -> names.add(businessDO.getName())); | |
| 110 | - }); | |
| 111 | - vo.setBusinessNames(names); | |
| 96 | + return success(voPageResult); | |
| 112 | 97 | } |
| 113 | 98 | |
| 114 | 99 | } |
| 115 | 100 | \ No newline at end of file | ... | ... |
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 { |
| 52 | 52 | private Long bizId; |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * 跟进类型,关联字典{@link DictTypeConstants#CRM_FOLLOW_UP_TYPE} | |
| 55 | + * 跟进类型 | |
| 56 | 56 | * |
| 57 | + * 关联 {@link DictTypeConstants#CRM_FOLLOW_UP_TYPE} 字典 | |
| 57 | 58 | */ |
| 58 | 59 | private Integer type; |
| 59 | 60 | /** | ... | ... |
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 { |
| 27 | 27 | |
| 28 | 28 | @Override |
| 29 | 29 | public Long createFollowUpRecord(CrmFollowUpRecordSaveReqVO createReqVO) { |
| 30 | - // 插入 | |
| 31 | 30 | CrmFollowUpRecordDO followUpRecord = BeanUtils.toBean(createReqVO, CrmFollowUpRecordDO.class); |
| 32 | 31 | crmFollowUpRecordMapper.insert(followUpRecord); |
| 33 | - // 返回 | |
| 32 | + // TODO @puhui999:需要更新 bizId 对应的记录; | |
| 33 | + // TODO @puhui999:需要更新 businessIds、contactIds 对应的记录; | |
| 34 | 34 | return followUpRecord.getId(); |
| 35 | 35 | } |
| 36 | 36 | ... | ... |