Commit 23df8633f4fc1cedaaaabf1ec72cfd2acf395e8e
1 parent
8f578a9a
📖 CRM:code review 数据权限的实现
Showing
25 changed files
with
128 additions
and
139 deletions
pom.xml
| @@ -15,12 +15,12 @@ | @@ -15,12 +15,12 @@ | ||
| 15 | <!-- 各种 module 拓展 --> | 15 | <!-- 各种 module 拓展 --> |
| 16 | <module>yudao-module-system</module> | 16 | <module>yudao-module-system</module> |
| 17 | <module>yudao-module-infra</module> | 17 | <module>yudao-module-infra</module> |
| 18 | -<!-- <module>yudao-module-member</module>--> | 18 | + <module>yudao-module-member</module> |
| 19 | <!-- <module>yudao-module-bpm</module>--> | 19 | <!-- <module>yudao-module-bpm</module>--> |
| 20 | <!-- <module>yudao-module-report</module>--> | 20 | <!-- <module>yudao-module-report</module>--> |
| 21 | <!-- <module>yudao-module-mp</module>--> | 21 | <!-- <module>yudao-module-mp</module>--> |
| 22 | -<!-- <module>yudao-module-pay</module>--> | ||
| 23 | -<!-- <module>yudao-module-mall</module>--> | 22 | + <module>yudao-module-pay</module> |
| 23 | + <module>yudao-module-mall</module> | ||
| 24 | <module>yudao-module-crm</module> | 24 | <module>yudao-module-crm</module> |
| 25 | <!-- 示例项目 --> | 25 | <!-- 示例项目 --> |
| 26 | <!-- <module>yudao-example</module>--> | 26 | <!-- <module>yudao-example</module>--> |
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java
| @@ -48,8 +48,10 @@ public interface BaseMapperX<T> extends MPJBaseMapper<T> { | @@ -48,8 +48,10 @@ public interface BaseMapperX<T> extends MPJBaseMapper<T> { | ||
| 48 | return new PageResult<>(list, (long) list.size()); | 48 | return new PageResult<>(list, (long) list.size()); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | + // MyBatis Plus Join 查询 | ||
| 51 | IPage<D> mpPage = MyBatisUtils.buildPage(pageParam); | 52 | IPage<D> mpPage = MyBatisUtils.buildPage(pageParam); |
| 52 | mpPage = selectJoinPage(mpPage, clazz, lambdaWrapper); | 53 | mpPage = selectJoinPage(mpPage, clazz, lambdaWrapper); |
| 54 | + // 转换返回 | ||
| 53 | return new PageResult<>(mpPage.getRecords(), mpPage.getTotal()); | 55 | return new PageResult<>(mpPage.getRecords(), mpPage.getTotal()); |
| 54 | } | 56 | } |
| 55 | 57 |
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmSceneTypeEnum.java
| @@ -17,9 +17,8 @@ import java.util.Arrays; | @@ -17,9 +17,8 @@ import java.util.Arrays; | ||
| 17 | public enum CrmSceneTypeEnum implements IntArrayValuable { | 17 | public enum CrmSceneTypeEnum implements IntArrayValuable { |
| 18 | 18 | ||
| 19 | OWNER(1, "我负责的"), | 19 | OWNER(1, "我负责的"), |
| 20 | - FOLLOW(2, "我关注的"), | ||
| 21 | - INVOLVED(3, "我参与的"), | ||
| 22 | - SUBORDINATE(4, "下属负责的"); | 20 | + INVOLVED(2, "我参与的"), |
| 21 | + SUBORDINATE(3, "下属负责的"); | ||
| 23 | 22 | ||
| 24 | public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneTypeEnum::getType).toArray(); | 23 | public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneTypeEnum::getType).toArray(); |
| 25 | 24 | ||
| @@ -36,10 +35,6 @@ public enum CrmSceneTypeEnum implements IntArrayValuable { | @@ -36,10 +35,6 @@ public enum CrmSceneTypeEnum implements IntArrayValuable { | ||
| 36 | return ObjUtil.equal(OWNER.getType(), type); | 35 | return ObjUtil.equal(OWNER.getType(), type); |
| 37 | } | 36 | } |
| 38 | 37 | ||
| 39 | - public static boolean isFollow(Integer type) { | ||
| 40 | - return ObjUtil.equal(FOLLOW.getType(), type); | ||
| 41 | - } | ||
| 42 | - | ||
| 43 | public static boolean isInvolved(Integer type) { | 38 | public static boolean isInvolved(Integer type) { |
| 44 | return ObjUtil.equal(INVOLVED.getType(), type); | 39 | return ObjUtil.equal(INVOLVED.getType(), type); |
| 45 | } | 40 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessPageReqVO.java
| @@ -20,12 +20,9 @@ public class CrmBusinessPageReqVO extends PageParam { | @@ -20,12 +20,9 @@ public class CrmBusinessPageReqVO extends PageParam { | ||
| 20 | @Schema(description = "客户编号", example = "10795") | 20 | @Schema(description = "客户编号", example = "10795") |
| 21 | private Long customerId; | 21 | private Long customerId; |
| 22 | 22 | ||
| 23 | - /** | ||
| 24 | - * 场景类型,为 null 时则表示全部 | ||
| 25 | - */ | ||
| 26 | @Schema(description = "场景类型", example = "1") | 23 | @Schema(description = "场景类型", example = "1") |
| 27 | @InEnum(CrmSceneTypeEnum.class) | 24 | @InEnum(CrmSceneTypeEnum.class) |
| 28 | - private Integer sceneType; | 25 | + private Integer sceneType; // 场景类型,为 null 时则表示全部 |
| 29 | 26 | ||
| 30 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") | 27 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") |
| 31 | private Boolean pool; // null 则表示为不是公海数据 | 28 | private Boolean pool; // null 则表示为不是公海数据 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java
| @@ -23,12 +23,9 @@ public class CrmCluePageReqVO extends PageParam { | @@ -23,12 +23,9 @@ public class CrmCluePageReqVO extends PageParam { | ||
| 23 | @Schema(description = "手机号", example = "18000000000") | 23 | @Schema(description = "手机号", example = "18000000000") |
| 24 | private String mobile; | 24 | private String mobile; |
| 25 | 25 | ||
| 26 | - /** | ||
| 27 | - * 场景类型,为 null 时则表示全部 | ||
| 28 | - */ | ||
| 29 | @Schema(description = "场景类型", example = "1") | 26 | @Schema(description = "场景类型", example = "1") |
| 30 | @InEnum(CrmSceneTypeEnum.class) | 27 | @InEnum(CrmSceneTypeEnum.class) |
| 31 | - private Integer sceneType; | 28 | + private Integer sceneType; // 场景类型,为 null 时则表示全部 |
| 32 | 29 | ||
| 33 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") | 30 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") |
| 34 | private Boolean pool; // null 则表示为不是公海数据 | 31 | private Boolean pool; // null 则表示为不是公海数据 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactPageReqVO.java
| @@ -35,12 +35,9 @@ public class CrmContactPageReqVO extends PageParam { | @@ -35,12 +35,9 @@ public class CrmContactPageReqVO extends PageParam { | ||
| 35 | @Schema(description = "微信", example = "zzZ98373") | 35 | @Schema(description = "微信", example = "zzZ98373") |
| 36 | private String wechat; | 36 | private String wechat; |
| 37 | 37 | ||
| 38 | - /** | ||
| 39 | - * 场景类型,为 null 时则表示全部 | ||
| 40 | - */ | ||
| 41 | @Schema(description = "场景类型", example = "1") | 38 | @Schema(description = "场景类型", example = "1") |
| 42 | @InEnum(CrmSceneTypeEnum.class) | 39 | @InEnum(CrmSceneTypeEnum.class) |
| 43 | - private Integer sceneType; | 40 | + private Integer sceneType; // 场景类型,为 null 时则表示全部 |
| 44 | 41 | ||
| 45 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") | 42 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") |
| 46 | private Boolean pool; // null 则表示为不是公海数据 | 43 | private Boolean pool; // null 则表示为不是公海数据 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractPageReqVO.java
| @@ -26,14 +26,11 @@ public class CrmContractPageReqVO extends PageParam { | @@ -26,14 +26,11 @@ public class CrmContractPageReqVO extends PageParam { | ||
| 26 | @Schema(description = "商机编号", example = "10864") | 26 | @Schema(description = "商机编号", example = "10864") |
| 27 | private Long businessId; | 27 | private Long businessId; |
| 28 | 28 | ||
| 29 | - /** | ||
| 30 | - * 场景类型,为 null 时则表示全部 | ||
| 31 | - */ | ||
| 32 | @Schema(description = "场景类型", example = "1") | 29 | @Schema(description = "场景类型", example = "1") |
| 33 | @InEnum(CrmSceneTypeEnum.class) | 30 | @InEnum(CrmSceneTypeEnum.class) |
| 34 | - private Integer sceneType; | 31 | + private Integer sceneType; // 场景类型,为 null 时则表示全部 |
| 35 | 32 | ||
| 36 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") | 33 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") |
| 37 | - private Boolean pool; // null 则表示为不是公海数据 | 34 | + private Boolean pool; // null 则表示为不是公海数据 TODO @puhui999:合同没有公海。目前只有【客户】【线索】有公海,其它都没 |
| 38 | 35 | ||
| 39 | } | 36 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java
| @@ -29,12 +29,9 @@ public class CrmCustomerPageReqVO extends PageParam { | @@ -29,12 +29,9 @@ public class CrmCustomerPageReqVO extends PageParam { | ||
| 29 | @Schema(description = "客户来源", example = "1") | 29 | @Schema(description = "客户来源", example = "1") |
| 30 | private Integer source; | 30 | private Integer source; |
| 31 | 31 | ||
| 32 | - /** | ||
| 33 | - * 场景类型,为 null 时则表示全部 | ||
| 34 | - */ | ||
| 35 | @Schema(description = "场景类型", example = "1") | 32 | @Schema(description = "场景类型", example = "1") |
| 36 | @InEnum(CrmSceneTypeEnum.class) | 33 | @InEnum(CrmSceneTypeEnum.class) |
| 37 | - private Integer sceneType; | 34 | + private Integer sceneType; // 场景类型,为 null 时则表示全部 |
| 38 | 35 | ||
| 39 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") | 36 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") |
| 40 | private Boolean pool; // null 则表示为不是公海数据 | 37 | private Boolean pool; // null 则表示为不是公海数据 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanPageReqVO.java
| @@ -21,12 +21,9 @@ public class CrmReceivablePlanPageReqVO extends PageParam { | @@ -21,12 +21,9 @@ public class CrmReceivablePlanPageReqVO extends PageParam { | ||
| 21 | @Schema(description = "合同名称", example = "3473") | 21 | @Schema(description = "合同名称", example = "3473") |
| 22 | private Long contractId; | 22 | private Long contractId; |
| 23 | 23 | ||
| 24 | - /** | ||
| 25 | - * 场景类型,为 null 时则表示全部 | ||
| 26 | - */ | ||
| 27 | @Schema(description = "场景类型", example = "1") | 24 | @Schema(description = "场景类型", example = "1") |
| 28 | @InEnum(CrmSceneTypeEnum.class) | 25 | @InEnum(CrmSceneTypeEnum.class) |
| 29 | - private Integer sceneType; | 26 | + private Integer sceneType; // 场景类型,为 null 时则表示全部 |
| 30 | 27 | ||
| 31 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") | 28 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") |
| 32 | private Boolean pool; // null 则表示为不是公海数据 | 29 | private Boolean pool; // null 则表示为不是公海数据 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java
| @@ -23,12 +23,9 @@ public class CrmReceivablePageReqVO extends PageParam { | @@ -23,12 +23,9 @@ public class CrmReceivablePageReqVO extends PageParam { | ||
| 23 | @Schema(description = "客户编号", example = "4963") | 23 | @Schema(description = "客户编号", example = "4963") |
| 24 | private Long customerId; | 24 | private Long customerId; |
| 25 | 25 | ||
| 26 | - /** | ||
| 27 | - * 场景类型,为 null 时则表示全部 | ||
| 28 | - */ | ||
| 29 | @Schema(description = "场景类型", example = "1") | 26 | @Schema(description = "场景类型", example = "1") |
| 30 | @InEnum(CrmSceneTypeEnum.class) | 27 | @InEnum(CrmSceneTypeEnum.class) |
| 31 | - private Integer sceneType; | 28 | + private Integer sceneType; // 场景类型,为 null 时则表示全部 |
| 32 | 29 | ||
| 33 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") | 30 | @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") |
| 34 | private Boolean pool; // null 则表示为不是公海数据 | 31 | private Boolean pool; // null 则表示为不是公海数据 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/package-info.java
0 → 100644
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java
| @@ -38,9 +38,7 @@ public interface CrmBusinessConvert { | @@ -38,9 +38,7 @@ public interface CrmBusinessConvert { | ||
| 38 | 38 | ||
| 39 | List<CrmBusinessExcelVO> convertList02(List<CrmBusinessDO> list); | 39 | List<CrmBusinessExcelVO> convertList02(List<CrmBusinessDO> list); |
| 40 | 40 | ||
| 41 | - @Mappings({ | ||
| 42 | - @Mapping(target = "bizId", source = "reqVO.id") | ||
| 43 | - }) | 41 | + @Mapping(target = "bizId", source = "reqVO.id") |
| 44 | CrmPermissionTransferReqBO convert(CrmBusinessTransferReqVO reqVO, Long userId); | 42 | CrmPermissionTransferReqBO convert(CrmBusinessTransferReqVO reqVO, Long userId); |
| 45 | 43 | ||
| 46 | default PageResult<CrmBusinessRespVO> convertPage(PageResult<CrmBusinessDO> page, List<CrmCustomerDO> customerList, | 44 | default PageResult<CrmBusinessRespVO> convertPage(PageResult<CrmBusinessDO> page, List<CrmCustomerDO> customerList, |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java
| @@ -54,9 +54,7 @@ public interface CrmCustomerConvert { | @@ -54,9 +54,7 @@ public interface CrmCustomerConvert { | ||
| 54 | 54 | ||
| 55 | List<CrmCustomerExcelVO> convertList02(List<CrmCustomerDO> list); | 55 | List<CrmCustomerExcelVO> convertList02(List<CrmCustomerDO> list); |
| 56 | 56 | ||
| 57 | - @Mappings({ | ||
| 58 | - @Mapping(target = "bizId", source = "reqVO.id") | ||
| 59 | - }) | 57 | + @Mapping(target = "bizId", source = "reqVO.id") |
| 60 | CrmPermissionTransferReqBO convert(CrmCustomerTransferReqVO reqVO, Long userId); | 58 | CrmPermissionTransferReqBO convert(CrmCustomerTransferReqVO reqVO, Long userId); |
| 61 | 59 | ||
| 62 | PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page); | 60 | PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java
| @@ -28,22 +28,23 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> { | @@ -28,22 +28,23 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> { | ||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | default PageResult<CrmBusinessDO> selectPage(CrmBusinessPageReqVO pageReqVO, Long userId) { | 30 | default PageResult<CrmBusinessDO> selectPage(CrmBusinessPageReqVO pageReqVO, Long userId) { |
| 31 | - MPJLambdaWrapperX<CrmBusinessDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); | ||
| 32 | - // 构建数据权限连表条件 | ||
| 33 | - CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_BUSINESS.getType(), CrmBusinessDO::getId, | 31 | + MPJLambdaWrapperX<CrmBusinessDO> query = new MPJLambdaWrapperX<>(); |
| 32 | + // 拼接数据权限的查询条件 | ||
| 33 | + CrmQueryWrapperUtils.builderPageQuery(query, CrmBizTypeEnum.CRM_BUSINESS.getType(), CrmBusinessDO::getId, | ||
| 34 | userId, pageReqVO.getSceneType(), pageReqVO.getPool()); | 34 | userId, pageReqVO.getSceneType(), pageReqVO.getPool()); |
| 35 | - mpjLambdaWrapperX.selectAll(CrmBusinessDO.class) | 35 | + // 拼接自身的查询条件 |
| 36 | + query.selectAll(CrmBusinessDO.class) | ||
| 36 | .eqIfPresent(CrmBusinessDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号 | 37 | .eqIfPresent(CrmBusinessDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号 |
| 37 | .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) | 38 | .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) |
| 38 | .orderByDesc(CrmBusinessDO::getId); | 39 | .orderByDesc(CrmBusinessDO::getId); |
| 39 | - return selectJoinPage(pageReqVO, CrmBusinessDO.class, mpjLambdaWrapperX); | 40 | + return selectJoinPage(pageReqVO, CrmBusinessDO.class, query); |
| 40 | } | 41 | } |
| 41 | 42 | ||
| 42 | default List<CrmBusinessDO> selectBatchIds(Collection<Long> ids, Long userId) { | 43 | default List<CrmBusinessDO> selectBatchIds(Collection<Long> ids, Long userId) { |
| 43 | - MPJLambdaWrapperX<CrmBusinessDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); | ||
| 44 | - // 构建数据权限连表条件 | ||
| 45 | - CrmQueryWrapperUtils.builderListQueryBatch(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_BUSINESS.getType(), ids, userId); | ||
| 46 | - return selectJoinList(CrmBusinessDO.class, mpjLambdaWrapperX); | 44 | + MPJLambdaWrapperX<CrmBusinessDO> query = new MPJLambdaWrapperX<>(); |
| 45 | + // 拼接数据权限的查询条件 | ||
| 46 | + CrmQueryWrapperUtils.builderListQueryBatch(query, CrmBizTypeEnum.CRM_BUSINESS.getType(), ids, userId); | ||
| 47 | + return selectJoinList(CrmBusinessDO.class, query); | ||
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | } | 50 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java
| @@ -28,23 +28,24 @@ public interface CrmClueMapper extends BaseMapperX<CrmClueDO> { | @@ -28,23 +28,24 @@ public interface CrmClueMapper extends BaseMapperX<CrmClueDO> { | ||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | default PageResult<CrmClueDO> selectPage(CrmCluePageReqVO pageReqVO, Long userId) { | 30 | default PageResult<CrmClueDO> selectPage(CrmCluePageReqVO pageReqVO, Long userId) { |
| 31 | - MPJLambdaWrapperX<CrmClueDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); | ||
| 32 | - // 构建数据权限连表条件 | ||
| 33 | - CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_LEADS.getType(), CrmClueDO::getId, | 31 | + MPJLambdaWrapperX<CrmClueDO> query = new MPJLambdaWrapperX<>(); |
| 32 | + // 拼接数据权限的查询条件 | ||
| 33 | + CrmQueryWrapperUtils.builderPageQuery(query, CrmBizTypeEnum.CRM_LEADS.getType(), CrmClueDO::getId, | ||
| 34 | userId, pageReqVO.getSceneType(), pageReqVO.getPool()); | 34 | userId, pageReqVO.getSceneType(), pageReqVO.getPool()); |
| 35 | - mpjLambdaWrapperX.selectAll(CrmClueDO.class) | 35 | + // 拼接自身的查询条件 |
| 36 | + query.selectAll(CrmClueDO.class) | ||
| 36 | .likeIfPresent(CrmClueDO::getName, pageReqVO.getName()) | 37 | .likeIfPresent(CrmClueDO::getName, pageReqVO.getName()) |
| 37 | .likeIfPresent(CrmClueDO::getTelephone, pageReqVO.getTelephone()) | 38 | .likeIfPresent(CrmClueDO::getTelephone, pageReqVO.getTelephone()) |
| 38 | .likeIfPresent(CrmClueDO::getMobile, pageReqVO.getMobile()) | 39 | .likeIfPresent(CrmClueDO::getMobile, pageReqVO.getMobile()) |
| 39 | .orderByDesc(CrmClueDO::getId); | 40 | .orderByDesc(CrmClueDO::getId); |
| 40 | - return selectJoinPage(pageReqVO, CrmClueDO.class, mpjLambdaWrapperX); | 41 | + return selectJoinPage(pageReqVO, CrmClueDO.class, query); |
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | default List<CrmClueDO> selectBatchIds(Collection<Long> ids, Long userId) { | 44 | default List<CrmClueDO> selectBatchIds(Collection<Long> ids, Long userId) { |
| 44 | - MPJLambdaWrapperX<CrmClueDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); | ||
| 45 | - // 构建数据权限连表条件 | ||
| 46 | - CrmQueryWrapperUtils.builderListQueryBatch(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_LEADS.getType(), ids, userId); | ||
| 47 | - return selectJoinList(CrmClueDO.class, mpjLambdaWrapperX); | 45 | + MPJLambdaWrapperX<CrmClueDO> query = new MPJLambdaWrapperX<>(); |
| 46 | + // 拼接数据权限的查询条件 | ||
| 47 | + CrmQueryWrapperUtils.builderListQueryBatch(query, CrmBizTypeEnum.CRM_LEADS.getType(), ids, userId); | ||
| 48 | + return selectJoinList(CrmClueDO.class, query); | ||
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | } | 51 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java
| @@ -28,11 +28,12 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { | @@ -28,11 +28,12 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { | ||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | default PageResult<CrmContactDO> selectPage(CrmContactPageReqVO pageReqVO, Long userId) { | 30 | default PageResult<CrmContactDO> selectPage(CrmContactPageReqVO pageReqVO, Long userId) { |
| 31 | - MPJLambdaWrapperX<CrmContactDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); | ||
| 32 | - // 构建数据权限连表条件 | ||
| 33 | - CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), CrmContactDO::getId, | 31 | + MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>(); |
| 32 | + // 拼接数据权限的查询条件 | ||
| 33 | + CrmQueryWrapperUtils.builderPageQuery(query, CrmBizTypeEnum.CRM_CONTACT.getType(), CrmContactDO::getId, | ||
| 34 | userId, pageReqVO.getSceneType(), pageReqVO.getPool()); | 34 | userId, pageReqVO.getSceneType(), pageReqVO.getPool()); |
| 35 | - mpjLambdaWrapperX.selectAll(CrmContactDO.class) | 35 | + // 拼接自身的查询条件 |
| 36 | + query.selectAll(CrmContactDO.class) | ||
| 36 | .eqIfPresent(CrmContactDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号 | 37 | .eqIfPresent(CrmContactDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号 |
| 37 | .likeIfPresent(CrmContactDO::getName, pageReqVO.getName()) | 38 | .likeIfPresent(CrmContactDO::getName, pageReqVO.getName()) |
| 38 | .eqIfPresent(CrmContactDO::getMobile, pageReqVO.getMobile()) | 39 | .eqIfPresent(CrmContactDO::getMobile, pageReqVO.getMobile()) |
| @@ -41,14 +42,14 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { | @@ -41,14 +42,14 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { | ||
| 41 | .eqIfPresent(CrmContactDO::getQq, pageReqVO.getQq()) | 42 | .eqIfPresent(CrmContactDO::getQq, pageReqVO.getQq()) |
| 42 | .eqIfPresent(CrmContactDO::getWechat, pageReqVO.getWechat()) | 43 | .eqIfPresent(CrmContactDO::getWechat, pageReqVO.getWechat()) |
| 43 | .orderByDesc(CrmContactDO::getId); | 44 | .orderByDesc(CrmContactDO::getId); |
| 44 | - return selectJoinPage(pageReqVO, CrmContactDO.class, mpjLambdaWrapperX); | 45 | + return selectJoinPage(pageReqVO, CrmContactDO.class, query); |
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | default List<CrmContactDO> selectBatchIds(Collection<Long> ids, Long userId) { | 48 | default List<CrmContactDO> selectBatchIds(Collection<Long> ids, Long userId) { |
| 48 | - MPJLambdaWrapperX<CrmContactDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); | ||
| 49 | - // 构建数据权限连表条件 | ||
| 50 | - CrmQueryWrapperUtils.builderListQueryBatch(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, userId); | ||
| 51 | - return selectJoinList(CrmContactDO.class, mpjLambdaWrapperX); | 49 | + MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>(); |
| 50 | + // 拼接数据权限的查询条件 | ||
| 51 | + CrmQueryWrapperUtils.builderListQueryBatch(query, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, userId); | ||
| 52 | + return selectJoinList(CrmContactDO.class, query); | ||
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | } | 55 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java
| @@ -28,24 +28,25 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | @@ -28,24 +28,25 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | ||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO pageReqVO, Long userId) { | 30 | default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO pageReqVO, Long userId) { |
| 31 | - MPJLambdaWrapperX<CrmCustomerDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); | ||
| 32 | - // 构建数据权限连表条件 | ||
| 33 | - CrmQueryWrapperUtils.builderPageQuery(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CUSTOMER.getType(), CrmCustomerDO::getId, | 31 | + MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>(); |
| 32 | + // 拼接数据权限的查询条件 | ||
| 33 | + CrmQueryWrapperUtils.builderPageQuery(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), CrmCustomerDO::getId, | ||
| 34 | userId, pageReqVO.getSceneType(), pageReqVO.getPool()); | 34 | userId, pageReqVO.getSceneType(), pageReqVO.getPool()); |
| 35 | - mpjLambdaWrapperX.selectAll(CrmCustomerDO.class) | 35 | + // 拼接自身的查询条件 |
| 36 | + query.selectAll(CrmCustomerDO.class) | ||
| 36 | .likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName()) | 37 | .likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName()) |
| 37 | .eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile()) | 38 | .eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile()) |
| 38 | .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId()) | 39 | .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId()) |
| 39 | .eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel()) | 40 | .eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel()) |
| 40 | .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource()); | 41 | .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource()); |
| 41 | - return selectJoinPage(pageReqVO, CrmCustomerDO.class, mpjLambdaWrapperX); | 42 | + return selectJoinPage(pageReqVO, CrmCustomerDO.class, query); |
| 42 | } | 43 | } |
| 43 | 44 | ||
| 44 | default List<CrmCustomerDO> selectBatchIds(Collection<Long> ids, Long userId) { | 45 | default List<CrmCustomerDO> selectBatchIds(Collection<Long> ids, Long userId) { |
| 45 | - MPJLambdaWrapperX<CrmCustomerDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); | ||
| 46 | - // 构建数据权限连表条件 | ||
| 47 | - CrmQueryWrapperUtils.builderListQueryBatch(mpjLambdaWrapperX, CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, userId); | ||
| 48 | - return selectJoinList(CrmCustomerDO.class, mpjLambdaWrapperX); | 46 | + MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>(); |
| 47 | + // 拼接数据权限的查询条件 | ||
| 48 | + CrmQueryWrapperUtils.builderListQueryBatch(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, userId); | ||
| 49 | + return selectJoinList(CrmCustomerDO.class, query); | ||
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | } | 52 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| @@ -112,9 +112,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -112,9 +112,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 112 | 112 | ||
| 113 | @Override | 113 | @Override |
| 114 | public PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmBusinessPageReqVO pageReqVO, Long userId) { | 114 | public PageResult<CrmBusinessDO> getBusinessPageByCustomer(CrmBusinessPageReqVO pageReqVO, Long userId) { |
| 115 | - // 校验客户存在 | 115 | + // 校验客户存在 TODO @puhui999:这里不校验 |
| 116 | customerService.validateCustomer(pageReqVO.getCustomerId()); | 116 | customerService.validateCustomer(pageReqVO.getCustomerId()); |
| 117 | - | 117 | + // TODO @puhui999:感觉这里貌似不太复用用 selectPage,因为他可能没商机权限,只是因为能看 customer,所以可以看到列表 |
| 118 | return businessMapper.selectPage(pageReqVO, userId); | 118 | return businessMapper.selectPage(pageReqVO, userId); |
| 119 | } | 119 | } |
| 120 | 120 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java
| @@ -35,6 +35,7 @@ public class CrmClueServiceImpl implements CrmClueService { | @@ -35,6 +35,7 @@ public class CrmClueServiceImpl implements CrmClueService { | ||
| 35 | 35 | ||
| 36 | @Resource | 36 | @Resource |
| 37 | private CrmClueMapper clueMapper; | 37 | private CrmClueMapper clueMapper; |
| 38 | + | ||
| 38 | @Resource | 39 | @Resource |
| 39 | private CrmCustomerService customerService; | 40 | private CrmCustomerService customerService; |
| 40 | @Resource | 41 | @Resource |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
| @@ -137,7 +137,7 @@ public class CrmContactServiceImpl implements CrmContactService { | @@ -137,7 +137,7 @@ public class CrmContactServiceImpl implements CrmContactService { | ||
| 137 | public PageResult<CrmContactDO> getContactPageByCustomerId(CrmContactPageReqVO pageVO, Long userId) { | 137 | public PageResult<CrmContactDO> getContactPageByCustomerId(CrmContactPageReqVO pageVO, Long userId) { |
| 138 | // 校验用户存在 | 138 | // 校验用户存在 |
| 139 | customerService.validateCustomer(pageVO.getCustomerId()); | 139 | customerService.validateCustomer(pageVO.getCustomerId()); |
| 140 | - | 140 | + // TODO @puhui999:getBusinessPageByCustomer 同理 |
| 141 | return contactMapper.selectPage(pageVO, userId); | 141 | return contactMapper.selectPage(pageVO, userId); |
| 142 | } | 142 | } |
| 143 | 143 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java
| @@ -126,9 +126,9 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { | @@ -126,9 +126,9 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { | ||
| 126 | @Override | 126 | @Override |
| 127 | @Transactional(rollbackFor = Exception.class) | 127 | @Transactional(rollbackFor = Exception.class) |
| 128 | public void deletePermission(Integer bizType, Long bizId, Integer level) { | 128 | public void deletePermission(Integer bizType, Long bizId, Integer level) { |
| 129 | + // 校验存在 | ||
| 129 | List<CrmPermissionDO> permissions = crmPermissionMapper.selectListByBizTypeAndBizIdAndLevel( | 130 | List<CrmPermissionDO> permissions = crmPermissionMapper.selectListByBizTypeAndBizIdAndLevel( |
| 130 | bizType, bizId, level); | 131 | bizType, bizId, level); |
| 131 | - // 校验存在 | ||
| 132 | if (CollUtil.isEmpty(permissions)) { | 132 | if (CollUtil.isEmpty(permissions)) { |
| 133 | throw exception(CRM_PERMISSION_NOT_EXISTS); | 133 | throw exception(CRM_PERMISSION_NOT_EXISTS); |
| 134 | } | 134 | } |
| @@ -139,6 +139,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { | @@ -139,6 +139,7 @@ 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:这种直接写条件删除;不需要先查询,再删除 | ||
| 142 | List<CrmPermissionDO> permissionList = crmPermissionMapper.selectByBizTypeAndBizId(bizType, bizId); | 143 | List<CrmPermissionDO> permissionList = crmPermissionMapper.selectByBizTypeAndBizId(bizType, bizId); |
| 143 | if (CollUtil.isEmpty(permissionList)) { | 144 | if (CollUtil.isEmpty(permissionList)) { |
| 144 | return; | 145 | return; |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmQueryWrapperUtils.java
| @@ -26,67 +26,74 @@ public class CrmQueryWrapperUtils { | @@ -26,67 +26,74 @@ public class CrmQueryWrapperUtils { | ||
| 26 | /** | 26 | /** |
| 27 | * 构造 CRM 数据类型数据分页查询条件 | 27 | * 构造 CRM 数据类型数据分页查询条件 |
| 28 | * | 28 | * |
| 29 | - * @param queryMapper 连表查询对象 | 29 | + * @param query 连表查询对象 |
| 30 | * @param bizType 数据类型 {@link CrmBizTypeEnum} | 30 | * @param bizType 数据类型 {@link CrmBizTypeEnum} |
| 31 | * @param bizId 数据编号 | 31 | * @param bizId 数据编号 |
| 32 | * @param userId 用户编号 | 32 | * @param userId 用户编号 |
| 33 | * @param sceneType 场景类型 | 33 | * @param sceneType 场景类型 |
| 34 | * @param pool 公海 | 34 | * @param pool 公海 |
| 35 | */ | 35 | */ |
| 36 | - public static <T extends MPJLambdaWrapper<?>, S> void builderPageQuery( | ||
| 37 | - T queryMapper, Integer bizType, SFunction<S, ?> bizId, Long userId, Integer sceneType, Boolean pool) { | 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) { | ||
| 38 | // 1. 构建数据权限连表条件 | 40 | // 1. 构建数据权限连表条件 |
| 39 | if (ObjUtil.notEqual(validateAdminUser(userId), Boolean.TRUE)) { // 管理员不需要数据权限 | 41 | if (ObjUtil.notEqual(validateAdminUser(userId), Boolean.TRUE)) { // 管理员不需要数据权限 |
| 40 | - queryMapper.innerJoin(CrmPermissionDO.class, on -> | 42 | + query.innerJoin(CrmPermissionDO.class, on -> |
| 41 | on.eq(CrmPermissionDO::getBizType, bizType).eq(CrmPermissionDO::getBizId, bizId) | 43 | on.eq(CrmPermissionDO::getBizType, bizType).eq(CrmPermissionDO::getBizId, bizId) |
| 42 | .eq(CrmPermissionDO::getUserId, userId)); | 44 | .eq(CrmPermissionDO::getUserId, userId)); |
| 43 | } | 45 | } |
| 44 | - // 1.2 场景一:我负责的数据 | 46 | + // 2.1 场景一:我负责的数据 |
| 45 | if (CrmSceneTypeEnum.isOwner(sceneType)) { | 47 | if (CrmSceneTypeEnum.isOwner(sceneType)) { |
| 46 | - queryMapper.eq("owner_user_id", userId); | 48 | + query.eq("owner_user_id", userId); |
| 47 | } | 49 | } |
| 48 | - // 1.3 场景一:我参与的数据 | 50 | + // 2.2 场景二:我参与的数据 |
| 51 | + // TODO @puhui999:参与,指的是有读写权限噢;可以把 1. 的合并到 2.2 里;因为 2.1 不需要; | ||
| 49 | if (CrmSceneTypeEnum.isInvolved(sceneType)) { | 52 | if (CrmSceneTypeEnum.isInvolved(sceneType)) { |
| 50 | - queryMapper.ne("owner_user_id", userId); | 53 | + query.ne("owner_user_id", userId); |
| 51 | } | 54 | } |
| 52 | - // 1.4 场景二:下属负责的数据 | 55 | + // 2.3 场景三:下属负责的数据 |
| 53 | if (CrmSceneTypeEnum.isSubordinate(sceneType)) { | 56 | if (CrmSceneTypeEnum.isSubordinate(sceneType)) { |
| 54 | List<AdminUserRespDTO> subordinateUsers = getAdminUserApi().getUserListBySubordinate(userId); | 57 | List<AdminUserRespDTO> subordinateUsers = getAdminUserApi().getUserListBySubordinate(userId); |
| 58 | + // TODO @puhui999:如果为空,不拼接,就是查询了所有数据呀? | ||
| 55 | if (CollUtil.isNotEmpty(subordinateUsers)) { | 59 | if (CollUtil.isNotEmpty(subordinateUsers)) { |
| 56 | - queryMapper.in("owner_user_id", convertSet(subordinateUsers, AdminUserRespDTO::getId)); | 60 | + query.in("owner_user_id", convertSet(subordinateUsers, AdminUserRespDTO::getId)); |
| 57 | } | 61 | } |
| 58 | } | 62 | } |
| 59 | 63 | ||
| 60 | // 2. 拼接公海的查询条件 | 64 | // 2. 拼接公海的查询条件 |
| 61 | if (ObjUtil.equal(pool, Boolean.TRUE)) { // 情况一:公海 | 65 | if (ObjUtil.equal(pool, Boolean.TRUE)) { // 情况一:公海 |
| 62 | - queryMapper.isNull("owner_user_id"); | 66 | + query.isNull("owner_user_id"); |
| 63 | } else { // 情况二:不是公海 | 67 | } else { // 情况二:不是公海 |
| 64 | - queryMapper.isNotNull("owner_user_id"); | 68 | + query.isNotNull("owner_user_id"); |
| 65 | } | 69 | } |
| 66 | } | 70 | } |
| 67 | 71 | ||
| 68 | /** | 72 | /** |
| 69 | * 构造 CRM 数据类型批量数据查询条件 | 73 | * 构造 CRM 数据类型批量数据查询条件 |
| 70 | * | 74 | * |
| 71 | - * @param queryMapper 连表查询对象 | 75 | + * @param query 连表查询对象 |
| 72 | * @param bizType 数据类型 {@link CrmBizTypeEnum} | 76 | * @param bizType 数据类型 {@link CrmBizTypeEnum} |
| 73 | * @param bizIds 数据编号 | 77 | * @param bizIds 数据编号 |
| 74 | * @param userId 用户编号 | 78 | * @param userId 用户编号 |
| 75 | */ | 79 | */ |
| 76 | - public static <T extends MPJLambdaWrapper<?>, S> void builderListQueryBatch( | ||
| 77 | - T queryMapper, Integer bizType, Collection<Long> bizIds, Long userId) { | ||
| 78 | - // 1. 构建数据权限连表条件 | 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 简单点 | ||
| 79 | if (ObjUtil.notEqual(validateAdminUser(userId), Boolean.TRUE)) { // 管理员不需要数据权限 | 84 | if (ObjUtil.notEqual(validateAdminUser(userId), Boolean.TRUE)) { // 管理员不需要数据权限 |
| 80 | - queryMapper.innerJoin(CrmPermissionDO.class, on -> | 85 | + query.innerJoin(CrmPermissionDO.class, on -> |
| 81 | on.eq(CrmPermissionDO::getBizType, bizType).in(CrmPermissionDO::getBizId, bizIds) | 86 | on.eq(CrmPermissionDO::getBizType, bizType).in(CrmPermissionDO::getBizId, bizIds) |
| 82 | .in(CollUtil.isNotEmpty(bizIds), CrmPermissionDO::getUserId, userId)); | 87 | .in(CollUtil.isNotEmpty(bizIds), CrmPermissionDO::getUserId, userId)); |
| 83 | } | 88 | } |
| 84 | } | 89 | } |
| 85 | 90 | ||
| 91 | + // TODO @puhui999:需要加个变量,不用每次都拿哈; | ||
| 86 | private static AdminUserApi getAdminUserApi() { | 92 | private static AdminUserApi getAdminUserApi() { |
| 87 | return SpringUtil.getBean(AdminUserApi.class); | 93 | return SpringUtil.getBean(AdminUserApi.class); |
| 88 | } | 94 | } |
| 89 | 95 | ||
| 96 | + // TODO @puhui999:需要实现; | ||
| 90 | /** | 97 | /** |
| 91 | * 校验用户是否是管理员 | 98 | * 校验用户是否是管理员 |
| 92 | * | 99 | * |
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java
| @@ -22,7 +22,6 @@ public interface AdminUserApi { | @@ -22,7 +22,6 @@ public interface AdminUserApi { | ||
| 22 | */ | 22 | */ |
| 23 | AdminUserRespDTO getUser(Long id); | 23 | AdminUserRespDTO getUser(Long id); |
| 24 | 24 | ||
| 25 | - // TODO @puhui999:这里返回 List<AdminUserRespDTO> 方法名可以改成 getUserListBySubordinate | ||
| 26 | /** | 25 | /** |
| 27 | * 通过用户 ID 查询用户下属 | 26 | * 通过用户 ID 查询用户下属 |
| 28 | * | 27 | * |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java
| @@ -39,13 +39,11 @@ public class AdminUserApiImpl implements AdminUserApi { | @@ -39,13 +39,11 @@ public class AdminUserApiImpl implements AdminUserApi { | ||
| 39 | 39 | ||
| 40 | @Override | 40 | @Override |
| 41 | public List<AdminUserRespDTO> getUserListBySubordinate(Long userId) { | 41 | public List<AdminUserRespDTO> getUserListBySubordinate(Long userId) { |
| 42 | - // 1. 获取用户信息 | 42 | + // 1.1 获取用户负责的部门 |
| 43 | AdminUserDO user = userService.getUser(userId); | 43 | AdminUserDO user = userService.getUser(userId); |
| 44 | if (user == null) { | 44 | if (user == null) { |
| 45 | return Collections.emptyList(); | 45 | return Collections.emptyList(); |
| 46 | } | 46 | } |
| 47 | - | ||
| 48 | - // 2.1 获取用户负责的部门 | ||
| 49 | ArrayList<Long> deptIds = new ArrayList<>(); | 47 | ArrayList<Long> deptIds = new ArrayList<>(); |
| 50 | DeptDO dept = deptService.getDept(user.getDeptId()); | 48 | DeptDO dept = deptService.getDept(user.getDeptId()); |
| 51 | if (dept == null) { | 49 | if (dept == null) { |
| @@ -54,13 +52,14 @@ public class AdminUserApiImpl implements AdminUserApi { | @@ -54,13 +52,14 @@ public class AdminUserApiImpl implements AdminUserApi { | ||
| 54 | if (ObjUtil.notEqual(dept.getLeaderUserId(), userId)) { // 校验为负责人 | 52 | if (ObjUtil.notEqual(dept.getLeaderUserId(), userId)) { // 校验为负责人 |
| 55 | return Collections.emptyList(); | 53 | return Collections.emptyList(); |
| 56 | } | 54 | } |
| 57 | - deptIds.add(dept.getId()); // 加入此部门 | ||
| 58 | - // 2.2 获取所有子部门 | 55 | + deptIds.add(dept.getId()); |
| 56 | + // 1.2 获取所有子部门 | ||
| 59 | List<DeptDO> childDeptList = deptService.getChildDeptList(dept.getId()); | 57 | List<DeptDO> childDeptList = deptService.getChildDeptList(dept.getId()); |
| 60 | if (CollUtil.isNotEmpty(childDeptList)) { | 58 | if (CollUtil.isNotEmpty(childDeptList)) { |
| 61 | deptIds.addAll(convertSet(childDeptList, DeptDO::getId)); | 59 | deptIds.addAll(convertSet(childDeptList, DeptDO::getId)); |
| 62 | } | 60 | } |
| 63 | - // 2.3 获取用户信息 | 61 | + |
| 62 | + // 2. 获取部门对应的用户信息 | ||
| 64 | List<AdminUserDO> users = userService.getUserListByDeptIds(deptIds); | 63 | List<AdminUserDO> users = userService.getUserListByDeptIds(deptIds); |
| 65 | users.removeIf(item -> ObjUtil.equal(item.getId(), userId)); // 排除自己 | 64 | users.removeIf(item -> ObjUtil.equal(item.getId(), userId)); // 排除自己 |
| 66 | return BeanUtils.toBean(users, AdminUserRespDTO.class); | 65 | return BeanUtils.toBean(users, AdminUserRespDTO.class); |
yudao-server/pom.xml
| @@ -37,11 +37,11 @@ | @@ -37,11 +37,11 @@ | ||
| 37 | </dependency> | 37 | </dependency> |
| 38 | 38 | ||
| 39 | <!-- 会员中心。默认注释,保证编译速度 --> | 39 | <!-- 会员中心。默认注释,保证编译速度 --> |
| 40 | -<!-- <dependency>--> | ||
| 41 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 42 | -<!-- <artifactId>yudao-module-member-biz</artifactId>--> | ||
| 43 | -<!-- <version>${revision}</version>--> | ||
| 44 | -<!-- </dependency>--> | 40 | + <dependency> |
| 41 | + <groupId>cn.iocoder.boot</groupId> | ||
| 42 | + <artifactId>yudao-module-member-biz</artifactId> | ||
| 43 | + <version>${revision}</version> | ||
| 44 | + </dependency> | ||
| 45 | 45 | ||
| 46 | <!-- 数据报表。默认注释,保证编译速度 --> | 46 | <!-- 数据报表。默认注释,保证编译速度 --> |
| 47 | <!-- <dependency>--> | 47 | <!-- <dependency>--> |
| @@ -56,11 +56,11 @@ | @@ -56,11 +56,11 @@ | ||
| 56 | <!-- <version>${revision}</version>--> | 56 | <!-- <version>${revision}</version>--> |
| 57 | <!-- </dependency>--> | 57 | <!-- </dependency>--> |
| 58 | <!-- 支付服务。默认注释,保证编译速度 --> | 58 | <!-- 支付服务。默认注释,保证编译速度 --> |
| 59 | -<!-- <dependency>--> | ||
| 60 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 61 | -<!-- <artifactId>yudao-module-pay-biz</artifactId>--> | ||
| 62 | -<!-- <version>${revision}</version>--> | ||
| 63 | -<!-- </dependency>--> | 59 | + <dependency> |
| 60 | + <groupId>cn.iocoder.boot</groupId> | ||
| 61 | + <artifactId>yudao-module-pay-biz</artifactId> | ||
| 62 | + <version>${revision}</version> | ||
| 63 | + </dependency> | ||
| 64 | 64 | ||
| 65 | <!-- 微信公众号模块。默认注释,保证编译速度 --> | 65 | <!-- 微信公众号模块。默认注释,保证编译速度 --> |
| 66 | <!-- <dependency>--> | 66 | <!-- <dependency>--> |
| @@ -70,26 +70,26 @@ | @@ -70,26 +70,26 @@ | ||
| 70 | <!-- </dependency>--> | 70 | <!-- </dependency>--> |
| 71 | 71 | ||
| 72 | <!-- 商城相关模块。默认注释,保证编译速度--> | 72 | <!-- 商城相关模块。默认注释,保证编译速度--> |
| 73 | -<!-- <dependency>--> | ||
| 74 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 75 | -<!-- <artifactId>yudao-module-promotion-biz</artifactId>--> | ||
| 76 | -<!-- <version>${revision}</version>--> | ||
| 77 | -<!-- </dependency>--> | ||
| 78 | -<!-- <dependency>--> | ||
| 79 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 80 | -<!-- <artifactId>yudao-module-product-biz</artifactId>--> | ||
| 81 | -<!-- <version>${revision}</version>--> | ||
| 82 | -<!-- </dependency>--> | ||
| 83 | -<!-- <dependency>--> | ||
| 84 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 85 | -<!-- <artifactId>yudao-module-trade-biz</artifactId>--> | ||
| 86 | -<!-- <version>${revision}</version>--> | ||
| 87 | -<!-- </dependency>--> | ||
| 88 | -<!-- <dependency>--> | ||
| 89 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 90 | -<!-- <artifactId>yudao-module-statistics-biz</artifactId>--> | ||
| 91 | -<!-- <version>${revision}</version>--> | ||
| 92 | -<!-- </dependency>--> | 73 | + <dependency> |
| 74 | + <groupId>cn.iocoder.boot</groupId> | ||
| 75 | + <artifactId>yudao-module-promotion-biz</artifactId> | ||
| 76 | + <version>${revision}</version> | ||
| 77 | + </dependency> | ||
| 78 | + <dependency> | ||
| 79 | + <groupId>cn.iocoder.boot</groupId> | ||
| 80 | + <artifactId>yudao-module-product-biz</artifactId> | ||
| 81 | + <version>${revision}</version> | ||
| 82 | + </dependency> | ||
| 83 | + <dependency> | ||
| 84 | + <groupId>cn.iocoder.boot</groupId> | ||
| 85 | + <artifactId>yudao-module-trade-biz</artifactId> | ||
| 86 | + <version>${revision}</version> | ||
| 87 | + </dependency> | ||
| 88 | + <dependency> | ||
| 89 | + <groupId>cn.iocoder.boot</groupId> | ||
| 90 | + <artifactId>yudao-module-statistics-biz</artifactId> | ||
| 91 | + <version>${revision}</version> | ||
| 92 | + </dependency> | ||
| 93 | 93 | ||
| 94 | <!-- CRM 相关模块。默认注释,保证编译速度 --> | 94 | <!-- CRM 相关模块。默认注释,保证编译速度 --> |
| 95 | <dependency> | 95 | <dependency> |