mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
📖 CRM:【联系人】code review 联系人的代码,补全对应的 todo list
This commit is contained in:
parent
f8f5e525be
commit
cff6e520ee
@ -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 @zyna:CrmContactCreateReqVO、CrmContactUpdateReqVO、CrmContactRespVO 按照新的 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")
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -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());
|
||||||
|
Loading…
Reference in New Issue
Block a user