📖 CRM:跟进记录的 code review
This commit is contained in:
parent
e64e60c711
commit
410c551e03
@ -125,6 +125,7 @@ public class CrmContactController {
|
|||||||
@Operation(summary = "获得联系人的精简列表")
|
@Operation(summary = "获得联系人的精简列表")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
|
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
|
||||||
public CommonResult<List<CrmContactRespVO>> getSimpleContactList() {
|
public CommonResult<List<CrmContactRespVO>> getSimpleContactList() {
|
||||||
|
// TODO @puhui999:这种还是搞个 getContactList 方法好点哈;
|
||||||
CrmContactPageReqVO reqVO = new CrmContactPageReqVO();
|
CrmContactPageReqVO reqVO = new CrmContactPageReqVO();
|
||||||
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
|
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
|
||||||
PageResult<CrmContactDO> pageResult = contactService.getContactPage(reqVO, getLoginUserId());
|
PageResult<CrmContactDO> pageResult = contactService.getContactPage(reqVO, getLoginUserId());
|
||||||
|
@ -5,6 +5,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
// TODO @puhui999:导出注解哈
|
||||||
@Schema(description = "管理后台 - CRM 合同 Response VO")
|
@Schema(description = "管理后台 - CRM 合同 Response VO")
|
||||||
@Data
|
@Data
|
||||||
public class CrmContractRespVO {
|
public class CrmContractRespVO {
|
||||||
|
@ -23,9 +23,7 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
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.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
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')")
|
@PreAuthorize("@ss.hasPermission('crm:follow-up-record:query')")
|
||||||
public CommonResult<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) {
|
public CommonResult<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) {
|
||||||
PageResult<CrmFollowUpRecordDO> pageResult = crmFollowUpRecordService.getFollowUpRecordPage(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(
|
||||||
Map<Long, CrmContactDO> contactMap = convertMap(contactService.getContactList(contactIds), CrmContactDO::getId);
|
convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream())), CrmContactDO::getId);
|
||||||
Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList(businessIds), CrmBusinessDO::getId);
|
Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList(
|
||||||
PageResult<CrmFollowUpRecordRespVO> result = BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class);
|
convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream())), CrmBusinessDO::getId);
|
||||||
result.getList().forEach(item -> {
|
PageResult<CrmFollowUpRecordRespVO> voPageResult = BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class, record -> {
|
||||||
setContactNames(item, contactMap);
|
record.setContactNames(new ArrayList<>()).setBusinessNames(new ArrayList<>());
|
||||||
setBusinessNames(item, businessMap);
|
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);
|
return success(voPageResult);
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -52,8 +52,9 @@ public class CrmFollowUpRecordDO extends BaseDO {
|
|||||||
private Long bizId;
|
private Long bizId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 跟进类型,关联字典{@link DictTypeConstants#CRM_FOLLOW_UP_TYPE}
|
* 跟进类型
|
||||||
*
|
*
|
||||||
|
* 关联 {@link DictTypeConstants#CRM_FOLLOW_UP_TYPE} 字典
|
||||||
*/
|
*/
|
||||||
private Integer type;
|
private Integer type;
|
||||||
/**
|
/**
|
||||||
|
@ -27,10 +27,10 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createFollowUpRecord(CrmFollowUpRecordSaveReqVO createReqVO) {
|
public Long createFollowUpRecord(CrmFollowUpRecordSaveReqVO createReqVO) {
|
||||||
// 插入
|
|
||||||
CrmFollowUpRecordDO followUpRecord = BeanUtils.toBean(createReqVO, CrmFollowUpRecordDO.class);
|
CrmFollowUpRecordDO followUpRecord = BeanUtils.toBean(createReqVO, CrmFollowUpRecordDO.class);
|
||||||
crmFollowUpRecordMapper.insert(followUpRecord);
|
crmFollowUpRecordMapper.insert(followUpRecord);
|
||||||
// 返回
|
// TODO @puhui999:需要更新 bizId 对应的记录;
|
||||||
|
// TODO @puhui999:需要更新 businessIds、contactIds 对应的记录;
|
||||||
return followUpRecord.getId();
|
return followUpRecord.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user