📖 CRM:跟进记录的 code review

This commit is contained in:
YunaiV 2024-01-15 13:43:15 +08:00
parent e64e60c711
commit 410c551e03
5 changed files with 18 additions and 30 deletions

View File

@ -125,6 +125,7 @@ public class CrmContactController {
@Operation(summary = "获得联系人的精简列表")
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
public CommonResult<List<CrmContactRespVO>> getSimpleContactList() {
// TODO @puhui999这种还是搞个 getContactList 方法好点哈
CrmContactPageReqVO reqVO = new CrmContactPageReqVO();
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
PageResult<CrmContactDO> pageResult = contactService.getContactPage(reqVO, getLoginUserId());

View File

@ -5,6 +5,7 @@ import lombok.Data;
import java.time.LocalDateTime;
// TODO @puhui999导出注解哈
@Schema(description = "管理后台 - CRM 合同 Response VO")
@Data
public class CrmContractRespVO {

View File

@ -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<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) {
PageResult<CrmFollowUpRecordDO> pageResult = crmFollowUpRecordService.getFollowUpRecordPage(pageReqVO);
Set<Long> contactIds = convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream());
Set<Long> businessIds = convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream());
Map<Long, CrmContactDO> contactMap = convertMap(contactService.getContactList(contactIds), CrmContactDO::getId);
Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList(businessIds), CrmBusinessDO::getId);
PageResult<CrmFollowUpRecordRespVO> result = BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class);
result.getList().forEach(item -> {
setContactNames(item, contactMap);
setBusinessNames(item, businessMap);
/// 拼接数据
Map<Long, CrmContactDO> contactMap = convertMap(contactService.getContactList(
convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream())), CrmContactDO::getId);
Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList(
convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream())), CrmBusinessDO::getId);
PageResult<CrmFollowUpRecordRespVO> 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<Long, CrmContactDO> contactMap) {
List<String> 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<Long, CrmBusinessDO> businessMap) {
List<String> names = new ArrayList<>();
vo.getContactIds().forEach(id -> {
MapUtils.findAndThen(businessMap, id, businessDO -> names.add(businessDO.getName()));
});
vo.setBusinessNames(names);
return success(voPageResult);
}
}

View File

@ -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;
/**

View File

@ -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需要更新 businessIdscontactIds 对应的记录
return followUpRecord.getId();
}