mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 09:11:52 +08:00
CRM-客户: 新增关注和取消关注客户接口
This commit is contained in:
parent
9c1687dc25
commit
b2621c8891
@ -36,7 +36,6 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
@Tag(name = "管理后台 - CRM 客户")
|
||||
@RestController
|
||||
@ -140,6 +139,24 @@ public class CrmCustomerController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/concern")
|
||||
@Operation(summary = "关注客户")
|
||||
@Parameter(name = "ids", description = "编号", required = true, example = "[1024]")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
||||
public CommonResult<Boolean> concernCustomer(@RequestParam("ids") List<Long> ids) {
|
||||
customerService.concernCustomer(ids, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/cancel-concern")
|
||||
@Operation(summary = "取消关注客户")
|
||||
@Parameter(name = "ids", description = "编号", required = true, example = "[1024]")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
||||
public CommonResult<Boolean> cancelConcernCustomer(@RequestParam("ids") List<Long> ids) {
|
||||
customerService.cancelConcernCustomer(ids, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// ==================== 公海相关操作 ====================
|
||||
|
||||
@PutMapping("/put-pool")
|
||||
@ -178,7 +195,7 @@ public class CrmCustomerController {
|
||||
@GetMapping("/query-all-list")
|
||||
@Operation(summary = "查询客户列表")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:all')")
|
||||
public CommonResult<List<CrmCustomerQueryAllRespVO>> queryAll(){
|
||||
public CommonResult<List<CrmCustomerQueryAllRespVO>> queryAll() {
|
||||
List<CrmCustomerDO> crmCustomerDOList = customerService.getCustomerList();
|
||||
List<CrmCustomerQueryAllRespVO> data = CrmCustomerConvert.INSTANCE.convertQueryAll(crmCustomerDOList);
|
||||
return success(data);
|
||||
|
@ -90,6 +90,22 @@ public interface CrmCustomerService {
|
||||
*/
|
||||
void lockCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 关注客户
|
||||
*
|
||||
* @param ids 客户编号
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void concernCustomer(List<Long> ids, Long userId);
|
||||
|
||||
/**
|
||||
* 取消关注客户
|
||||
*
|
||||
* @param ids 客户编号
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void cancelConcernCustomer(List<Long> ids, Long userId);
|
||||
|
||||
// ==================== 公海相关操作 ====================
|
||||
|
||||
/**
|
||||
@ -109,8 +125,10 @@ public interface CrmCustomerService {
|
||||
|
||||
/**
|
||||
* 获取客户列表
|
||||
*
|
||||
* @return 客户列表
|
||||
* @author zyna
|
||||
*/
|
||||
List<CrmCustomerDO> getCustomerList();
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package cn.iocoder.yudao.module.crm.service.customer;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO;
|
||||
@ -9,9 +11,11 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdat
|
||||
import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper;
|
||||
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.service.concerned.CrmConcernedService;
|
||||
import cn.iocoder.yudao.module.crm.service.concerned.bo.CrmConcernedCreateReqBO;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
@ -23,6 +27,7 @@ import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
@ -41,6 +46,9 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
@Resource
|
||||
private CrmPermissionService crmPermissionService;
|
||||
|
||||
@Resource
|
||||
private CrmConcernedService crmConcernedService;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@ -151,6 +159,33 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
customerMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void concernCustomer(List<Long> ids, Long userId) {
|
||||
// 1. 校验客户是否存在
|
||||
validateCustomerExists(ids);
|
||||
|
||||
// 2. 创建关注
|
||||
List<CrmConcernedCreateReqBO> createReqBOs = BeanUtils.toBean(convertList(ids, id -> new CrmConcernedCreateReqBO()
|
||||
.setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()).setBizId(id).setUserId(userId)), CrmConcernedCreateReqBO.class);
|
||||
crmConcernedService.createConcernedBatch(createReqBOs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelConcernCustomer(List<Long> ids, Long userId) {
|
||||
// 1. 校验客户是否存在
|
||||
validateCustomerExists(ids);
|
||||
|
||||
// 2. 取消关注
|
||||
crmConcernedService.deleteConcerned(CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, userId);
|
||||
}
|
||||
|
||||
private void validateCustomerExists(List<Long> ids) {
|
||||
List<CrmCustomerDO> customerList = customerMapper.selectBatchIds(ids);
|
||||
if (ObjUtil.notEqual(ids.size(), customerList.size())) {
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
||||
|
@ -108,16 +108,12 @@ public class CrmCrmReceivableServiceImplTest extends BaseDbUnitTest {
|
||||
o.setPlanId(null);
|
||||
o.setCustomerId(null);
|
||||
o.setContractId(null);
|
||||
o.setCheckStatus(null);
|
||||
o.setProcessInstanceId(null);
|
||||
o.setReturnTime(null);
|
||||
o.setReturnType(null);
|
||||
o.setPrice(null);
|
||||
o.setOwnerUserId(null);
|
||||
o.setBatchId(null);
|
||||
o.setSort(null);
|
||||
o.setDataScope(null);
|
||||
o.setDataScopeDeptIds(null);
|
||||
o.setAuditStatus(null);
|
||||
o.setRemark(null);
|
||||
o.setCreateTime(null);
|
||||
|
Loading…
Reference in New Issue
Block a user