mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
📖 CRM:code review 跟进日志
This commit is contained in:
parent
ff7e492887
commit
d732008ef8
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.crm.controller.admin.operatelog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.operatelog.vo.CrmOperateLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.enums.LogRecordConstants;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
|
||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2PageReqDTO;
|
||||
@ -25,7 +26,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
|
||||
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*;
|
||||
|
||||
@Tag(name = "管理后台 - 操作日志")
|
||||
@Tag(name = "管理后台 - CRM 操作日志")
|
||||
@RestController
|
||||
@RequestMapping("/crm/operate-log")
|
||||
@Validated
|
||||
@ -34,6 +35,9 @@ public class CrmOperateLogController {
|
||||
@Resource
|
||||
private OperateLogApi operateLogApi;
|
||||
|
||||
/**
|
||||
* {@link CrmBizTypeEnum} 与 {@link LogRecordConstants} 的映射关系
|
||||
*/
|
||||
private static final Map<Integer, String> BIZ_TYPE_MAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
@ -47,6 +51,7 @@ public class CrmOperateLogController {
|
||||
BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), CRM_RECEIVABLE_PLAN_TYPE);
|
||||
}
|
||||
|
||||
// TODO @puhui999:还是搞个 VO 出来哈
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得操作日志")
|
||||
@Parameter(name = "id", description = "客户编号", required = true)
|
||||
@ -54,8 +59,7 @@ public class CrmOperateLogController {
|
||||
public CommonResult<PageResult<OperateLogV2RespDTO>> getCustomerOperateLog(@Valid CrmOperateLogPageReqVO pageReqVO) {
|
||||
OperateLogV2PageReqDTO reqDTO = new OperateLogV2PageReqDTO();
|
||||
reqDTO.setPageSize(PAGE_SIZE_NONE); // 默认不分页,需要分页需注释
|
||||
reqDTO.setBizType(BIZ_TYPE_MAP.get(pageReqVO.getBizType()));
|
||||
reqDTO.setBizId(pageReqVO.getBizId());
|
||||
reqDTO.setBizType(BIZ_TYPE_MAP.get(pageReqVO.getBizType())).setBizId(pageReqVO.getBizId());
|
||||
return success(operateLogApi.getOperateLogPage(reqDTO));
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 跟进记录分页 Request VO")
|
||||
@Schema(description = "管理后台 - CRM 操作日志 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
|
@ -29,6 +29,7 @@ public interface CrmPermissionConvert {
|
||||
|
||||
CrmPermissionConvert INSTANCE = Mappers.getMapper(CrmPermissionConvert.class);
|
||||
|
||||
// TODO @puhui999:这个要不也搞到 copy 里
|
||||
List<CrmPermissionRespVO> convert(List<CrmPermissionDO> permission);
|
||||
|
||||
default List<CrmPermissionRespVO> convert(List<CrmPermissionDO> permission, List<AdminUserRespDTO> userList,
|
||||
|
@ -26,12 +26,14 @@ public interface CrmFollowUpRecordMapper extends BaseMapperX<CrmFollowUpRecordDO
|
||||
}
|
||||
|
||||
default void deleteByBiz(Integer bizType, Long bizId) {
|
||||
delete(new LambdaQueryWrapperX<CrmFollowUpRecordDO>().eq(CrmFollowUpRecordDO::getBizType, bizType)
|
||||
delete(new LambdaQueryWrapperX<CrmFollowUpRecordDO>()
|
||||
.eq(CrmFollowUpRecordDO::getBizType, bizType)
|
||||
.eq(CrmFollowUpRecordDO::getBizId, bizId));
|
||||
}
|
||||
|
||||
default List<CrmFollowUpRecordDO> selectListByBiz(Integer bizType, Collection<Long> bizIds) {
|
||||
return selectList(new LambdaQueryWrapperX<CrmFollowUpRecordDO>().eq(CrmFollowUpRecordDO::getBizType, bizType)
|
||||
return selectList(new LambdaQueryWrapperX<CrmFollowUpRecordDO>()
|
||||
.eq(CrmFollowUpRecordDO::getBizType, bizType)
|
||||
.in(CrmFollowUpRecordDO::getBizId, bizIds));
|
||||
}
|
||||
|
||||
|
@ -73,17 +73,17 @@ public class CrmClueServiceImpl implements CrmClueService {
|
||||
@LogRecord(type = CRM_LEADS_TYPE, subType = CRM_LEADS_CREATE_SUB_TYPE, bizNo = "{{#clue.id}}",
|
||||
success = CRM_LEADS_CREATE_SUCCESS)
|
||||
public Long createClue(CrmClueSaveReqVO createReqVO, Long userId) {
|
||||
// 1. 校验关联数据
|
||||
// 1.1 校验关联数据
|
||||
validateRelationDataExists(createReqVO);
|
||||
// 1.2 校验负责人是否存在
|
||||
if (createReqVO.getOwnerUserId() != null) {
|
||||
adminUserApi.validateUserList(singletonList(createReqVO.getOwnerUserId()));
|
||||
} else {
|
||||
createReqVO.setOwnerUserId(userId); // 如果没有设置负责人那么默认操作人为负责人
|
||||
}
|
||||
|
||||
// 2. 插入
|
||||
CrmClueDO clue = BeanUtils.toBean(createReqVO, CrmClueDO.class).setId(null);
|
||||
if (ObjUtil.isNull(createReqVO.getOwnerUserId())) {
|
||||
clue.setOwnerUserId(userId); // 如果没有设置负责人那么默认操作人为负责人
|
||||
} else {
|
||||
// 校验负责人是否存在
|
||||
adminUserApi.validateUserList(singletonList(createReqVO.getOwnerUserId()));
|
||||
}
|
||||
clueMapper.insert(clue);
|
||||
|
||||
// 3. 创建数据权限
|
||||
@ -193,10 +193,13 @@ public class CrmClueServiceImpl implements CrmClueService {
|
||||
}
|
||||
|
||||
// 2. 遍历线索(未转化的线索),创建对应的客户
|
||||
// TODO @puhui999:这里不用过滤了;
|
||||
List<CrmClueDO> translateClues = filterList(clues, clue -> ObjUtil.equal(Boolean.FALSE, clue.getTransformStatus()));
|
||||
List<CrmCustomerDO> customers = customerService.createCustomerBatch(convertList(translateClues, clue ->
|
||||
BeanUtils.toBean(clue, CrmCustomerCreateReqBO.class)), userId);
|
||||
|
||||
// TODO @puhui999:这里不用搞一个 clueCustomerIdMap 出来;可以考虑逐个创建,然后把 customerId 设置回 CrmClueDO;避免 name 匹配,极端会有问题哈;
|
||||
// TODO 是不是就直接 foreach 处理好了;因为本身量不大,for 处理性能 ok,可阅读性好
|
||||
Map<Long, Long> clueCustomerIdMap = new HashMap<>(translateClues.size());
|
||||
// 2.1 更新线索
|
||||
clueMapper.updateBatch(convertList(customers, customer -> {
|
||||
@ -209,6 +212,7 @@ public class CrmClueServiceImpl implements CrmClueService {
|
||||
|
||||
// 3. 记录操作日志
|
||||
for (CrmClueDO clue : translateClues) {
|
||||
// TODO @puhui999:这里优化下,translate 操作日志
|
||||
getSelf().receiveClueLog(clue);
|
||||
}
|
||||
}
|
||||
|
@ -120,11 +120,12 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService {
|
||||
// 校验存在
|
||||
CrmFollowUpRecordDO followUpRecord = validateFollowUpRecordExists(id);
|
||||
// 校验权限
|
||||
// TODO @puhui999:是不是封装一个 hasPermission,更简介一点;
|
||||
List<CrmPermissionDO> permissionList = permissionService.getPermissionListByBiz(
|
||||
followUpRecord.getBizType(), followUpRecord.getBizId());
|
||||
boolean condition = anyMatch(permissionList, permission ->
|
||||
boolean hasPermission = anyMatch(permissionList, permission ->
|
||||
ObjUtil.equal(permission.getUserId(), userId) && ObjUtil.equal(permission.getLevel(), CrmPermissionLevelEnum.OWNER.getLevel()));
|
||||
if (!condition) {
|
||||
if (!hasPermission) {
|
||||
throw exception(FOLLOW_UP_RECORD_DELETE_DENIED);
|
||||
}
|
||||
|
||||
@ -134,7 +135,6 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService {
|
||||
|
||||
@Override
|
||||
public void deleteFollowUpRecordByBiz(Integer bizType, Long bizId) {
|
||||
// 删除
|
||||
crmFollowUpRecordMapper.deleteByBiz(bizType, bizId);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user