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,6 +125,7 @@ public class CrmContactController { | ||
| 125 | @Operation(summary = "获得联系人的精简列表") | 125 | @Operation(summary = "获得联系人的精简列表") |
| 126 | @PreAuthorize("@ss.hasPermission('crm:contact:query')") | 126 | @PreAuthorize("@ss.hasPermission('crm:contact:query')") |
| 127 | public CommonResult<List<CrmContactRespVO>> getSimpleContactList() { | 127 | public CommonResult<List<CrmContactRespVO>> getSimpleContactList() { |
| 128 | + // TODO @puhui999:这种还是搞个 getContactList 方法好点哈; | ||
| 128 | CrmContactPageReqVO reqVO = new CrmContactPageReqVO(); | 129 | CrmContactPageReqVO reqVO = new CrmContactPageReqVO(); |
| 129 | reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 | 130 | reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 |
| 130 | PageResult<CrmContactDO> pageResult = contactService.getContactPage(reqVO, getLoginUserId()); | 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
| @@ -5,6 +5,7 @@ import lombok.Data; | @@ -5,6 +5,7 @@ import lombok.Data; | ||
| 5 | 5 | ||
| 6 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
| 7 | 7 | ||
| 8 | +// TODO @puhui999:导出注解哈 | ||
| 8 | @Schema(description = "管理后台 - CRM 合同 Response VO") | 9 | @Schema(description = "管理后台 - CRM 合同 Response VO") |
| 9 | @Data | 10 | @Data |
| 10 | public class CrmContractRespVO { | 11 | public class CrmContractRespVO { |
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,9 +23,7 @@ import org.springframework.validation.annotation.Validated; | ||
| 23 | import org.springframework.web.bind.annotation.*; | 23 | import org.springframework.web.bind.annotation.*; |
| 24 | 24 | ||
| 25 | import java.util.ArrayList; | 25 | import java.util.ArrayList; |
| 26 | -import java.util.List; | ||
| 27 | import java.util.Map; | 26 | import java.util.Map; |
| 28 | -import java.util.Set; | ||
| 29 | 27 | ||
| 30 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 28 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 31 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | 29 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| @@ -83,32 +81,19 @@ public class CrmFollowUpRecordController { | @@ -83,32 +81,19 @@ public class CrmFollowUpRecordController { | ||
| 83 | @PreAuthorize("@ss.hasPermission('crm:follow-up-record:query')") | 81 | @PreAuthorize("@ss.hasPermission('crm:follow-up-record:query')") |
| 84 | public CommonResult<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) { | 82 | public CommonResult<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) { |
| 85 | PageResult<CrmFollowUpRecordDO> pageResult = crmFollowUpRecordService.getFollowUpRecordPage(pageReqVO); | 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 | \ No newline at end of file | 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,8 +52,9 @@ public class CrmFollowUpRecordDO extends BaseDO { | ||
| 52 | private Long bizId; | 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 | private Integer type; | 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,10 +27,10 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { | ||
| 27 | 27 | ||
| 28 | @Override | 28 | @Override |
| 29 | public Long createFollowUpRecord(CrmFollowUpRecordSaveReqVO createReqVO) { | 29 | public Long createFollowUpRecord(CrmFollowUpRecordSaveReqVO createReqVO) { |
| 30 | - // 插入 | ||
| 31 | CrmFollowUpRecordDO followUpRecord = BeanUtils.toBean(createReqVO, CrmFollowUpRecordDO.class); | 30 | CrmFollowUpRecordDO followUpRecord = BeanUtils.toBean(createReqVO, CrmFollowUpRecordDO.class); |
| 32 | crmFollowUpRecordMapper.insert(followUpRecord); | 31 | crmFollowUpRecordMapper.insert(followUpRecord); |
| 33 | - // 返回 | 32 | + // TODO @puhui999:需要更新 bizId 对应的记录; |
| 33 | + // TODO @puhui999:需要更新 businessIds、contactIds 对应的记录; | ||
| 34 | return followUpRecord.getId(); | 34 | return followUpRecord.getId(); |
| 35 | } | 35 | } |
| 36 | 36 |