📖 CRM:【联系人】code review 联系人的代码,补全对应的 todo list

This commit is contained in:
YunaiV 2024-01-03 22:07:20 +08:00
parent f8f5e525be
commit cff6e520ee
3 changed files with 21 additions and 11 deletions

View File

@ -6,6 +6,7 @@ import cn.hutool.core.util.NumberUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils; import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
@ -61,6 +62,7 @@ public class CrmContactController {
@Resource @Resource
private CrmContactBusinessService contactBusinessLinkService; private CrmContactBusinessService contactBusinessLinkService;
// TODO @zynaCrmContactCreateReqVOCrmContactUpdateReqVOCrmContactRespVO 按照新的 VO 规范搞哈可以参考 dept 模块
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建联系人") @Operation(summary = "创建联系人")
@PreAuthorize("@ss.hasPermission('crm:contact:create')") @PreAuthorize("@ss.hasPermission('crm:contact:create')")
@ -110,10 +112,11 @@ public class CrmContactController {
@Operation(summary = "获得联系人列表") @Operation(summary = "获得联系人列表")
@PreAuthorize("@ss.hasPermission('crm:contact:query')") @PreAuthorize("@ss.hasPermission('crm:contact:query')")
public CommonResult<List<CrmContactSimpleRespVO>> getSimpleContactList() { public CommonResult<List<CrmContactSimpleRespVO>> getSimpleContactList() {
// TODO @zyna建议 contactService 单独搞个 list 接口哈
CrmContactPageReqVO pageReqVO = new CrmContactPageReqVO(); CrmContactPageReqVO pageReqVO = new CrmContactPageReqVO();
pageReqVO.setPageSize(PAGE_SIZE_NONE); pageReqVO.setPageSize(PAGE_SIZE_NONE);
List<CrmContactDO> list = contactService.getContactPage(pageReqVO, getLoginUserId()).getList(); List<CrmContactDO> list = contactService.getContactPage(pageReqVO, getLoginUserId()).getList();
return success(CrmContactConvert.INSTANCE.convertAllList(list)); return success(BeanUtils.toBean(list, CrmContactSimpleRespVO.class));
} }
@GetMapping("/page") @GetMapping("/page")

View File

@ -39,8 +39,6 @@ public interface CrmContactConvert {
PageResult<CrmContactRespVO> convertPage(PageResult<CrmContactDO> page); PageResult<CrmContactRespVO> convertPage(PageResult<CrmContactDO> page);
List<CrmContactSimpleRespVO> convertAllList(List<CrmContactDO> list);
@Mapping(target = "bizId", source = "reqVO.id") @Mapping(target = "bizId", source = "reqVO.id")
CrmPermissionTransferReqBO convert(CrmContactTransferReqVO reqVO, Long userId); CrmPermissionTransferReqBO convert(CrmContactTransferReqVO reqVO, Long userId);

View File

@ -7,7 +7,6 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
import cn.iocoder.yudao.module.crm.convert.contact.CrmContactConvert; import cn.iocoder.yudao.module.crm.convert.contact.CrmContactConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper; import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper;
import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessMapper;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
@ -47,32 +46,35 @@ public class CrmContactServiceImpl implements CrmContactService {
@Resource @Resource
private AdminUserApi adminUserApi; private AdminUserApi adminUserApi;
@Resource
private CrmContactBusinessMapper contactBusinessLinkMapper;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
// TODO @zyna增加操作日志可以参考 CustomerService内容是 新建了联系人名字
public Long createContact(CrmContactCreateReqVO createReqVO, Long userId) { public Long createContact(CrmContactCreateReqVO createReqVO, Long userId) {
// 1.1 校验 // 1. 校验
validateRelationDataExists(createReqVO); validateRelationDataExists(createReqVO);
// 1.2 插入
// 2. 插入联系人
CrmContactDO contact = CrmContactConvert.INSTANCE.convert(createReqVO); CrmContactDO contact = CrmContactConvert.INSTANCE.convert(createReqVO);
contactMapper.insert(contact); contactMapper.insert(contact);
// 2. 创建数据权限 // 3. 创建数据权限
crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(userId) crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(userId)
.setBizType(CrmBizTypeEnum.CRM_CONTACT.getType()).setBizId(contact.getId()) .setBizType(CrmBizTypeEnum.CRM_CONTACT.getType()).setBizId(contact.getId())
.setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); .setLevel(CrmPermissionLevelEnum.OWNER.getLevel()));
// TODO @zyna特殊逻辑如果在商机详情那点击新增联系人可以自动绑定商机
return contact.getId(); return contact.getId();
} }
@Override @Override
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
// TODO @zyna增加操作日志可以参考 CustomerService需要 diff 出字段
public void updateContact(CrmContactUpdateReqVO updateReqVO) { public void updateContact(CrmContactUpdateReqVO updateReqVO) {
// 1. 校验存在 // 1. 校验存在
validateContactExists(updateReqVO.getId()); validateContactExists(updateReqVO.getId());
validateRelationDataExists(updateReqVO); validateRelationDataExists(updateReqVO);
// 2. 更新
// 2. 更新联系人
CrmContactDO updateObj = CrmContactConvert.INSTANCE.convert(updateReqVO); CrmContactDO updateObj = CrmContactConvert.INSTANCE.convert(updateReqVO);
contactMapper.updateById(updateObj); contactMapper.updateById(updateObj);
} }
@ -102,10 +104,15 @@ public class CrmContactServiceImpl implements CrmContactService {
public void deleteContact(Long id) { public void deleteContact(Long id) {
// 校验存在 // 校验存在
validateContactExists(id); validateContactExists(id);
// TODO @zyna如果有关联的合同不允许删除Contract.contactId
// 删除 // 删除
contactMapper.deleteById(id); contactMapper.deleteById(id);
// 删除数据权限 // 删除数据权限
crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CONTACT.getType(), id); crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CONTACT.getType(), id);
// TODO @zyna删除商机联系人关联
// TODO @puhui999删除跟进记录
} }
private void validateContactExists(Long id) { private void validateContactExists(Long id) {
@ -140,6 +147,8 @@ public class CrmContactServiceImpl implements CrmContactService {
} }
@Override @Override
// TODO @puhui999权限校验
// TODO @puhui999记录操作日志将联系人名字转移给新负责人
public void transferContact(CrmContactTransferReqVO reqVO, Long userId) { public void transferContact(CrmContactTransferReqVO reqVO, Long userId) {
// 1 校验联系人是否存在 // 1 校验联系人是否存在
validateContactExists(reqVO.getId()); validateContactExists(reqVO.getId());