mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
CRM-合同:完善数据权限,新增权限关联、场景分页查询,新增权限关联批量查询
This commit is contained in:
parent
f69a18fd23
commit
7c54affb16
@ -9,7 +9,6 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
|||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
|
||||||
@ -121,9 +120,9 @@ public class CrmBusinessController {
|
|||||||
|
|
||||||
@GetMapping("/page-by-customer")
|
@GetMapping("/page-by-customer")
|
||||||
@Operation(summary = "获得商机分页,基于指定客户")
|
@Operation(summary = "获得商机分页,基于指定客户")
|
||||||
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmContractPageReqVO pageReqVO) {
|
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmBusinessPageReqVO pageReqVO) {
|
||||||
Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空");
|
Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空");
|
||||||
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomer(pageReqVO);
|
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomer(pageReqVO, getLoginUserId());
|
||||||
// 处理客户名称回显
|
// 处理客户名称回显
|
||||||
// TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
|
// TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
|
||||||
Set<Long> customerIds = pageResult.getList().stream()
|
Set<Long> customerIds = pageResult.getList().stream()
|
||||||
|
@ -125,7 +125,7 @@ public class CrmContactController {
|
|||||||
@Operation(summary = "获得联系人分页,基于指定客户")
|
@Operation(summary = "获得联系人分页,基于指定客户")
|
||||||
public CommonResult<PageResult<CrmContactRespVO>> getContactPageByCustomer(@Valid CrmContactPageReqVO pageVO) {
|
public CommonResult<PageResult<CrmContactRespVO>> getContactPageByCustomer(@Valid CrmContactPageReqVO pageVO) {
|
||||||
Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空");
|
Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空");
|
||||||
PageResult<CrmContactDO> pageResult = contactService.getContactPage(pageVO, getLoginUserId());
|
PageResult<CrmContactDO> pageResult = contactService.getContactPageByCustomerId(pageVO, getLoginUserId());
|
||||||
return success(convertDetailContactPage(pageResult));
|
return success(convertDetailContactPage(pageResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class CrmContractController {
|
|||||||
@Operation(summary = "获得合同分页")
|
@Operation(summary = "获得合同分页")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:contract:query')")
|
@PreAuthorize("@ss.hasPermission('crm:contract:query')")
|
||||||
public CommonResult<PageResult<ContractRespVO>> getContractPage(@Valid CrmContractPageReqVO pageVO) {
|
public CommonResult<PageResult<ContractRespVO>> getContractPage(@Valid CrmContractPageReqVO pageVO) {
|
||||||
PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO);
|
PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO, getLoginUserId());
|
||||||
return success(convertDetailContractPage(pageResult));
|
return success(convertDetailContractPage(pageResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ public class CrmContractController {
|
|||||||
@Operation(summary = "获得联系人分页,基于指定客户")
|
@Operation(summary = "获得联系人分页,基于指定客户")
|
||||||
public CommonResult<PageResult<ContractRespVO>> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) {
|
public CommonResult<PageResult<ContractRespVO>> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) {
|
||||||
Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空");
|
Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空");
|
||||||
PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomer(pageVO);
|
PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomer(pageVO, getLoginUserId());
|
||||||
return success(convertDetailContractPage(pageResult));
|
return success(convertDetailContractPage(pageResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ public class CrmContractController {
|
|||||||
@OperateLog(type = EXPORT)
|
@OperateLog(type = EXPORT)
|
||||||
public void exportContractExcel(@Valid CrmContractPageReqVO exportReqVO,
|
public void exportContractExcel(@Valid CrmContractPageReqVO exportReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
PageResult<CrmContractDO> pageResult = contractService.getContractPage(exportReqVO);
|
PageResult<CrmContractDO> pageResult = contractService.getContractPage(exportReqVO, getLoginUserId());
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
ExcelUtils.write(response, "合同.xls", "数据", CrmContractExcelVO.class,
|
ExcelUtils.write(response, "合同.xls", "数据", CrmContractExcelVO.class,
|
||||||
ContractConvert.INSTANCE.convertList02(pageResult.getList()));
|
ContractConvert.INSTANCE.convertList02(pageResult.getList()));
|
||||||
|
@ -33,7 +33,7 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> {
|
|||||||
CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_BUSINESS.getType(), CrmBusinessDO::getId,
|
CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_BUSINESS.getType(), CrmBusinessDO::getId,
|
||||||
userId, pageReqVO.getSceneType(), pageReqVO.getPool());
|
userId, pageReqVO.getSceneType(), pageReqVO.getPool());
|
||||||
mpjLambdaWrapperX.selectAll(CrmBusinessDO.class)
|
mpjLambdaWrapperX.selectAll(CrmBusinessDO.class)
|
||||||
.eq(CrmBusinessDO::getCustomerId, pageReqVO.getCustomerId()) // 必须传递
|
.eqIfPresent(CrmBusinessDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号
|
||||||
.likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName())
|
.likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName())
|
||||||
.orderByDesc(CrmBusinessDO::getId);
|
.orderByDesc(CrmBusinessDO::getId);
|
||||||
return selectJoinPage(pageReqVO, CrmBusinessDO.class, mpjLambdaWrapperX);
|
return selectJoinPage(pageReqVO, CrmBusinessDO.class, mpjLambdaWrapperX);
|
||||||
|
@ -33,7 +33,7 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> {
|
|||||||
CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), CrmContactDO::getId,
|
CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), CrmContactDO::getId,
|
||||||
userId, pageReqVO.getSceneType(), pageReqVO.getPool());
|
userId, pageReqVO.getSceneType(), pageReqVO.getPool());
|
||||||
mpjLambdaWrapperX.selectAll(CrmContactDO.class)
|
mpjLambdaWrapperX.selectAll(CrmContactDO.class)
|
||||||
.eq(CrmContactDO::getCustomerId, pageReqVO.getCustomerId()) // 必须传递
|
.eqIfPresent(CrmContactDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号
|
||||||
.likeIfPresent(CrmContactDO::getName, pageReqVO.getName())
|
.likeIfPresent(CrmContactDO::getName, pageReqVO.getName())
|
||||||
.eqIfPresent(CrmContactDO::getMobile, pageReqVO.getMobile())
|
.eqIfPresent(CrmContactDO::getMobile, pageReqVO.getMobile())
|
||||||
.eqIfPresent(CrmContactDO::getTelephone, pageReqVO.getTelephone())
|
.eqIfPresent(CrmContactDO::getTelephone, pageReqVO.getTelephone())
|
||||||
|
@ -2,11 +2,17 @@ package cn.iocoder.yudao.module.crm.dal.mysql.contract;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CRM 合同 Mapper
|
* CRM 合同 Mapper
|
||||||
*
|
*
|
||||||
@ -15,22 +21,32 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
|
public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
|
||||||
|
|
||||||
default PageResult<CrmContractDO> selectPage(CrmContractPageReqVO reqVO) {
|
default int updateOwnerUserIdById(Long id, Long ownerUserId) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmContractDO>()
|
return update(new LambdaUpdateWrapper<CrmContractDO>()
|
||||||
.likeIfPresent(CrmContractDO::getNo, reqVO.getNo())
|
.eq(CrmContractDO::getId, id)
|
||||||
.likeIfPresent(CrmContractDO::getName, reqVO.getName())
|
.set(CrmContractDO::getOwnerUserId, ownerUserId));
|
||||||
.eqIfPresent(CrmContractDO::getCustomerId, reqVO.getCustomerId())
|
|
||||||
.eqIfPresent(CrmContractDO::getBusinessId, reqVO.getBusinessId())
|
|
||||||
.orderByDesc(CrmContractDO::getId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default PageResult<CrmContractDO> selectPageByCustomer(CrmContractPageReqVO reqVO) {
|
default PageResult<CrmContractDO> selectPage(CrmContractPageReqVO pageReqVO, Long userId) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmContractDO>()
|
MPJLambdaWrapperX<CrmContractDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>();
|
||||||
.eq(CrmContractDO::getCustomerId, reqVO.getCustomerId()) // 必须传递
|
// 构建数据权限连表条件
|
||||||
.likeIfPresent(CrmContractDO::getNo, reqVO.getNo())
|
CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), CrmContractDO::getId,
|
||||||
.likeIfPresent(CrmContractDO::getName, reqVO.getName())
|
userId, pageReqVO.getSceneType(), pageReqVO.getPool());
|
||||||
.eqIfPresent(CrmContractDO::getBusinessId, reqVO.getBusinessId())
|
mpjLambdaWrapperX.selectAll(CrmContractDO.class)
|
||||||
.orderByDesc(CrmContractDO::getId));
|
.eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId())
|
||||||
|
.likeIfPresent(CrmContractDO::getNo, pageReqVO.getNo())
|
||||||
|
.likeIfPresent(CrmContractDO::getName, pageReqVO.getName())
|
||||||
|
.eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId())
|
||||||
|
.eqIfPresent(CrmContractDO::getBusinessId, pageReqVO.getBusinessId())
|
||||||
|
.orderByDesc(CrmContractDO::getId);
|
||||||
|
return selectJoinPage(pageReqVO, CrmContractDO.class, mpjLambdaWrapperX);
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<CrmContractDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
||||||
|
MPJLambdaWrapperX<CrmContractDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>();
|
||||||
|
// 构建数据权限连表条件
|
||||||
|
CrmQueryWrapperUtils.builderListQueryBatch(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, userId);
|
||||||
|
return selectJoinList(CrmContractDO.class, mpjLambdaWrapperX);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusi
|
|||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@ -76,9 +75,10 @@ public interface CrmBusinessService {
|
|||||||
* 数据权限:基于 {@link CrmCustomerDO} 读取
|
* 数据权限:基于 {@link CrmCustomerDO} 读取
|
||||||
*
|
*
|
||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
|
* @param userId 用户编号
|
||||||
* @return 联系人分页
|
* @return 联系人分页
|
||||||
*/
|
*/
|
||||||
PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmContractPageReqVO pageReqVO);
|
PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmBusinessPageReqVO pageReqVO, Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商机转移
|
* 商机转移
|
||||||
|
@ -7,13 +7,13 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusi
|
|||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper;
|
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper;
|
||||||
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.core.annotations.CrmPermission;
|
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
|
||||||
|
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@ -38,6 +38,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CrmBusinessMapper businessMapper;
|
private CrmBusinessMapper businessMapper;
|
||||||
|
@Resource
|
||||||
|
private CrmCustomerService customerService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CrmPermissionService crmPermissionService;
|
private CrmPermissionService crmPermissionService;
|
||||||
@ -109,10 +111,11 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ)
|
public PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmBusinessPageReqVO pageReqVO, Long userId) {
|
||||||
public PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmContractPageReqVO pageReqVO) {
|
// 校验客户存在
|
||||||
//return businessMapper.selectPageByCustomer(pageReqVO);
|
customerService.validateCustomer(pageReqVO.getCustomerId());
|
||||||
return null; // TODO puhui999: 可以跟分页合并吗?
|
|
||||||
|
return businessMapper.selectPage(pageReqVO, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -68,4 +68,15 @@ public interface CrmContactService {
|
|||||||
*/
|
*/
|
||||||
PageResult<CrmContactDO> getContactPage(CrmContactPageReqVO pageReqVO, Long userId);
|
PageResult<CrmContactDO> getContactPage(CrmContactPageReqVO pageReqVO, Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得联系人分页
|
||||||
|
*
|
||||||
|
* 数据权限:基于 {@link CrmContactDO}
|
||||||
|
*
|
||||||
|
* @param pageVO 分页查询
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @return 联系人分页
|
||||||
|
*/
|
||||||
|
PageResult<CrmContactDO> getContactPageByCustomerId(CrmContactPageReqVO pageVO, Long userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -133,4 +133,12 @@ public class CrmContactServiceImpl implements CrmContactService {
|
|||||||
return contactMapper.selectPage(pageReqVO, userId);
|
return contactMapper.selectPage(pageReqVO, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<CrmContactDO> getContactPageByCustomerId(CrmContactPageReqVO pageVO, Long userId) {
|
||||||
|
// 校验用户存在
|
||||||
|
customerService.validateCustomer(pageVO.getCustomerId());
|
||||||
|
|
||||||
|
return contactMapper.selectPage(pageVO, userId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.crm.service.contract;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -64,9 +64,10 @@ public interface CrmContractService {
|
|||||||
* 数据权限:基于 {@link CrmContractDO} 读取
|
* 数据权限:基于 {@link CrmContractDO} 读取
|
||||||
*
|
*
|
||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
|
* @param userId 用户编号
|
||||||
* @return 合同分页
|
* @return 合同分页
|
||||||
*/
|
*/
|
||||||
PageResult<CrmContractDO> getContractPage(CrmContractPageReqVO pageReqVO);
|
PageResult<CrmContractDO> getContractPage(CrmContractPageReqVO pageReqVO, Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得合同分页,基于指定客户
|
* 获得合同分页,基于指定客户
|
||||||
@ -74,9 +75,12 @@ public interface CrmContractService {
|
|||||||
* 数据权限:基于 {@link CrmCustomerDO} 读取
|
* 数据权限:基于 {@link CrmCustomerDO} 读取
|
||||||
*
|
*
|
||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
|
* @param userId 用户编号
|
||||||
* @return 联系人分页
|
* @return 联系人分页
|
||||||
*/
|
*/
|
||||||
PageResult<CrmContractDO> getContractPageByCustomer(CrmContractPageReqVO pageReqVO);
|
default PageResult<CrmContractDO> getContractPageByCustomer(CrmContractPageReqVO pageReqVO, Long userId) {
|
||||||
|
return getContractPage(pageReqVO, userId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 合同转移
|
* 合同转移
|
||||||
|
@ -5,8 +5,8 @@ import cn.hutool.core.collection.ListUtil;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert;
|
import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;
|
import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;
|
||||||
@ -15,11 +15,11 @@ 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.framework.core.annotations.CrmPermission;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ public class CrmContractServiceImpl implements CrmContractService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, level = CrmPermissionLevelEnum.WRITE)
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
|
||||||
public void updateContract(CrmContractUpdateReqVO updateReqVO) {
|
public void updateContract(CrmContractUpdateReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateContractExists(updateReqVO.getId());
|
validateContractExists(updateReqVO.getId());
|
||||||
@ -67,12 +67,14 @@ public class CrmContractServiceImpl implements CrmContractService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE)
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
||||||
public void deleteContract(Long id) {
|
public void deleteContract(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateContractExists(id);
|
validateContractExists(id);
|
||||||
// 删除
|
// 删除
|
||||||
contractMapper.deleteById(id);
|
contractMapper.deleteById(id);
|
||||||
|
// 删除数据权限
|
||||||
|
crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CONTRACT.getType(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CrmContractDO validateContractExists(Long id) {
|
private CrmContractDO validateContractExists(Long id) {
|
||||||
@ -83,7 +85,6 @@ public class CrmContractServiceImpl implements CrmContractService {
|
|||||||
return contract;
|
return contract;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 芋艿:是否要做数据权限的校验???
|
|
||||||
@Override
|
@Override
|
||||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.READ)
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.READ)
|
||||||
public CrmContractDO getContract(Long id) {
|
public CrmContractDO getContract(Long id) {
|
||||||
@ -99,27 +100,24 @@ public class CrmContractServiceImpl implements CrmContractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<CrmContractDO> getContractPage(CrmContractPageReqVO pageReqVO) {
|
public PageResult<CrmContractDO> getContractPage(CrmContractPageReqVO pageReqVO, Long userId) {
|
||||||
return contractMapper.selectPage(pageReqVO);
|
return contractMapper.selectPage(pageReqVO, userId);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ)
|
|
||||||
public PageResult<CrmContractDO> getContractPageByCustomer(CrmContractPageReqVO pageReqVO) {
|
|
||||||
return contractMapper.selectPageByCustomer(pageReqVO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void transferContract(CrmContractTransferReqVO reqVO, Long userId) {
|
public void transferContract(CrmContractTransferReqVO reqVO, Long userId) {
|
||||||
// 1 校验合同是否存在
|
// 1. 校验合同是否存在
|
||||||
validateContractExists(reqVO.getId());
|
validateContractExists(reqVO.getId());
|
||||||
|
|
||||||
// 2. 数据权限转移
|
// 2.1 数据权限转移
|
||||||
crmPermissionService.transferPermission(
|
crmPermissionService.transferPermission(
|
||||||
ContractConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_CONTRACT.getType()));
|
ContractConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_CONTRACT.getType()));
|
||||||
|
// 2.2 设置负责人
|
||||||
|
contractMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId());
|
||||||
|
|
||||||
// 3. TODO 记录转移日志
|
// 3. TODO 记录转移日志
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,9 +71,8 @@ public interface CrmCustomerService {
|
|||||||
* 校验客户是否存在
|
* 校验客户是否存在
|
||||||
*
|
*
|
||||||
* @param customerId 客户 id
|
* @param customerId 客户 id
|
||||||
* @return 客户
|
|
||||||
*/
|
*/
|
||||||
CrmCustomerDO validateCustomer(Long customerId);
|
void validateCustomer(Long customerId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户转移
|
* 客户转移
|
||||||
|
@ -111,15 +111,18 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
|||||||
* 校验客户是否存在
|
* 校验客户是否存在
|
||||||
*
|
*
|
||||||
* @param customerId 客户 id
|
* @param customerId 客户 id
|
||||||
* @return 客户
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CrmCustomerDO validateCustomer(Long customerId) {
|
public void validateCustomer(Long customerId) {
|
||||||
CrmCustomerDO customer = getCustomer(customerId);
|
// TODO puhui999: 不返回客户不走校验应该可行
|
||||||
|
// 校验客户是否存在
|
||||||
|
if (customerId == null) {
|
||||||
|
throw exception(CUSTOMER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
CrmCustomerDO customer = customerMapper.selectById(customerId);
|
||||||
if (Objects.isNull(customer)) {
|
if (Objects.isNull(customer)) {
|
||||||
throw exception(CUSTOMER_NOT_EXISTS);
|
throw exception(CUSTOMER_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
return customer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -147,7 +147,7 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest {
|
|||||||
reqVO.setMobile(null);
|
reqVO.setMobile(null);
|
||||||
|
|
||||||
// 调用
|
// 调用
|
||||||
PageResult<CrmClueDO> pageResult = clueService.getCluePage(reqVO, getLoginUserId());
|
PageResult<CrmClueDO> pageResult = clueService.getCluePage(reqVO, 1L);
|
||||||
// 断言
|
// 断言
|
||||||
assertEquals(1, pageResult.getTotal());
|
assertEquals(1, pageResult.getTotal());
|
||||||
assertEquals(1, pageResult.getList().size());
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
@ -7,12 +7,11 @@ import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageR
|
|||||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;
|
import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||||
@ -127,7 +126,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest {
|
|||||||
reqVO.setNo(null);
|
reqVO.setNo(null);
|
||||||
|
|
||||||
// 调用
|
// 调用
|
||||||
PageResult<CrmContractDO> pageResult = contractService.getContractPage(reqVO);
|
PageResult<CrmContractDO> pageResult = contractService.getContractPage(reqVO, getLoginUserId());
|
||||||
// 断言
|
// 断言
|
||||||
assertEquals(1, pageResult.getTotal());
|
assertEquals(1, pageResult.getTotal());
|
||||||
assertEquals(1, pageResult.getList().size());
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
Loading…
Reference in New Issue
Block a user