Commit 7c54affb16fea44111b4ea4f14defe786e0cfff0
1 parent
f69a18fd
CRM-合同:完善数据权限,新增权限关联、场景分页查询,新增权限关联批量查询
Showing
16 changed files
with
100 additions
and
60 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java
| ... | ... | @@ -9,7 +9,6 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 9 | 9 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*; |
| 10 | 10 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO; |
| 11 | 11 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO; |
| 12 | -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; | |
| 13 | 12 | import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; |
| 14 | 13 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 15 | 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; |
| ... | ... | @@ -121,9 +120,9 @@ public class CrmBusinessController { |
| 121 | 120 | |
| 122 | 121 | @GetMapping("/page-by-customer") |
| 123 | 122 | @Operation(summary = "获得商机分页,基于指定客户") |
| 124 | - public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmContractPageReqVO pageReqVO) { | |
| 123 | + public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmBusinessPageReqVO pageReqVO) { | |
| 125 | 124 | Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); |
| 126 | - PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomer(pageReqVO); | |
| 125 | + PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomer(pageReqVO, getLoginUserId()); | |
| 127 | 126 | // 处理客户名称回显 |
| 128 | 127 | // TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈; |
| 129 | 128 | Set<Long> customerIds = pageResult.getList().stream() | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java
| ... | ... | @@ -125,7 +125,7 @@ public class CrmContactController { |
| 125 | 125 | @Operation(summary = "获得联系人分页,基于指定客户") |
| 126 | 126 | public CommonResult<PageResult<CrmContactRespVO>> getContactPageByCustomer(@Valid CrmContactPageReqVO pageVO) { |
| 127 | 127 | Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); |
| 128 | - PageResult<CrmContactDO> pageResult = contactService.getContactPage(pageVO, getLoginUserId()); | |
| 128 | + PageResult<CrmContactDO> pageResult = contactService.getContactPageByCustomerId(pageVO, getLoginUserId()); | |
| 129 | 129 | return success(convertDetailContactPage(pageResult)); |
| 130 | 130 | } |
| 131 | 131 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java
| ... | ... | @@ -87,7 +87,7 @@ public class CrmContractController { |
| 87 | 87 | @Operation(summary = "获得合同分页") |
| 88 | 88 | @PreAuthorize("@ss.hasPermission('crm:contract:query')") |
| 89 | 89 | public CommonResult<PageResult<ContractRespVO>> getContractPage(@Valid CrmContractPageReqVO pageVO) { |
| 90 | - PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO); | |
| 90 | + PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO, getLoginUserId()); | |
| 91 | 91 | return success(convertDetailContractPage(pageResult)); |
| 92 | 92 | } |
| 93 | 93 | |
| ... | ... | @@ -95,7 +95,7 @@ public class CrmContractController { |
| 95 | 95 | @Operation(summary = "获得联系人分页,基于指定客户") |
| 96 | 96 | public CommonResult<PageResult<ContractRespVO>> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) { |
| 97 | 97 | Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); |
| 98 | - PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomer(pageVO); | |
| 98 | + PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomer(pageVO, getLoginUserId()); | |
| 99 | 99 | return success(convertDetailContractPage(pageResult)); |
| 100 | 100 | } |
| 101 | 101 | |
| ... | ... | @@ -105,7 +105,7 @@ public class CrmContractController { |
| 105 | 105 | @OperateLog(type = EXPORT) |
| 106 | 106 | public void exportContractExcel(@Valid CrmContractPageReqVO exportReqVO, |
| 107 | 107 | HttpServletResponse response) throws IOException { |
| 108 | - PageResult<CrmContractDO> pageResult = contractService.getContractPage(exportReqVO); | |
| 108 | + PageResult<CrmContractDO> pageResult = contractService.getContractPage(exportReqVO, getLoginUserId()); | |
| 109 | 109 | // 导出 Excel |
| 110 | 110 | ExcelUtils.write(response, "合同.xls", "数据", CrmContractExcelVO.class, |
| 111 | 111 | ContractConvert.INSTANCE.convertList02(pageResult.getList())); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java
| ... | ... | @@ -33,7 +33,7 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> { |
| 33 | 33 | CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_BUSINESS.getType(), CrmBusinessDO::getId, |
| 34 | 34 | userId, pageReqVO.getSceneType(), pageReqVO.getPool()); |
| 35 | 35 | mpjLambdaWrapperX.selectAll(CrmBusinessDO.class) |
| 36 | - .eq(CrmBusinessDO::getCustomerId, pageReqVO.getCustomerId()) // 必须传递 | |
| 36 | + .eqIfPresent(CrmBusinessDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号 | |
| 37 | 37 | .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) |
| 38 | 38 | .orderByDesc(CrmBusinessDO::getId); |
| 39 | 39 | return selectJoinPage(pageReqVO, CrmBusinessDO.class, mpjLambdaWrapperX); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java
| ... | ... | @@ -33,7 +33,7 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { |
| 33 | 33 | CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), CrmContactDO::getId, |
| 34 | 34 | userId, pageReqVO.getSceneType(), pageReqVO.getPool()); |
| 35 | 35 | mpjLambdaWrapperX.selectAll(CrmContactDO.class) |
| 36 | - .eq(CrmContactDO::getCustomerId, pageReqVO.getCustomerId()) // 必须传递 | |
| 36 | + .eqIfPresent(CrmContactDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号 | |
| 37 | 37 | .likeIfPresent(CrmContactDO::getName, pageReqVO.getName()) |
| 38 | 38 | .eqIfPresent(CrmContactDO::getMobile, pageReqVO.getMobile()) |
| 39 | 39 | .eqIfPresent(CrmContactDO::getTelephone, pageReqVO.getTelephone()) | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java
| ... | ... | @@ -2,11 +2,17 @@ package cn.iocoder.yudao.module.crm.dal.mysql.contract; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; | |
| 6 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; |
| 7 | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; |
| 8 | +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | |
| 9 | +import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils; | |
| 10 | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |
| 8 | 11 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 12 | |
| 13 | +import java.util.Collection; | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 10 | 16 | /** |
| 11 | 17 | * CRM 合同 Mapper |
| 12 | 18 | * |
| ... | ... | @@ -15,22 +21,32 @@ import org.apache.ibatis.annotations.Mapper; |
| 15 | 21 | @Mapper |
| 16 | 22 | public interface CrmContractMapper extends BaseMapperX<CrmContractDO> { |
| 17 | 23 | |
| 18 | - default PageResult<CrmContractDO> selectPage(CrmContractPageReqVO reqVO) { | |
| 19 | - return selectPage(reqVO, new LambdaQueryWrapperX<CrmContractDO>() | |
| 20 | - .likeIfPresent(CrmContractDO::getNo, reqVO.getNo()) | |
| 21 | - .likeIfPresent(CrmContractDO::getName, reqVO.getName()) | |
| 22 | - .eqIfPresent(CrmContractDO::getCustomerId, reqVO.getCustomerId()) | |
| 23 | - .eqIfPresent(CrmContractDO::getBusinessId, reqVO.getBusinessId()) | |
| 24 | - .orderByDesc(CrmContractDO::getId)); | |
| 24 | + default int updateOwnerUserIdById(Long id, Long ownerUserId) { | |
| 25 | + return update(new LambdaUpdateWrapper<CrmContractDO>() | |
| 26 | + .eq(CrmContractDO::getId, id) | |
| 27 | + .set(CrmContractDO::getOwnerUserId, ownerUserId)); | |
| 28 | + } | |
| 29 | + | |
| 30 | + default PageResult<CrmContractDO> selectPage(CrmContractPageReqVO pageReqVO, Long userId) { | |
| 31 | + MPJLambdaWrapperX<CrmContractDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); | |
| 32 | + // 构建数据权限连表条件 | |
| 33 | + CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), CrmContractDO::getId, | |
| 34 | + userId, pageReqVO.getSceneType(), pageReqVO.getPool()); | |
| 35 | + mpjLambdaWrapperX.selectAll(CrmContractDO.class) | |
| 36 | + .eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) | |
| 37 | + .likeIfPresent(CrmContractDO::getNo, pageReqVO.getNo()) | |
| 38 | + .likeIfPresent(CrmContractDO::getName, pageReqVO.getName()) | |
| 39 | + .eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) | |
| 40 | + .eqIfPresent(CrmContractDO::getBusinessId, pageReqVO.getBusinessId()) | |
| 41 | + .orderByDesc(CrmContractDO::getId); | |
| 42 | + return selectJoinPage(pageReqVO, CrmContractDO.class, mpjLambdaWrapperX); | |
| 25 | 43 | } |
| 26 | 44 | |
| 27 | - default PageResult<CrmContractDO> selectPageByCustomer(CrmContractPageReqVO reqVO) { | |
| 28 | - return selectPage(reqVO, new LambdaQueryWrapperX<CrmContractDO>() | |
| 29 | - .eq(CrmContractDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 | |
| 30 | - .likeIfPresent(CrmContractDO::getNo, reqVO.getNo()) | |
| 31 | - .likeIfPresent(CrmContractDO::getName, reqVO.getName()) | |
| 32 | - .eqIfPresent(CrmContractDO::getBusinessId, reqVO.getBusinessId()) | |
| 33 | - .orderByDesc(CrmContractDO::getId)); | |
| 45 | + default List<CrmContractDO> selectBatchIds(Collection<Long> ids, Long userId) { | |
| 46 | + MPJLambdaWrapperX<CrmContractDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); | |
| 47 | + // 构建数据权限连表条件 | |
| 48 | + CrmQueryWrapperUtils.builderListQueryBatch(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, userId); | |
| 49 | + return selectJoinList(CrmContractDO.class, mpjLambdaWrapperX); | |
| 34 | 50 | } |
| 35 | 51 | |
| 36 | 52 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java
| ... | ... | @@ -5,7 +5,6 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusi |
| 5 | 5 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; |
| 6 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; |
| 7 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO; |
| 8 | -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; | |
| 9 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 10 | 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 11 | 10 | import jakarta.validation.Valid; |
| ... | ... | @@ -76,9 +75,10 @@ public interface CrmBusinessService { |
| 76 | 75 | * 数据权限:基于 {@link CrmCustomerDO} 读取 |
| 77 | 76 | * |
| 78 | 77 | * @param pageReqVO 分页查询 |
| 78 | + * @param userId 用户编号 | |
| 79 | 79 | * @return 联系人分页 |
| 80 | 80 | */ |
| 81 | - PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmContractPageReqVO pageReqVO); | |
| 81 | + PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmBusinessPageReqVO pageReqVO, Long userId); | |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * 商机转移 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| ... | ... | @@ -7,13 +7,13 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusi |
| 7 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; |
| 9 | 9 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO; |
| 10 | -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; | |
| 11 | 10 | import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; |
| 12 | 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 13 | 12 | import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; |
| 14 | 13 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 15 | 14 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 16 | 15 | import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; |
| 16 | +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | |
| 17 | 17 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 18 | 18 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 19 | 19 | import jakarta.annotation.Resource; |
| ... | ... | @@ -38,6 +38,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 38 | 38 | |
| 39 | 39 | @Resource |
| 40 | 40 | private CrmBusinessMapper businessMapper; |
| 41 | + @Resource | |
| 42 | + private CrmCustomerService customerService; | |
| 41 | 43 | |
| 42 | 44 | @Resource |
| 43 | 45 | private CrmPermissionService crmPermissionService; |
| ... | ... | @@ -109,10 +111,11 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 109 | 111 | } |
| 110 | 112 | |
| 111 | 113 | @Override |
| 112 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) | |
| 113 | - public PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmContractPageReqVO pageReqVO) { | |
| 114 | - //return businessMapper.selectPageByCustomer(pageReqVO); | |
| 115 | - return null; // TODO puhui999: 可以跟分页合并吗? | |
| 114 | + public PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmBusinessPageReqVO pageReqVO, Long userId) { | |
| 115 | + // 校验客户存在 | |
| 116 | + customerService.validateCustomer(pageReqVO.getCustomerId()); | |
| 117 | + | |
| 118 | + return businessMapper.selectPage(pageReqVO, userId); | |
| 116 | 119 | } |
| 117 | 120 | |
| 118 | 121 | @Override | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java
| ... | ... | @@ -68,4 +68,15 @@ public interface CrmContactService { |
| 68 | 68 | */ |
| 69 | 69 | PageResult<CrmContactDO> getContactPage(CrmContactPageReqVO pageReqVO, Long userId); |
| 70 | 70 | |
| 71 | + /** | |
| 72 | + * 获得联系人分页 | |
| 73 | + * | |
| 74 | + * 数据权限:基于 {@link CrmContactDO} | |
| 75 | + * | |
| 76 | + * @param pageVO 分页查询 | |
| 77 | + * @param userId 用户编号 | |
| 78 | + * @return 联系人分页 | |
| 79 | + */ | |
| 80 | + PageResult<CrmContactDO> getContactPageByCustomerId(CrmContactPageReqVO pageVO, Long userId); | |
| 81 | + | |
| 71 | 82 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
| ... | ... | @@ -133,4 +133,12 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 133 | 133 | return contactMapper.selectPage(pageReqVO, userId); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | + @Override | |
| 137 | + public PageResult<CrmContactDO> getContactPageByCustomerId(CrmContactPageReqVO pageVO, Long userId) { | |
| 138 | + // 校验用户存在 | |
| 139 | + customerService.validateCustomer(pageVO.getCustomerId()); | |
| 140 | + | |
| 141 | + return contactMapper.selectPage(pageVO, userId); | |
| 142 | + } | |
| 143 | + | |
| 136 | 144 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java
| ... | ... | @@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.crm.service.contract; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO; |
| 5 | 5 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO; | |
| 7 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; |
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO; | |
| 8 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; |
| 9 | 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 10 | - | |
| 11 | 10 | import jakarta.validation.Valid; |
| 11 | + | |
| 12 | 12 | import java.util.Collection; |
| 13 | 13 | import java.util.List; |
| 14 | 14 | |
| ... | ... | @@ -64,9 +64,10 @@ public interface CrmContractService { |
| 64 | 64 | * 数据权限:基于 {@link CrmContractDO} 读取 |
| 65 | 65 | * |
| 66 | 66 | * @param pageReqVO 分页查询 |
| 67 | + * @param userId 用户编号 | |
| 67 | 68 | * @return 合同分页 |
| 68 | 69 | */ |
| 69 | - PageResult<CrmContractDO> getContractPage(CrmContractPageReqVO pageReqVO); | |
| 70 | + PageResult<CrmContractDO> getContractPage(CrmContractPageReqVO pageReqVO, Long userId); | |
| 70 | 71 | |
| 71 | 72 | /** |
| 72 | 73 | * 获得合同分页,基于指定客户 |
| ... | ... | @@ -74,9 +75,12 @@ public interface CrmContractService { |
| 74 | 75 | * 数据权限:基于 {@link CrmCustomerDO} 读取 |
| 75 | 76 | * |
| 76 | 77 | * @param pageReqVO 分页查询 |
| 78 | + * @param userId 用户编号 | |
| 77 | 79 | * @return 联系人分页 |
| 78 | 80 | */ |
| 79 | - PageResult<CrmContractDO> getContractPageByCustomer(CrmContractPageReqVO pageReqVO); | |
| 81 | + default PageResult<CrmContractDO> getContractPageByCustomer(CrmContractPageReqVO pageReqVO, Long userId) { | |
| 82 | + return getContractPage(pageReqVO, userId); | |
| 83 | + } | |
| 80 | 84 | |
| 81 | 85 | /** |
| 82 | 86 | * 合同转移 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java
| ... | ... | @@ -5,8 +5,8 @@ import cn.hutool.core.collection.ListUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO; |
| 7 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; |
| 8 | -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO; | |
| 9 | 8 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; |
| 9 | +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO; | |
| 10 | 10 | import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert; |
| 11 | 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; |
| 12 | 12 | import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper; |
| ... | ... | @@ -15,11 +15,11 @@ import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 15 | 15 | import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; |
| 16 | 16 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 17 | 17 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 18 | +import jakarta.annotation.Resource; | |
| 18 | 19 | import org.springframework.stereotype.Service; |
| 19 | 20 | import org.springframework.transaction.annotation.Transactional; |
| 20 | 21 | import org.springframework.validation.annotation.Validated; |
| 21 | 22 | |
| 22 | -import jakarta.annotation.Resource; | |
| 23 | 23 | import java.util.Collection; |
| 24 | 24 | import java.util.List; |
| 25 | 25 | |
| ... | ... | @@ -56,7 +56,7 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 56 | 56 | |
| 57 | 57 | @Override |
| 58 | 58 | @Transactional(rollbackFor = Exception.class) |
| 59 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, level = CrmPermissionLevelEnum.WRITE) | |
| 59 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) | |
| 60 | 60 | public void updateContract(CrmContractUpdateReqVO updateReqVO) { |
| 61 | 61 | // 校验存在 |
| 62 | 62 | validateContractExists(updateReqVO.getId()); |
| ... | ... | @@ -67,12 +67,14 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 67 | 67 | |
| 68 | 68 | @Override |
| 69 | 69 | @Transactional(rollbackFor = Exception.class) |
| 70 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) | |
| 70 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) | |
| 71 | 71 | public void deleteContract(Long id) { |
| 72 | 72 | // 校验存在 |
| 73 | 73 | validateContractExists(id); |
| 74 | 74 | // 删除 |
| 75 | 75 | contractMapper.deleteById(id); |
| 76 | + // 删除数据权限 | |
| 77 | + crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CONTRACT.getType(), id); | |
| 76 | 78 | } |
| 77 | 79 | |
| 78 | 80 | private CrmContractDO validateContractExists(Long id) { |
| ... | ... | @@ -83,7 +85,6 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 83 | 85 | return contract; |
| 84 | 86 | } |
| 85 | 87 | |
| 86 | - // TODO 芋艿:是否要做数据权限的校验??? | |
| 87 | 88 | @Override |
| 88 | 89 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.READ) |
| 89 | 90 | public CrmContractDO getContract(Long id) { |
| ... | ... | @@ -99,27 +100,24 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 99 | 100 | } |
| 100 | 101 | |
| 101 | 102 | @Override |
| 102 | - public PageResult<CrmContractDO> getContractPage(CrmContractPageReqVO pageReqVO) { | |
| 103 | - return contractMapper.selectPage(pageReqVO); | |
| 104 | - } | |
| 105 | - | |
| 106 | - @Override | |
| 107 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) | |
| 108 | - public PageResult<CrmContractDO> getContractPageByCustomer(CrmContractPageReqVO pageReqVO) { | |
| 109 | - return contractMapper.selectPageByCustomer(pageReqVO); | |
| 103 | + public PageResult<CrmContractDO> getContractPage(CrmContractPageReqVO pageReqVO, Long userId) { | |
| 104 | + return contractMapper.selectPage(pageReqVO, userId); | |
| 110 | 105 | } |
| 111 | 106 | |
| 112 | 107 | @Override |
| 113 | 108 | @Transactional(rollbackFor = Exception.class) |
| 114 | 109 | public void transferContract(CrmContractTransferReqVO reqVO, Long userId) { |
| 115 | - // 1 校验合同是否存在 | |
| 110 | + // 1. 校验合同是否存在 | |
| 116 | 111 | validateContractExists(reqVO.getId()); |
| 117 | 112 | |
| 118 | - // 2. 数据权限转移 | |
| 113 | + // 2.1 数据权限转移 | |
| 119 | 114 | crmPermissionService.transferPermission( |
| 120 | 115 | ContractConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_CONTRACT.getType())); |
| 116 | + // 2.2 设置负责人 | |
| 117 | + contractMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); | |
| 121 | 118 | |
| 122 | 119 | // 3. TODO 记录转移日志 |
| 120 | + | |
| 123 | 121 | } |
| 124 | 122 | |
| 125 | 123 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| ... | ... | @@ -111,15 +111,18 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 111 | 111 | * 校验客户是否存在 |
| 112 | 112 | * |
| 113 | 113 | * @param customerId 客户 id |
| 114 | - * @return 客户 | |
| 115 | 114 | */ |
| 116 | 115 | @Override |
| 117 | - public CrmCustomerDO validateCustomer(Long customerId) { | |
| 118 | - CrmCustomerDO customer = getCustomer(customerId); | |
| 116 | + public void validateCustomer(Long customerId) { | |
| 117 | + // TODO puhui999: 不返回客户不走校验应该可行 | |
| 118 | + // 校验客户是否存在 | |
| 119 | + if (customerId == null) { | |
| 120 | + throw exception(CUSTOMER_NOT_EXISTS); | |
| 121 | + } | |
| 122 | + CrmCustomerDO customer = customerMapper.selectById(customerId); | |
| 119 | 123 | if (Objects.isNull(customer)) { |
| 120 | 124 | throw exception(CUSTOMER_NOT_EXISTS); |
| 121 | 125 | } |
| 122 | - return customer; | |
| 123 | 126 | } |
| 124 | 127 | |
| 125 | 128 | @Override | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java
| ... | ... | @@ -147,7 +147,7 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { |
| 147 | 147 | reqVO.setMobile(null); |
| 148 | 148 | |
| 149 | 149 | // 调用 |
| 150 | - PageResult<CrmClueDO> pageResult = clueService.getCluePage(reqVO, getLoginUserId()); | |
| 150 | + PageResult<CrmClueDO> pageResult = clueService.getCluePage(reqVO, 1L); | |
| 151 | 151 | // 断言 |
| 152 | 152 | assertEquals(1, pageResult.getTotal()); |
| 153 | 153 | assertEquals(1, pageResult.getList().size()); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java
| ... | ... | @@ -7,12 +7,11 @@ import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageR |
| 7 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; |
| 9 | 9 | import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper; |
| 10 | +import jakarta.annotation.Resource; | |
| 10 | 11 | import org.junit.jupiter.api.Disabled; |
| 11 | 12 | import org.junit.jupiter.api.Test; |
| 12 | 13 | import org.springframework.context.annotation.Import; |
| 13 | 14 | |
| 14 | -import jakarta.annotation.Resource; | |
| 15 | - | |
| 16 | 15 | import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; |
| 17 | 16 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 18 | 17 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| ... | ... | @@ -127,7 +126,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest { |
| 127 | 126 | reqVO.setNo(null); |
| 128 | 127 | |
| 129 | 128 | // 调用 |
| 130 | - PageResult<CrmContractDO> pageResult = contractService.getContractPage(reqVO); | |
| 129 | + PageResult<CrmContractDO> pageResult = contractService.getContractPage(reqVO, getLoginUserId()); | |
| 131 | 130 | // 断言 |
| 132 | 131 | assertEquals(1, pageResult.getTotal()); |
| 133 | 132 | assertEquals(1, pageResult.getList().size()); | ... | ... |