Commit e4d3175f06ef278e8abd536fa793a28862421198
1 parent
23df8633
CRM-数据权限:完善 review 提到的问题
Showing
31 changed files
with
169 additions
and
123 deletions
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java
| @@ -22,7 +22,8 @@ public enum CrmBizTypeEnum implements IntArrayValuable { | @@ -22,7 +22,8 @@ public enum CrmBizTypeEnum implements IntArrayValuable { | ||
| 22 | CRM_CONTACT(3, "联系人"), | 22 | CRM_CONTACT(3, "联系人"), |
| 23 | CRM_BUSINESS(4, "商机"), | 23 | CRM_BUSINESS(4, "商机"), |
| 24 | CRM_CONTRACT(5, "合同"), | 24 | CRM_CONTRACT(5, "合同"), |
| 25 | - CRM_PRODUCT(6, "产品") | 25 | + CRM_PRODUCT(6, "产品"), |
| 26 | + CRM_RECEIVABLE(7, "回款") | ||
| 26 | ; | 27 | ; |
| 27 | 28 | ||
| 28 | public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBizTypeEnum::getType).toArray(); | 29 | public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBizTypeEnum::getType).toArray(); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java
| @@ -122,7 +122,7 @@ public class CrmBusinessController { | @@ -122,7 +122,7 @@ public class CrmBusinessController { | ||
| 122 | @Operation(summary = "获得商机分页,基于指定客户") | 122 | @Operation(summary = "获得商机分页,基于指定客户") |
| 123 | public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmBusinessPageReqVO pageReqVO) { | 123 | public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmBusinessPageReqVO pageReqVO) { |
| 124 | Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); | 124 | Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); |
| 125 | - PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomer(pageReqVO, getLoginUserId()); | 125 | + PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomerId(pageReqVO); |
| 126 | // 处理客户名称回显 | 126 | // 处理客户名称回显 |
| 127 | // TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈; | 127 | // TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈; |
| 128 | Set<Long> customerIds = pageResult.getList().stream() | 128 | Set<Long> customerIds = pageResult.getList().stream() |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessPageReqVO.java
| @@ -24,7 +24,4 @@ public class CrmBusinessPageReqVO extends PageParam { | @@ -24,7 +24,4 @@ public class CrmBusinessPageReqVO extends PageParam { | ||
| 24 | @InEnum(CrmSceneTypeEnum.class) | 24 | @InEnum(CrmSceneTypeEnum.class) |
| 25 | private Integer sceneType; // 场景类型,为 null 时则表示全部 | 25 | private Integer sceneType; // 场景类型,为 null 时则表示全部 |
| 26 | 26 | ||
| 27 | - @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") | ||
| 28 | - private Boolean pool; // null 则表示为不是公海数据 | ||
| 29 | - | ||
| 30 | } | 27 | } |
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,7 +125,7 @@ public class CrmContactController { | ||
| 125 | @Operation(summary = "获得联系人分页,基于指定客户") | 125 | @Operation(summary = "获得联系人分页,基于指定客户") |
| 126 | public CommonResult<PageResult<CrmContactRespVO>> getContactPageByCustomer(@Valid CrmContactPageReqVO pageVO) { | 126 | public CommonResult<PageResult<CrmContactRespVO>> getContactPageByCustomer(@Valid CrmContactPageReqVO pageVO) { |
| 127 | Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); | 127 | Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); |
| 128 | - PageResult<CrmContactDO> pageResult = contactService.getContactPageByCustomerId(pageVO, getLoginUserId()); | 128 | + PageResult<CrmContactDO> pageResult = contactService.getContactPageByCustomerId(pageVO); |
| 129 | return success(convertDetailContactPage(pageResult)); | 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/contact/vo/CrmContactPageReqVO.java
| @@ -39,7 +39,4 @@ public class CrmContactPageReqVO extends PageParam { | @@ -39,7 +39,4 @@ public class CrmContactPageReqVO extends PageParam { | ||
| 39 | @InEnum(CrmSceneTypeEnum.class) | 39 | @InEnum(CrmSceneTypeEnum.class) |
| 40 | private Integer sceneType; // 场景类型,为 null 时则表示全部 | 40 | private Integer sceneType; // 场景类型,为 null 时则表示全部 |
| 41 | 41 | ||
| 42 | - @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") | ||
| 43 | - private Boolean pool; // null 则表示为不是公海数据 | ||
| 44 | - | ||
| 45 | } | 42 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java
| @@ -95,7 +95,7 @@ public class CrmContractController { | @@ -95,7 +95,7 @@ public class CrmContractController { | ||
| 95 | @Operation(summary = "获得联系人分页,基于指定客户") | 95 | @Operation(summary = "获得联系人分页,基于指定客户") |
| 96 | public CommonResult<PageResult<ContractRespVO>> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) { | 96 | public CommonResult<PageResult<ContractRespVO>> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) { |
| 97 | Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); | 97 | Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); |
| 98 | - PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomer(pageVO, getLoginUserId()); | 98 | + PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomerId(pageVO); |
| 99 | return success(convertDetailContractPage(pageResult)); | 99 | return success(convertDetailContractPage(pageResult)); |
| 100 | } | 100 | } |
| 101 | 101 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractPageReqVO.java
| @@ -30,7 +30,4 @@ public class CrmContractPageReqVO extends PageParam { | @@ -30,7 +30,4 @@ public class CrmContractPageReqVO extends PageParam { | ||
| 30 | @InEnum(CrmSceneTypeEnum.class) | 30 | @InEnum(CrmSceneTypeEnum.class) |
| 31 | private Integer sceneType; // 场景类型,为 null 时则表示全部 | 31 | private Integer sceneType; // 场景类型,为 null 时则表示全部 |
| 32 | 32 | ||
| 33 | - @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") | ||
| 34 | - private Boolean pool; // null 则表示为不是公海数据 TODO @puhui999:合同没有公海。目前只有【客户】【线索】有公海,其它都没 | ||
| 35 | - | ||
| 36 | } | 33 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java
| @@ -36,6 +36,7 @@ import java.util.Map; | @@ -36,6 +36,7 @@ import java.util.Map; | ||
| 36 | import java.util.stream.Stream; | 36 | import java.util.stream.Stream; |
| 37 | 37 | ||
| 38 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 38 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 39 | +import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; | ||
| 39 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; | 40 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; |
| 40 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 41 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 41 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | 42 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| @@ -94,7 +95,7 @@ public class CrmReceivableController { | @@ -94,7 +95,7 @@ public class CrmReceivableController { | ||
| 94 | @Operation(summary = "获得回款分页") | 95 | @Operation(summary = "获得回款分页") |
| 95 | @PreAuthorize("@ss.hasPermission('crm:receivable:query')") | 96 | @PreAuthorize("@ss.hasPermission('crm:receivable:query')") |
| 96 | public CommonResult<PageResult<CrmReceivableRespVO>> getReceivablePage(@Valid CrmReceivablePageReqVO pageReqVO) { | 97 | public CommonResult<PageResult<CrmReceivableRespVO>> getReceivablePage(@Valid CrmReceivablePageReqVO pageReqVO) { |
| 97 | - PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(pageReqVO); | 98 | + PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(pageReqVO, getLoginUserId()); |
| 98 | return success(convertDetailReceivablePage(pageResult)); | 99 | return success(convertDetailReceivablePage(pageResult)); |
| 99 | } | 100 | } |
| 100 | 101 | ||
| @@ -102,7 +103,7 @@ public class CrmReceivableController { | @@ -102,7 +103,7 @@ public class CrmReceivableController { | ||
| 102 | @Operation(summary = "获得回款分页,基于指定客户") | 103 | @Operation(summary = "获得回款分页,基于指定客户") |
| 103 | public CommonResult<PageResult<CrmReceivableRespVO>> getReceivablePageByCustomer(@Valid CrmReceivablePageReqVO pageReqVO) { | 104 | public CommonResult<PageResult<CrmReceivableRespVO>> getReceivablePageByCustomer(@Valid CrmReceivablePageReqVO pageReqVO) { |
| 104 | Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); | 105 | Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); |
| 105 | - PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePageByCustomer(pageReqVO); | 106 | + PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePageByCustomerId(pageReqVO); |
| 106 | return success(convertDetailReceivablePage(pageResult)); | 107 | return success(convertDetailReceivablePage(pageResult)); |
| 107 | } | 108 | } |
| 108 | 109 | ||
| @@ -113,7 +114,8 @@ public class CrmReceivableController { | @@ -113,7 +114,8 @@ public class CrmReceivableController { | ||
| 113 | @OperateLog(type = EXPORT) | 114 | @OperateLog(type = EXPORT) |
| 114 | public void exportReceivableExcel(@Valid CrmReceivablePageReqVO exportReqVO, | 115 | public void exportReceivableExcel(@Valid CrmReceivablePageReqVO exportReqVO, |
| 115 | HttpServletResponse response) throws IOException { | 116 | HttpServletResponse response) throws IOException { |
| 116 | - PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(exportReqVO); | 117 | + exportReqVO.setPageSize(PAGE_SIZE_NONE); |
| 118 | + PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(exportReqVO, getLoginUserId()); | ||
| 117 | // 导出 Excel | 119 | // 导出 Excel |
| 118 | ExcelUtils.write(response, "回款.xls", "数据", CrmReceivableRespVO.class, | 120 | ExcelUtils.write(response, "回款.xls", "数据", CrmReceivableRespVO.class, |
| 119 | convertDetailReceivablePage(pageResult).getList()); | 121 | convertDetailReceivablePage(pageResult).getList()); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanPageReqVO.java
| @@ -25,7 +25,4 @@ public class CrmReceivablePlanPageReqVO extends PageParam { | @@ -25,7 +25,4 @@ public class CrmReceivablePlanPageReqVO extends PageParam { | ||
| 25 | @InEnum(CrmSceneTypeEnum.class) | 25 | @InEnum(CrmSceneTypeEnum.class) |
| 26 | private Integer sceneType; // 场景类型,为 null 时则表示全部 | 26 | private Integer sceneType; // 场景类型,为 null 时则表示全部 |
| 27 | 27 | ||
| 28 | - @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") | ||
| 29 | - private Boolean pool; // null 则表示为不是公海数据 | ||
| 30 | - | ||
| 31 | } | 28 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java
| @@ -27,7 +27,4 @@ public class CrmReceivablePageReqVO extends PageParam { | @@ -27,7 +27,4 @@ public class CrmReceivablePageReqVO extends PageParam { | ||
| 27 | @InEnum(CrmSceneTypeEnum.class) | 27 | @InEnum(CrmSceneTypeEnum.class) |
| 28 | private Integer sceneType; // 场景类型,为 null 时则表示全部 | 28 | private Integer sceneType; // 场景类型,为 null 时则表示全部 |
| 29 | 29 | ||
| 30 | - @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") | ||
| 31 | - private Boolean pool; // null 则表示为不是公海数据 | ||
| 32 | - | ||
| 33 | } | 30 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java
| @@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferRe | @@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferRe | ||
| 9 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 9 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 10 | import org.mapstruct.Mapper; | 10 | import org.mapstruct.Mapper; |
| 11 | import org.mapstruct.Mapping; | 11 | import org.mapstruct.Mapping; |
| 12 | -import org.mapstruct.Mappings; | ||
| 13 | import org.mapstruct.factory.Mappers; | 12 | import org.mapstruct.factory.Mappers; |
| 14 | 13 | ||
| 15 | import java.util.List; | 14 | import java.util.List; |
| @@ -48,10 +47,7 @@ public interface ContactConvert { | @@ -48,10 +47,7 @@ public interface ContactConvert { | ||
| 48 | 47 | ||
| 49 | List<CrmContactSimpleRespVO> convertAllList(List<CrmContactDO> list); | 48 | List<CrmContactSimpleRespVO> convertAllList(List<CrmContactDO> list); |
| 50 | 49 | ||
| 51 | - @Mappings({ | ||
| 52 | - @Mapping(target = "bizId", source = "reqVO.id"), | ||
| 53 | - @Mapping(target = "newOwnerUserId", source = "reqVO.id") | ||
| 54 | - }) | 50 | + @Mapping(target = "bizId", source = "reqVO.id") |
| 55 | CrmPermissionTransferReqBO convert(CrmContactTransferReqVO reqVO, Long userId); | 51 | CrmPermissionTransferReqBO convert(CrmContactTransferReqVO reqVO, Long userId); |
| 56 | 52 | ||
| 57 | /** | 53 | /** |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/ContractConvert.java
| @@ -8,7 +8,6 @@ import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferRe | @@ -8,7 +8,6 @@ import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferRe | ||
| 8 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 8 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 9 | import org.mapstruct.Mapper; | 9 | import org.mapstruct.Mapper; |
| 10 | import org.mapstruct.Mapping; | 10 | import org.mapstruct.Mapping; |
| 11 | -import org.mapstruct.Mappings; | ||
| 12 | import org.mapstruct.factory.Mappers; | 11 | import org.mapstruct.factory.Mappers; |
| 13 | 12 | ||
| 14 | import java.util.List; | 13 | import java.util.List; |
| @@ -39,10 +38,7 @@ public interface ContractConvert { | @@ -39,10 +38,7 @@ public interface ContractConvert { | ||
| 39 | 38 | ||
| 40 | List<CrmContractExcelVO> convertList02(List<CrmContractDO> list); | 39 | List<CrmContractExcelVO> convertList02(List<CrmContractDO> list); |
| 41 | 40 | ||
| 42 | - @Mappings({ | ||
| 43 | - @Mapping(target = "bizId", source = "reqVO.id"), | ||
| 44 | - @Mapping(target = "newOwnerUserId", source = "reqVO.id") | ||
| 45 | - }) | 41 | + @Mapping(target = "bizId", source = "reqVO.id") |
| 46 | CrmPermissionTransferReqBO convert(CrmContractTransferReqVO reqVO, Long userId); | 42 | CrmPermissionTransferReqBO convert(CrmContractTransferReqVO reqVO, Long userId); |
| 47 | 43 | ||
| 48 | default PageResult<ContractRespVO> convertPage(PageResult<CrmContractDO> pageResult, Map<Long, AdminUserRespDTO> userMap, | 44 | default PageResult<ContractRespVO> convertPage(PageResult<CrmContractDO> pageResult, Map<Long, AdminUserRespDTO> userMap, |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.dal.mysql.business; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.dal.mysql.business; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 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 | import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; |
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; | 7 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; |
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| @@ -27,14 +28,20 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> { | @@ -27,14 +28,20 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> { | ||
| 27 | .set(CrmBusinessDO::getOwnerUserId, ownerUserId)); | 28 | .set(CrmBusinessDO::getOwnerUserId, ownerUserId)); |
| 28 | } | 29 | } |
| 29 | 30 | ||
| 31 | + default PageResult<CrmBusinessDO> selectPageByCustomerId(CrmBusinessPageReqVO pageReqVO) { | ||
| 32 | + return selectPage(pageReqVO, new LambdaQueryWrapperX<CrmBusinessDO>() | ||
| 33 | + .eq(CrmBusinessDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号 | ||
| 34 | + .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) | ||
| 35 | + .orderByDesc(CrmBusinessDO::getId)); | ||
| 36 | + } | ||
| 37 | + | ||
| 30 | default PageResult<CrmBusinessDO> selectPage(CrmBusinessPageReqVO pageReqVO, Long userId) { | 38 | default PageResult<CrmBusinessDO> selectPage(CrmBusinessPageReqVO pageReqVO, Long userId) { |
| 31 | MPJLambdaWrapperX<CrmBusinessDO> query = new MPJLambdaWrapperX<>(); | 39 | MPJLambdaWrapperX<CrmBusinessDO> query = new MPJLambdaWrapperX<>(); |
| 32 | // 拼接数据权限的查询条件 | 40 | // 拼接数据权限的查询条件 |
| 33 | - CrmQueryWrapperUtils.builderPageQuery(query, CrmBizTypeEnum.CRM_BUSINESS.getType(), CrmBusinessDO::getId, | ||
| 34 | - userId, pageReqVO.getSceneType(), pageReqVO.getPool()); | 41 | + CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_BUSINESS.getType(), CrmBusinessDO::getId, |
| 42 | + userId, pageReqVO.getSceneType(), Boolean.FALSE); | ||
| 35 | // 拼接自身的查询条件 | 43 | // 拼接自身的查询条件 |
| 36 | query.selectAll(CrmBusinessDO.class) | 44 | query.selectAll(CrmBusinessDO.class) |
| 37 | - .eqIfPresent(CrmBusinessDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号 | ||
| 38 | .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) | 45 | .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) |
| 39 | .orderByDesc(CrmBusinessDO::getId); | 46 | .orderByDesc(CrmBusinessDO::getId); |
| 40 | return selectJoinPage(pageReqVO, CrmBusinessDO.class, query); | 47 | return selectJoinPage(pageReqVO, CrmBusinessDO.class, query); |
| @@ -43,7 +50,7 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> { | @@ -43,7 +50,7 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> { | ||
| 43 | default List<CrmBusinessDO> selectBatchIds(Collection<Long> ids, Long userId) { | 50 | default List<CrmBusinessDO> selectBatchIds(Collection<Long> ids, Long userId) { |
| 44 | MPJLambdaWrapperX<CrmBusinessDO> query = new MPJLambdaWrapperX<>(); | 51 | MPJLambdaWrapperX<CrmBusinessDO> query = new MPJLambdaWrapperX<>(); |
| 45 | // 拼接数据权限的查询条件 | 52 | // 拼接数据权限的查询条件 |
| 46 | - CrmQueryWrapperUtils.builderListQueryBatch(query, CrmBizTypeEnum.CRM_BUSINESS.getType(), ids, userId); | 53 | + CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_BUSINESS.getType(), ids, userId); |
| 47 | return selectJoinList(CrmBusinessDO.class, query); | 54 | return selectJoinList(CrmBusinessDO.class, query); |
| 48 | } | 55 | } |
| 49 | 56 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java
| @@ -30,7 +30,7 @@ public interface CrmClueMapper extends BaseMapperX<CrmClueDO> { | @@ -30,7 +30,7 @@ public interface CrmClueMapper extends BaseMapperX<CrmClueDO> { | ||
| 30 | default PageResult<CrmClueDO> selectPage(CrmCluePageReqVO pageReqVO, Long userId) { | 30 | default PageResult<CrmClueDO> selectPage(CrmCluePageReqVO pageReqVO, Long userId) { |
| 31 | MPJLambdaWrapperX<CrmClueDO> query = new MPJLambdaWrapperX<>(); | 31 | MPJLambdaWrapperX<CrmClueDO> query = new MPJLambdaWrapperX<>(); |
| 32 | // 拼接数据权限的查询条件 | 32 | // 拼接数据权限的查询条件 |
| 33 | - CrmQueryWrapperUtils.builderPageQuery(query, CrmBizTypeEnum.CRM_LEADS.getType(), CrmClueDO::getId, | 33 | + CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_LEADS.getType(), CrmClueDO::getId, |
| 34 | userId, pageReqVO.getSceneType(), pageReqVO.getPool()); | 34 | userId, pageReqVO.getSceneType(), pageReqVO.getPool()); |
| 35 | // 拼接自身的查询条件 | 35 | // 拼接自身的查询条件 |
| 36 | query.selectAll(CrmClueDO.class) | 36 | query.selectAll(CrmClueDO.class) |
| @@ -44,7 +44,7 @@ public interface CrmClueMapper extends BaseMapperX<CrmClueDO> { | @@ -44,7 +44,7 @@ public interface CrmClueMapper extends BaseMapperX<CrmClueDO> { | ||
| 44 | default List<CrmClueDO> selectBatchIds(Collection<Long> ids, Long userId) { | 44 | default List<CrmClueDO> selectBatchIds(Collection<Long> ids, Long userId) { |
| 45 | MPJLambdaWrapperX<CrmClueDO> query = new MPJLambdaWrapperX<>(); | 45 | MPJLambdaWrapperX<CrmClueDO> query = new MPJLambdaWrapperX<>(); |
| 46 | // 拼接数据权限的查询条件 | 46 | // 拼接数据权限的查询条件 |
| 47 | - CrmQueryWrapperUtils.builderListQueryBatch(query, CrmBizTypeEnum.CRM_LEADS.getType(), ids, userId); | 47 | + CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_LEADS.getType(), ids, userId); |
| 48 | return selectJoinList(CrmClueDO.class, query); | 48 | return selectJoinList(CrmClueDO.class, query); |
| 49 | } | 49 | } |
| 50 | 50 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.dal.mysql.contact; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.dal.mysql.contact; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 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 | import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; |
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; | 7 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; |
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| @@ -27,14 +28,25 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { | @@ -27,14 +28,25 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { | ||
| 27 | .set(CrmContactDO::getOwnerUserId, ownerUserId)); | 28 | .set(CrmContactDO::getOwnerUserId, ownerUserId)); |
| 28 | } | 29 | } |
| 29 | 30 | ||
| 31 | + default PageResult<CrmContactDO> selectPageByCustomerId(CrmContactPageReqVO pageVO) { | ||
| 32 | + return selectPage(pageVO, new LambdaQueryWrapperX<CrmContactDO>() | ||
| 33 | + .eq(CrmContactDO::getCustomerId, pageVO.getCustomerId()) // 指定客户编号 | ||
| 34 | + .likeIfPresent(CrmContactDO::getName, pageVO.getName()) | ||
| 35 | + .eqIfPresent(CrmContactDO::getMobile, pageVO.getMobile()) | ||
| 36 | + .eqIfPresent(CrmContactDO::getTelephone, pageVO.getTelephone()) | ||
| 37 | + .eqIfPresent(CrmContactDO::getEmail, pageVO.getEmail()) | ||
| 38 | + .eqIfPresent(CrmContactDO::getQq, pageVO.getQq()) | ||
| 39 | + .eqIfPresent(CrmContactDO::getWechat, pageVO.getWechat()) | ||
| 40 | + .orderByDesc(CrmContactDO::getId)); | ||
| 41 | + } | ||
| 42 | + | ||
| 30 | default PageResult<CrmContactDO> selectPage(CrmContactPageReqVO pageReqVO, Long userId) { | 43 | default PageResult<CrmContactDO> selectPage(CrmContactPageReqVO pageReqVO, Long userId) { |
| 31 | MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>(); | 44 | MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>(); |
| 32 | // 拼接数据权限的查询条件 | 45 | // 拼接数据权限的查询条件 |
| 33 | - CrmQueryWrapperUtils.builderPageQuery(query, CrmBizTypeEnum.CRM_CONTACT.getType(), CrmContactDO::getId, | ||
| 34 | - userId, pageReqVO.getSceneType(), pageReqVO.getPool()); | 46 | + CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTACT.getType(), CrmContactDO::getId, |
| 47 | + userId, pageReqVO.getSceneType(), Boolean.FALSE); | ||
| 35 | // 拼接自身的查询条件 | 48 | // 拼接自身的查询条件 |
| 36 | query.selectAll(CrmContactDO.class) | 49 | query.selectAll(CrmContactDO.class) |
| 37 | - .eqIfPresent(CrmContactDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号 | ||
| 38 | .likeIfPresent(CrmContactDO::getName, pageReqVO.getName()) | 50 | .likeIfPresent(CrmContactDO::getName, pageReqVO.getName()) |
| 39 | .eqIfPresent(CrmContactDO::getMobile, pageReqVO.getMobile()) | 51 | .eqIfPresent(CrmContactDO::getMobile, pageReqVO.getMobile()) |
| 40 | .eqIfPresent(CrmContactDO::getTelephone, pageReqVO.getTelephone()) | 52 | .eqIfPresent(CrmContactDO::getTelephone, pageReqVO.getTelephone()) |
| @@ -48,7 +60,7 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { | @@ -48,7 +60,7 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { | ||
| 48 | default List<CrmContactDO> selectBatchIds(Collection<Long> ids, Long userId) { | 60 | default List<CrmContactDO> selectBatchIds(Collection<Long> ids, Long userId) { |
| 49 | MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>(); | 61 | MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>(); |
| 50 | // 拼接数据权限的查询条件 | 62 | // 拼接数据权限的查询条件 |
| 51 | - CrmQueryWrapperUtils.builderListQueryBatch(query, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, userId); | 63 | + CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, userId); |
| 52 | return selectJoinList(CrmContactDO.class, query); | 64 | return selectJoinList(CrmContactDO.class, query); |
| 53 | } | 65 | } |
| 54 | 66 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.dal.mysql.contract; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.dal.mysql.contract; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 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 | import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; |
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; | 7 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; |
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; |
| @@ -27,13 +28,22 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> { | @@ -27,13 +28,22 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> { | ||
| 27 | .set(CrmContractDO::getOwnerUserId, ownerUserId)); | 28 | .set(CrmContractDO::getOwnerUserId, ownerUserId)); |
| 28 | } | 29 | } |
| 29 | 30 | ||
| 31 | + default PageResult<CrmContractDO> selectPageByCustomerId(CrmContractPageReqVO pageReqVO) { | ||
| 32 | + return selectPage(pageReqVO, new LambdaQueryWrapperX<CrmContractDO>() | ||
| 33 | + .eq(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) | ||
| 34 | + .likeIfPresent(CrmContractDO::getNo, pageReqVO.getNo()) | ||
| 35 | + .likeIfPresent(CrmContractDO::getName, pageReqVO.getName()) | ||
| 36 | + .eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) | ||
| 37 | + .eqIfPresent(CrmContractDO::getBusinessId, pageReqVO.getBusinessId()) | ||
| 38 | + .orderByDesc(CrmContractDO::getId)); | ||
| 39 | + } | ||
| 40 | + | ||
| 30 | default PageResult<CrmContractDO> selectPage(CrmContractPageReqVO pageReqVO, Long userId) { | 41 | default PageResult<CrmContractDO> selectPage(CrmContractPageReqVO pageReqVO, Long userId) { |
| 31 | MPJLambdaWrapperX<CrmContractDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); | 42 | MPJLambdaWrapperX<CrmContractDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); |
| 32 | // 构建数据权限连表条件 | 43 | // 构建数据权限连表条件 |
| 33 | - CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), CrmContractDO::getId, | ||
| 34 | - userId, pageReqVO.getSceneType(), pageReqVO.getPool()); | 44 | + CrmQueryWrapperUtils.appendPermissionCondition(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), CrmContractDO::getId, |
| 45 | + userId, pageReqVO.getSceneType(), Boolean.FALSE); | ||
| 35 | mpjLambdaWrapperX.selectAll(CrmContractDO.class) | 46 | mpjLambdaWrapperX.selectAll(CrmContractDO.class) |
| 36 | - .eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) | ||
| 37 | .likeIfPresent(CrmContractDO::getNo, pageReqVO.getNo()) | 47 | .likeIfPresent(CrmContractDO::getNo, pageReqVO.getNo()) |
| 38 | .likeIfPresent(CrmContractDO::getName, pageReqVO.getName()) | 48 | .likeIfPresent(CrmContractDO::getName, pageReqVO.getName()) |
| 39 | .eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) | 49 | .eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) |
| @@ -45,7 +55,7 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> { | @@ -45,7 +55,7 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> { | ||
| 45 | default List<CrmContractDO> selectBatchIds(Collection<Long> ids, Long userId) { | 55 | default List<CrmContractDO> selectBatchIds(Collection<Long> ids, Long userId) { |
| 46 | MPJLambdaWrapperX<CrmContractDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); | 56 | MPJLambdaWrapperX<CrmContractDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); |
| 47 | // 构建数据权限连表条件 | 57 | // 构建数据权限连表条件 |
| 48 | - CrmQueryWrapperUtils.builderListQueryBatch(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, userId); | 58 | + CrmQueryWrapperUtils.appendPermissionCondition(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, userId); |
| 49 | return selectJoinList(CrmContractDO.class, mpjLambdaWrapperX); | 59 | return selectJoinList(CrmContractDO.class, mpjLambdaWrapperX); |
| 50 | } | 60 | } |
| 51 | 61 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java
| @@ -30,7 +30,7 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | @@ -30,7 +30,7 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | ||
| 30 | default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO pageReqVO, Long userId) { | 30 | default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO pageReqVO, Long userId) { |
| 31 | MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>(); | 31 | MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>(); |
| 32 | // 拼接数据权限的查询条件 | 32 | // 拼接数据权限的查询条件 |
| 33 | - CrmQueryWrapperUtils.builderPageQuery(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), CrmCustomerDO::getId, | 33 | + CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), CrmCustomerDO::getId, |
| 34 | userId, pageReqVO.getSceneType(), pageReqVO.getPool()); | 34 | userId, pageReqVO.getSceneType(), pageReqVO.getPool()); |
| 35 | // 拼接自身的查询条件 | 35 | // 拼接自身的查询条件 |
| 36 | query.selectAll(CrmCustomerDO.class) | 36 | query.selectAll(CrmCustomerDO.class) |
| @@ -45,7 +45,7 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | @@ -45,7 +45,7 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | ||
| 45 | default List<CrmCustomerDO> selectBatchIds(Collection<Long> ids, Long userId) { | 45 | default List<CrmCustomerDO> selectBatchIds(Collection<Long> ids, Long userId) { |
| 46 | MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>(); | 46 | MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>(); |
| 47 | // 拼接数据权限的查询条件 | 47 | // 拼接数据权限的查询条件 |
| 48 | - CrmQueryWrapperUtils.builderListQueryBatch(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, userId); | 48 | + CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, userId); |
| 49 | return selectJoinList(CrmCustomerDO.class, query); | 49 | return selectJoinList(CrmCustomerDO.class, query); |
| 50 | } | 50 | } |
| 51 | 51 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java
| @@ -46,4 +46,10 @@ public interface CrmPermissionMapper extends BaseMapperX<CrmPermissionDO> { | @@ -46,4 +46,10 @@ public interface CrmPermissionMapper extends BaseMapperX<CrmPermissionDO> { | ||
| 46 | .eq(CrmPermissionDO::getId, id).eq(CrmPermissionDO::getUserId, userId)); | 46 | .eq(CrmPermissionDO::getId, id).eq(CrmPermissionDO::getUserId, userId)); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | + default int deletePermission(Integer bizType, Long bizId) { | ||
| 50 | + return delete(new LambdaQueryWrapperX<CrmPermissionDO>() | ||
| 51 | + .eq(CrmPermissionDO::getBizType, bizType) | ||
| 52 | + .eq(CrmPermissionDO::getBizId, bizId)); | ||
| 53 | + } | ||
| 54 | + | ||
| 49 | } | 55 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java
| @@ -3,10 +3,17 @@ package cn.iocoder.yudao.module.crm.dal.mysql.receivable; | @@ -3,10 +3,17 @@ package cn.iocoder.yudao.module.crm.dal.mysql.receivable; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 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.LambdaQueryWrapperX; |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; | ||
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; | 7 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; |
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; |
| 9 | +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | ||
| 10 | +import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils; | ||
| 11 | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | ||
| 8 | import org.apache.ibatis.annotations.Mapper; | 12 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 13 | ||
| 14 | +import java.util.Collection; | ||
| 15 | +import java.util.List; | ||
| 16 | + | ||
| 10 | /** | 17 | /** |
| 11 | * 回款 Mapper | 18 | * 回款 Mapper |
| 12 | * | 19 | * |
| @@ -15,15 +22,13 @@ import org.apache.ibatis.annotations.Mapper; | @@ -15,15 +22,13 @@ import org.apache.ibatis.annotations.Mapper; | ||
| 15 | @Mapper | 22 | @Mapper |
| 16 | public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> { | 23 | public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> { |
| 17 | 24 | ||
| 18 | - default PageResult<CrmReceivableDO> selectPage(CrmReceivablePageReqVO reqVO) { | ||
| 19 | - return selectPage(reqVO, new LambdaQueryWrapperX<CrmReceivableDO>() | ||
| 20 | - .eqIfPresent(CrmReceivableDO::getNo, reqVO.getNo()) | ||
| 21 | - .eqIfPresent(CrmReceivableDO::getPlanId, reqVO.getPlanId()) | ||
| 22 | - .eqIfPresent(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) | ||
| 23 | - .orderByDesc(CrmReceivableDO::getId)); | 25 | + default int updateOwnerUserIdById(Long id, Long ownerUserId) { |
| 26 | + return update(new LambdaUpdateWrapper<CrmReceivableDO>() | ||
| 27 | + .eq(CrmReceivableDO::getId, id) | ||
| 28 | + .set(CrmReceivableDO::getOwnerUserId, ownerUserId)); | ||
| 24 | } | 29 | } |
| 25 | 30 | ||
| 26 | - default PageResult<CrmReceivableDO> selectPageByCustomer(CrmReceivablePageReqVO reqVO) { | 31 | + default PageResult<CrmReceivableDO> selectPageByCustomerId(CrmReceivablePageReqVO reqVO) { |
| 27 | return selectPage(reqVO, new LambdaQueryWrapperX<CrmReceivableDO>() | 32 | return selectPage(reqVO, new LambdaQueryWrapperX<CrmReceivableDO>() |
| 28 | .eq(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 | 33 | .eq(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 |
| 29 | .eqIfPresent(CrmReceivableDO::getNo, reqVO.getNo()) | 34 | .eqIfPresent(CrmReceivableDO::getNo, reqVO.getNo()) |
| @@ -31,4 +36,24 @@ public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> { | @@ -31,4 +36,24 @@ public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> { | ||
| 31 | .orderByDesc(CrmReceivableDO::getId)); | 36 | .orderByDesc(CrmReceivableDO::getId)); |
| 32 | } | 37 | } |
| 33 | 38 | ||
| 39 | + default PageResult<CrmReceivableDO> selectPage(CrmReceivablePageReqVO pageReqVO, Long userId) { | ||
| 40 | + MPJLambdaWrapperX<CrmReceivableDO> query = new MPJLambdaWrapperX<>(); | ||
| 41 | + // 拼接数据权限的查询条件 | ||
| 42 | + CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(), CrmReceivableDO::getId, | ||
| 43 | + userId, pageReqVO.getSceneType(), Boolean.FALSE); | ||
| 44 | + // 拼接自身的查询条件 | ||
| 45 | + query.selectAll(CrmReceivableDO.class) | ||
| 46 | + .eqIfPresent(CrmReceivableDO::getNo, pageReqVO.getNo()) | ||
| 47 | + .eqIfPresent(CrmReceivableDO::getPlanId, pageReqVO.getPlanId()) | ||
| 48 | + .orderByDesc(CrmReceivableDO::getId); | ||
| 49 | + return selectJoinPage(pageReqVO, CrmReceivableDO.class, query); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + default List<CrmReceivableDO> selectBatchIds(Collection<Long> ids, Long userId) { | ||
| 53 | + MPJLambdaWrapperX<CrmReceivableDO> query = new MPJLambdaWrapperX<>(); | ||
| 54 | + // 拼接数据权限的查询条件 | ||
| 55 | + CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(), ids, userId); | ||
| 56 | + return selectJoinList(CrmReceivableDO.class, query); | ||
| 57 | + } | ||
| 58 | + | ||
| 34 | } | 59 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java
| @@ -75,10 +75,9 @@ public interface CrmBusinessService { | @@ -75,10 +75,9 @@ public interface CrmBusinessService { | ||
| 75 | * 数据权限:基于 {@link CrmCustomerDO} 读取 | 75 | * 数据权限:基于 {@link CrmCustomerDO} 读取 |
| 76 | * | 76 | * |
| 77 | * @param pageReqVO 分页查询 | 77 | * @param pageReqVO 分页查询 |
| 78 | - * @param userId 用户编号 | ||
| 79 | * @return 联系人分页 | 78 | * @return 联系人分页 |
| 80 | */ | 79 | */ |
| 81 | - PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmBusinessPageReqVO pageReqVO, Long userId); | 80 | + PageResult<CrmBusinessDO> getBusinessPageByCustomerId(CrmBusinessPageReqVO pageReqVO); |
| 82 | 81 | ||
| 83 | /** | 82 | /** |
| 84 | * 商机转移 | 83 | * 商机转移 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| @@ -111,11 +111,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -111,11 +111,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | @Override | 113 | @Override |
| 114 | - public PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmBusinessPageReqVO pageReqVO, Long userId) { | ||
| 115 | - // 校验客户存在 TODO @puhui999:这里不校验 | ||
| 116 | - customerService.validateCustomer(pageReqVO.getCustomerId()); | ||
| 117 | - // TODO @puhui999:感觉这里貌似不太复用用 selectPage,因为他可能没商机权限,只是因为能看 customer,所以可以看到列表 | ||
| 118 | - return businessMapper.selectPage(pageReqVO, userId); | 114 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) |
| 115 | + public PageResult<CrmBusinessDO> getBusinessPageByCustomerId(CrmBusinessPageReqVO pageReqVO) { | ||
| 116 | + return businessMapper.selectPageByCustomerId(pageReqVO); | ||
| 119 | } | 117 | } |
| 120 | 118 | ||
| 121 | @Override | 119 | @Override |
| @@ -127,7 +125,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -127,7 +125,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 127 | // 2.1 数据权限转移 | 125 | // 2.1 数据权限转移 |
| 128 | crmPermissionService.transferPermission( | 126 | crmPermissionService.transferPermission( |
| 129 | CrmBusinessConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType())); | 127 | CrmBusinessConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType())); |
| 130 | - | ||
| 131 | // 2.2 设置新的负责人 | 128 | // 2.2 设置新的负责人 |
| 132 | businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); | 129 | businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); |
| 133 | 130 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java
| @@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactCreateR | @@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactCreateR | ||
| 5 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; | 5 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; |
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactUpdateReqVO; | 6 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactUpdateReqVO; |
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 8 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||
| 8 | import jakarta.validation.Valid; | 9 | import jakarta.validation.Valid; |
| 9 | 10 | ||
| 10 | import java.util.Collection; | 11 | import java.util.Collection; |
| @@ -71,12 +72,11 @@ public interface CrmContactService { | @@ -71,12 +72,11 @@ public interface CrmContactService { | ||
| 71 | /** | 72 | /** |
| 72 | * 获得联系人分页 | 73 | * 获得联系人分页 |
| 73 | * | 74 | * |
| 74 | - * 数据权限:基于 {@link CrmContactDO} | 75 | + * 数据权限:基于 {@link CrmCustomerDO} |
| 75 | * | 76 | * |
| 76 | * @param pageVO 分页查询 | 77 | * @param pageVO 分页查询 |
| 77 | - * @param userId 用户编号 | ||
| 78 | * @return 联系人分页 | 78 | * @return 联系人分页 |
| 79 | */ | 79 | */ |
| 80 | - PageResult<CrmContactDO> getContactPageByCustomerId(CrmContactPageReqVO pageVO, Long userId); | 80 | + PageResult<CrmContactDO> getContactPageByCustomerId(CrmContactPageReqVO pageVO); |
| 81 | 81 | ||
| 82 | } | 82 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
| @@ -134,11 +134,9 @@ public class CrmContactServiceImpl implements CrmContactService { | @@ -134,11 +134,9 @@ public class CrmContactServiceImpl implements CrmContactService { | ||
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | @Override | 136 | @Override |
| 137 | - public PageResult<CrmContactDO> getContactPageByCustomerId(CrmContactPageReqVO pageVO, Long userId) { | ||
| 138 | - // 校验用户存在 | ||
| 139 | - customerService.validateCustomer(pageVO.getCustomerId()); | ||
| 140 | - // TODO @puhui999:getBusinessPageByCustomer 同理 | ||
| 141 | - return contactMapper.selectPage(pageVO, userId); | 137 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageVO.customerId", level = CrmPermissionLevelEnum.READ) |
| 138 | + public PageResult<CrmContactDO> getContactPageByCustomerId(CrmContactPageReqVO pageVO) { | ||
| 139 | + return contactMapper.selectPageByCustomerId(pageVO); | ||
| 142 | } | 140 | } |
| 143 | 141 | ||
| 144 | } | 142 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java
| @@ -75,12 +75,9 @@ public interface CrmContractService { | @@ -75,12 +75,9 @@ public interface CrmContractService { | ||
| 75 | * 数据权限:基于 {@link CrmCustomerDO} 读取 | 75 | * 数据权限:基于 {@link CrmCustomerDO} 读取 |
| 76 | * | 76 | * |
| 77 | * @param pageReqVO 分页查询 | 77 | * @param pageReqVO 分页查询 |
| 78 | - * @param userId 用户编号 | ||
| 79 | * @return 联系人分页 | 78 | * @return 联系人分页 |
| 80 | */ | 79 | */ |
| 81 | - default PageResult<CrmContractDO> getContractPageByCustomer(CrmContractPageReqVO pageReqVO, Long userId) { | ||
| 82 | - return getContractPage(pageReqVO, userId); | ||
| 83 | - } | 80 | + PageResult<CrmContractDO> getContractPageByCustomerId(CrmContractPageReqVO pageReqVO); |
| 84 | 81 | ||
| 85 | /** | 82 | /** |
| 86 | * 合同转移 | 83 | * 合同转移 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java
| @@ -105,6 +105,12 @@ public class CrmContractServiceImpl implements CrmContractService { | @@ -105,6 +105,12 @@ public class CrmContractServiceImpl implements CrmContractService { | ||
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | @Override | 107 | @Override |
| 108 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) | ||
| 109 | + public PageResult<CrmContractDO> getContractPageByCustomerId(CrmContractPageReqVO pageReqVO) { | ||
| 110 | + return contractMapper.selectPageByCustomerId(pageReqVO); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + @Override | ||
| 108 | @Transactional(rollbackFor = Exception.class) | 114 | @Transactional(rollbackFor = Exception.class) |
| 109 | public void transferContract(CrmContractTransferReqVO reqVO, Long userId) { | 115 | public void transferContract(CrmContractTransferReqVO reqVO, Long userId) { |
| 110 | // 1. 校验合同是否存在 | 116 | // 1. 校验合同是否存在 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| @@ -114,7 +114,6 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -114,7 +114,6 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 114 | */ | 114 | */ |
| 115 | @Override | 115 | @Override |
| 116 | public void validateCustomer(Long customerId) { | 116 | public void validateCustomer(Long customerId) { |
| 117 | - // TODO puhui999: 不返回客户不走校验应该可行 | ||
| 118 | // 校验客户是否存在 | 117 | // 校验客户是否存在 |
| 119 | if (customerId == null) { | 118 | if (customerId == null) { |
| 120 | throw exception(CUSTOMER_NOT_EXISTS); | 119 | throw exception(CUSTOMER_NOT_EXISTS); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java
| @@ -139,14 +139,11 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { | @@ -139,14 +139,11 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { | ||
| 139 | 139 | ||
| 140 | @Override | 140 | @Override |
| 141 | public void deletePermission(Integer bizType, Long bizId) { | 141 | public void deletePermission(Integer bizType, Long bizId) { |
| 142 | - // TODO @puhui999:这种直接写条件删除;不需要先查询,再删除 | ||
| 143 | - List<CrmPermissionDO> permissionList = crmPermissionMapper.selectByBizTypeAndBizId(bizType, bizId); | ||
| 144 | - if (CollUtil.isEmpty(permissionList)) { | ||
| 145 | - return; | ||
| 146 | - } | ||
| 147 | - | ||
| 148 | // 删除数据权限 | 142 | // 删除数据权限 |
| 149 | - crmPermissionMapper.deleteBatchIds(convertSet(permissionList, CrmPermissionDO::getId)); | 143 | + int deletedCol = crmPermissionMapper.deletePermission(bizType, bizId); |
| 144 | + if (deletedCol == 0) { | ||
| 145 | + throw exception(CRM_PERMISSION_NOT_EXISTS); | ||
| 146 | + } | ||
| 150 | } | 147 | } |
| 151 | 148 | ||
| 152 | @Override | 149 | @Override |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java
| @@ -6,8 +6,8 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.Crm | @@ -6,8 +6,8 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.Crm | ||
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; | 6 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; |
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; |
| 9 | - | ||
| 10 | import jakarta.validation.Valid; | 9 | import jakarta.validation.Valid; |
| 10 | + | ||
| 11 | import java.util.Collection; | 11 | import java.util.Collection; |
| 12 | import java.util.List; | 12 | import java.util.List; |
| 13 | 13 | ||
| @@ -62,9 +62,10 @@ public interface CrmReceivableService { | @@ -62,9 +62,10 @@ public interface CrmReceivableService { | ||
| 62 | * 数据权限:基于 {@link CrmReceivableDO} 读取 | 62 | * 数据权限:基于 {@link CrmReceivableDO} 读取 |
| 63 | * | 63 | * |
| 64 | * @param pageReqVO 分页查询 | 64 | * @param pageReqVO 分页查询 |
| 65 | + * @param userId 用户编号 | ||
| 65 | * @return 回款分页 | 66 | * @return 回款分页 |
| 66 | */ | 67 | */ |
| 67 | - PageResult<CrmReceivableDO> getReceivablePage(CrmReceivablePageReqVO pageReqVO); | 68 | + PageResult<CrmReceivableDO> getReceivablePage(CrmReceivablePageReqVO pageReqVO, Long userId); |
| 68 | 69 | ||
| 69 | /** | 70 | /** |
| 70 | * 获得回款分页,基于指定客户 | 71 | * 获得回款分页,基于指定客户 |
| @@ -74,6 +75,6 @@ public interface CrmReceivableService { | @@ -74,6 +75,6 @@ public interface CrmReceivableService { | ||
| 74 | * @param pageReqVO 分页查询 | 75 | * @param pageReqVO 分页查询 |
| 75 | * @return 回款分页 | 76 | * @return 回款分页 |
| 76 | */ | 77 | */ |
| 77 | - PageResult<CrmReceivableDO> getReceivablePageByCustomer(CrmReceivablePageReqVO pageReqVO); | 78 | + PageResult<CrmReceivableDO> getReceivablePageByCustomerId(CrmReceivablePageReqVO pageReqVO); |
| 78 | 79 | ||
| 79 | } | 80 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java
| @@ -20,10 +20,10 @@ import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | @@ -20,10 +20,10 @@ import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | ||
| 20 | import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; | 20 | import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; |
| 21 | import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; | 21 | import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; |
| 22 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | 22 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| 23 | +import jakarta.annotation.Resource; | ||
| 23 | import org.springframework.stereotype.Service; | 24 | import org.springframework.stereotype.Service; |
| 24 | import org.springframework.validation.annotation.Validated; | 25 | import org.springframework.validation.annotation.Validated; |
| 25 | 26 | ||
| 26 | -import jakarta.annotation.Resource; | ||
| 27 | import java.util.Collection; | 27 | import java.util.Collection; |
| 28 | import java.util.List; | 28 | import java.util.List; |
| 29 | 29 | ||
| @@ -129,16 +129,15 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | @@ -129,16 +129,15 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||
| 129 | return receivableMapper.selectBatchIds(ids); | 129 | return receivableMapper.selectBatchIds(ids); |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | - // TODO @芋艿:数据权限 | ||
| 133 | @Override | 132 | @Override |
| 134 | - public PageResult<CrmReceivableDO> getReceivablePage(CrmReceivablePageReqVO pageReqVO) { | ||
| 135 | - return receivableMapper.selectPage(pageReqVO); | 133 | + public PageResult<CrmReceivableDO> getReceivablePage(CrmReceivablePageReqVO pageReqVO, Long userId) { |
| 134 | + return receivableMapper.selectPage(pageReqVO, userId); | ||
| 136 | } | 135 | } |
| 137 | 136 | ||
| 138 | @Override | 137 | @Override |
| 139 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) | 138 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) |
| 140 | - public PageResult<CrmReceivableDO> getReceivablePageByCustomer(CrmReceivablePageReqVO pageReqVO) { | ||
| 141 | - return receivableMapper.selectPageByCustomer(pageReqVO); | 139 | + public PageResult<CrmReceivableDO> getReceivablePageByCustomerId(CrmReceivablePageReqVO pageReqVO) { |
| 140 | + return receivableMapper.selectPageByCustomerId(pageReqVO); | ||
| 142 | } | 141 | } |
| 143 | 142 | ||
| 144 | } | 143 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmQueryWrapperUtils.java
| @@ -6,6 +6,7 @@ import cn.hutool.extra.spring.SpringUtil; | @@ -6,6 +6,7 @@ import cn.hutool.extra.spring.SpringUtil; | ||
| 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; | 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; |
| 7 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | 7 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 8 | import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; | 8 | import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; |
| 9 | +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | ||
| 9 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 10 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 10 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 11 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 11 | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; | 12 | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; |
| @@ -17,7 +18,7 @@ import java.util.List; | @@ -17,7 +18,7 @@ import java.util.List; | ||
| 17 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 18 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 18 | 19 | ||
| 19 | /** | 20 | /** |
| 20 | - * CRM 分页查询工具类 | 21 | + * CRM 查询工具类 |
| 21 | * | 22 | * |
| 22 | * @author HUIHUI | 23 | * @author HUIHUI |
| 23 | */ | 24 | */ |
| @@ -26,17 +27,16 @@ public class CrmQueryWrapperUtils { | @@ -26,17 +27,16 @@ public class CrmQueryWrapperUtils { | ||
| 26 | /** | 27 | /** |
| 27 | * 构造 CRM 数据类型数据分页查询条件 | 28 | * 构造 CRM 数据类型数据分页查询条件 |
| 28 | * | 29 | * |
| 29 | - * @param query 连表查询对象 | ||
| 30 | - * @param bizType 数据类型 {@link CrmBizTypeEnum} | ||
| 31 | - * @param bizId 数据编号 | ||
| 32 | - * @param userId 用户编号 | ||
| 33 | - * @param sceneType 场景类型 | ||
| 34 | - * @param pool 公海 | 30 | + * @param query 连表查询对象 |
| 31 | + * @param bizType 数据类型 {@link CrmBizTypeEnum} | ||
| 32 | + * @param bizId 数据编号 | ||
| 33 | + * @param userId 用户编号 | ||
| 34 | + * @param sceneType 场景类型 | ||
| 35 | + * @param pool 公海 | ||
| 35 | */ | 36 | */ |
| 36 | - // TODO @puhui999:bizId 直接传递会不会简单点 | ||
| 37 | - // TODO @puhui999:builderPageQuery 应该不仅仅适合于分页查询,应该适用于所有的查询;可以改成 appendPermissionCondition | ||
| 38 | - public static <T extends MPJLambdaWrapper<?>, S> void builderPageQuery(T query, Integer bizType, SFunction<S, ?> bizId, | ||
| 39 | - Long userId, Integer sceneType, Boolean pool) { | 37 | + // TODO @puhui999:bizId 直接传递会不会简单点 回复:还是需要 SFunction 因为分页连表时不知道 bizId 是多少 |
| 38 | + public static <T extends MPJLambdaWrapper<?>, S> void appendPermissionCondition(T query, Integer bizType, SFunction<S, ?> bizId, | ||
| 39 | + Long userId, Integer sceneType, Boolean pool) { | ||
| 40 | // 1. 构建数据权限连表条件 | 40 | // 1. 构建数据权限连表条件 |
| 41 | if (ObjUtil.notEqual(validateAdminUser(userId), Boolean.TRUE)) { // 管理员不需要数据权限 | 41 | if (ObjUtil.notEqual(validateAdminUser(userId), Boolean.TRUE)) { // 管理员不需要数据权限 |
| 42 | query.innerJoin(CrmPermissionDO.class, on -> | 42 | query.innerJoin(CrmPermissionDO.class, on -> |
| @@ -48,9 +48,13 @@ public class CrmQueryWrapperUtils { | @@ -48,9 +48,13 @@ public class CrmQueryWrapperUtils { | ||
| 48 | query.eq("owner_user_id", userId); | 48 | query.eq("owner_user_id", userId); |
| 49 | } | 49 | } |
| 50 | // 2.2 场景二:我参与的数据 | 50 | // 2.2 场景二:我参与的数据 |
| 51 | - // TODO @puhui999:参与,指的是有读写权限噢;可以把 1. 的合并到 2.2 里;因为 2.1 不需要; | ||
| 52 | if (CrmSceneTypeEnum.isInvolved(sceneType)) { | 51 | if (CrmSceneTypeEnum.isInvolved(sceneType)) { |
| 53 | - query.ne("owner_user_id", userId); | 52 | + query |
| 53 | + .ne("owner_user_id", userId) | ||
| 54 | + .and(q -> q.eq(CrmPermissionDO::getLevel, CrmPermissionLevelEnum.READ.getLevel()) | ||
| 55 | + .or() | ||
| 56 | + .eq(CrmPermissionDO::getLevel, CrmPermissionLevelEnum.WRITE.getLevel())); | ||
| 57 | + | ||
| 54 | } | 58 | } |
| 55 | // 2.3 场景三:下属负责的数据 | 59 | // 2.3 场景三:下属负责的数据 |
| 56 | if (CrmSceneTypeEnum.isSubordinate(sceneType)) { | 60 | if (CrmSceneTypeEnum.isSubordinate(sceneType)) { |
| @@ -61,7 +65,7 @@ public class CrmQueryWrapperUtils { | @@ -61,7 +65,7 @@ public class CrmQueryWrapperUtils { | ||
| 61 | } | 65 | } |
| 62 | } | 66 | } |
| 63 | 67 | ||
| 64 | - // 2. 拼接公海的查询条件 | 68 | + // 3. 拼接公海的查询条件 |
| 65 | if (ObjUtil.equal(pool, Boolean.TRUE)) { // 情况一:公海 | 69 | if (ObjUtil.equal(pool, Boolean.TRUE)) { // 情况一:公海 |
| 66 | query.isNull("owner_user_id"); | 70 | query.isNull("owner_user_id"); |
| 67 | } else { // 情况二:不是公海 | 71 | } else { // 情况二:不是公海 |
| @@ -72,28 +76,27 @@ public class CrmQueryWrapperUtils { | @@ -72,28 +76,27 @@ public class CrmQueryWrapperUtils { | ||
| 72 | /** | 76 | /** |
| 73 | * 构造 CRM 数据类型批量数据查询条件 | 77 | * 构造 CRM 数据类型批量数据查询条件 |
| 74 | * | 78 | * |
| 75 | - * @param query 连表查询对象 | ||
| 76 | - * @param bizType 数据类型 {@link CrmBizTypeEnum} | ||
| 77 | - * @param bizIds 数据编号 | ||
| 78 | - * @param userId 用户编号 | 79 | + * @param query 连表查询对象 |
| 80 | + * @param bizType 数据类型 {@link CrmBizTypeEnum} | ||
| 81 | + * @param bizIds 数据编号 | ||
| 82 | + * @param userId 用户编号 | ||
| 79 | */ | 83 | */ |
| 80 | - // TODO @puhui999:可以改成 appendPermissionCondition | ||
| 81 | - // TODO @puhui999:S 是不是可以删除 | ||
| 82 | - public static <T extends MPJLambdaWrapper<?>, S> void builderListQueryBatch(T query, Integer bizType, Collection<Long> bizIds, Long userId) { | ||
| 83 | - // TODO @puhui999:这里先 if return 简单点 | ||
| 84 | - if (ObjUtil.notEqual(validateAdminUser(userId), Boolean.TRUE)) { // 管理员不需要数据权限 | ||
| 85 | - query.innerJoin(CrmPermissionDO.class, on -> | ||
| 86 | - on.eq(CrmPermissionDO::getBizType, bizType).in(CrmPermissionDO::getBizId, bizIds) | ||
| 87 | - .in(CollUtil.isNotEmpty(bizIds), CrmPermissionDO::getUserId, userId)); | 84 | + public static <T extends MPJLambdaWrapper<?>> void appendPermissionCondition(T query, Integer bizType, Collection<Long> bizIds, Long userId) { |
| 85 | + if (ObjUtil.equal(validateAdminUser(userId), Boolean.TRUE)) {// 管理员不需要数据权限 | ||
| 86 | + return; | ||
| 88 | } | 87 | } |
| 88 | + | ||
| 89 | + query.innerJoin(CrmPermissionDO.class, on -> | ||
| 90 | + on.eq(CrmPermissionDO::getBizType, bizType).in(CrmPermissionDO::getBizId, bizIds) | ||
| 91 | + .in(CollUtil.isNotEmpty(bizIds), CrmPermissionDO::getUserId, userId)); | ||
| 89 | } | 92 | } |
| 90 | 93 | ||
| 91 | - // TODO @puhui999:需要加个变量,不用每次都拿哈; | ||
| 92 | private static AdminUserApi getAdminUserApi() { | 94 | private static AdminUserApi getAdminUserApi() { |
| 93 | - return SpringUtil.getBean(AdminUserApi.class); | 95 | + return AdminUserApiHolder.ADMIN_USER_API; |
| 94 | } | 96 | } |
| 95 | 97 | ||
| 96 | // TODO @puhui999:需要实现; | 98 | // TODO @puhui999:需要实现; |
| 99 | + | ||
| 97 | /** | 100 | /** |
| 98 | * 校验用户是否是管理员 | 101 | * 校验用户是否是管理员 |
| 99 | * | 102 | * |
| @@ -104,4 +107,15 @@ public class CrmQueryWrapperUtils { | @@ -104,4 +107,15 @@ public class CrmQueryWrapperUtils { | ||
| 104 | return false; | 107 | return false; |
| 105 | } | 108 | } |
| 106 | 109 | ||
| 110 | + /** | ||
| 111 | + * 静态内部类实现 AdminUserApi 单例获取 | ||
| 112 | + * | ||
| 113 | + * @author HUIHUI | ||
| 114 | + */ | ||
| 115 | + private static class AdminUserApiHolder { | ||
| 116 | + | ||
| 117 | + private static final AdminUserApi ADMIN_USER_API = SpringUtil.getBean(AdminUserApi.class); | ||
| 118 | + | ||
| 119 | + } | ||
| 120 | + | ||
| 107 | } | 121 | } |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivableServiceImplTest.java
| @@ -7,12 +7,11 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.Crm | @@ -7,12 +7,11 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.Crm | ||
| 7 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; | 7 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; |
| 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; |
| 9 | import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivableMapper; | 9 | import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivableMapper; |
| 10 | +import jakarta.annotation.Resource; | ||
| 10 | import org.junit.jupiter.api.Disabled; | 11 | import org.junit.jupiter.api.Disabled; |
| 11 | import org.junit.jupiter.api.Test; | 12 | import org.junit.jupiter.api.Test; |
| 12 | import org.springframework.context.annotation.Import; | 13 | import org.springframework.context.annotation.Import; |
| 13 | 14 | ||
| 14 | -import jakarta.annotation.Resource; | ||
| 15 | - | ||
| 16 | import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | 15 | import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; |
| 17 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | 16 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 18 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | 17 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; |
| @@ -133,7 +132,7 @@ public class CrmCrmReceivableServiceImplTest extends BaseDbUnitTest { | @@ -133,7 +132,7 @@ public class CrmCrmReceivableServiceImplTest extends BaseDbUnitTest { | ||
| 133 | reqVO.setCustomerId(null); | 132 | reqVO.setCustomerId(null); |
| 134 | 133 | ||
| 135 | // 调用 | 134 | // 调用 |
| 136 | - PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(reqVO); | 135 | + PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(reqVO, 1L); |
| 137 | // 断言 | 136 | // 断言 |
| 138 | assertEquals(1, pageResult.getTotal()); | 137 | assertEquals(1, pageResult.getTotal()); |
| 139 | assertEquals(1, pageResult.getList().size()); | 138 | assertEquals(1, pageResult.getList().size()); |