Commit cff6e520ee99c519e497423fc5b75fb9f5bc4321
1 parent
f8f5e525
📖 CRM:【联系人】code review 联系人的代码,补全对应的 todo list
Showing
3 changed files
with
21 additions
and
11 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java
| ... | ... | @@ -6,6 +6,7 @@ import cn.hutool.core.util.NumberUtil; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | 8 | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; |
| 9 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 9 | 10 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 10 | 11 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 11 | 12 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; |
| ... | ... | @@ -61,6 +62,7 @@ public class CrmContactController { |
| 61 | 62 | @Resource |
| 62 | 63 | private CrmContactBusinessService contactBusinessLinkService; |
| 63 | 64 | |
| 65 | + // TODO @zyna:CrmContactCreateReqVO、CrmContactUpdateReqVO、CrmContactRespVO 按照新的 VO 规范搞哈;可以参考 dept 模块 | |
| 64 | 66 | @PostMapping("/create") |
| 65 | 67 | @Operation(summary = "创建联系人") |
| 66 | 68 | @PreAuthorize("@ss.hasPermission('crm:contact:create')") |
| ... | ... | @@ -110,10 +112,11 @@ public class CrmContactController { |
| 110 | 112 | @Operation(summary = "获得联系人列表") |
| 111 | 113 | @PreAuthorize("@ss.hasPermission('crm:contact:query')") |
| 112 | 114 | public CommonResult<List<CrmContactSimpleRespVO>> getSimpleContactList() { |
| 115 | + // TODO @zyna:建议 contactService 单独搞个 list 接口哈 | |
| 113 | 116 | CrmContactPageReqVO pageReqVO = new CrmContactPageReqVO(); |
| 114 | 117 | pageReqVO.setPageSize(PAGE_SIZE_NONE); |
| 115 | 118 | List<CrmContactDO> list = contactService.getContactPage(pageReqVO, getLoginUserId()).getList(); |
| 116 | - return success(CrmContactConvert.INSTANCE.convertAllList(list)); | |
| 119 | + return success(BeanUtils.toBean(list, CrmContactSimpleRespVO.class)); | |
| 117 | 120 | } |
| 118 | 121 | |
| 119 | 122 | @GetMapping("/page") | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/CrmContactConvert.java
| ... | ... | @@ -39,8 +39,6 @@ public interface CrmContactConvert { |
| 39 | 39 | |
| 40 | 40 | PageResult<CrmContactRespVO> convertPage(PageResult<CrmContactDO> page); |
| 41 | 41 | |
| 42 | - List<CrmContactSimpleRespVO> convertAllList(List<CrmContactDO> list); | |
| 43 | - | |
| 44 | 42 | @Mapping(target = "bizId", source = "reqVO.id") |
| 45 | 43 | CrmPermissionTransferReqBO convert(CrmContactTransferReqVO reqVO, Long userId); |
| 46 | 44 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
| ... | ... | @@ -7,7 +7,6 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; |
| 7 | 7 | import cn.iocoder.yudao.module.crm.convert.contact.CrmContactConvert; |
| 8 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 9 | 9 | import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper; |
| 10 | -import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessMapper; | |
| 11 | 10 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 12 | 11 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 13 | 12 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; |
| ... | ... | @@ -47,32 +46,35 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 47 | 46 | @Resource |
| 48 | 47 | private AdminUserApi adminUserApi; |
| 49 | 48 | |
| 50 | - @Resource | |
| 51 | - private CrmContactBusinessMapper contactBusinessLinkMapper; | |
| 52 | - | |
| 53 | 49 | @Override |
| 54 | 50 | @Transactional(rollbackFor = Exception.class) |
| 51 | + // TODO @zyna:增加操作日志,可以参考 CustomerService;内容是 新建了联系人【名字】 | |
| 55 | 52 | public Long createContact(CrmContactCreateReqVO createReqVO, Long userId) { |
| 56 | - // 1.1 校验 | |
| 53 | + // 1. 校验 | |
| 57 | 54 | validateRelationDataExists(createReqVO); |
| 58 | - // 1.2 插入 | |
| 55 | + | |
| 56 | + // 2. 插入联系人 | |
| 59 | 57 | CrmContactDO contact = CrmContactConvert.INSTANCE.convert(createReqVO); |
| 60 | 58 | contactMapper.insert(contact); |
| 61 | 59 | |
| 62 | - // 2. 创建数据权限 | |
| 60 | + // 3. 创建数据权限 | |
| 63 | 61 | crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(userId) |
| 64 | 62 | .setBizType(CrmBizTypeEnum.CRM_CONTACT.getType()).setBizId(contact.getId()) |
| 65 | 63 | .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); |
| 64 | + | |
| 65 | + // TODO @zyna:特殊逻辑:如果在【商机】详情那,点击【新增联系人】时,可以自动绑定商机 | |
| 66 | 66 | return contact.getId(); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | @Override |
| 70 | 70 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) |
| 71 | + // TODO @zyna:增加操作日志,可以参考 CustomerService;需要 diff 出字段 | |
| 71 | 72 | public void updateContact(CrmContactUpdateReqVO updateReqVO) { |
| 72 | 73 | // 1. 校验存在 |
| 73 | 74 | validateContactExists(updateReqVO.getId()); |
| 74 | 75 | validateRelationDataExists(updateReqVO); |
| 75 | - // 2. 更新 | |
| 76 | + | |
| 77 | + // 2. 更新联系人 | |
| 76 | 78 | CrmContactDO updateObj = CrmContactConvert.INSTANCE.convert(updateReqVO); |
| 77 | 79 | contactMapper.updateById(updateObj); |
| 78 | 80 | } |
| ... | ... | @@ -102,10 +104,15 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 102 | 104 | public void deleteContact(Long id) { |
| 103 | 105 | // 校验存在 |
| 104 | 106 | validateContactExists(id); |
| 107 | + // TODO @zyna:如果有关联的合同,不允许删除;Contract.contactId | |
| 108 | + | |
| 105 | 109 | // 删除 |
| 106 | 110 | contactMapper.deleteById(id); |
| 107 | 111 | // 删除数据权限 |
| 108 | 112 | crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CONTACT.getType(), id); |
| 113 | + // TODO @zyna:删除商机联系人关联 | |
| 114 | + | |
| 115 | + // TODO @puhui999:删除跟进记录 | |
| 109 | 116 | } |
| 110 | 117 | |
| 111 | 118 | private void validateContactExists(Long id) { |
| ... | ... | @@ -140,6 +147,8 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 140 | 147 | } |
| 141 | 148 | |
| 142 | 149 | @Override |
| 150 | + // TODO @puhui999:权限校验 | |
| 151 | + // TODO @puhui999:记录操作日志;将联系人【名字】转移给【新负责人】 | |
| 143 | 152 | public void transferContact(CrmContactTransferReqVO reqVO, Long userId) { |
| 144 | 153 | // 1 校验联系人是否存在 |
| 145 | 154 | validateContactExists(reqVO.getId()); | ... | ... |