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