Commit 6f882ca24e872ca311cfa17aff3b6909bfe7729a
Committed by
Gitee
!762 crm:完善 code review 数据权限提到的问题
Merge pull request !762 from puhui999/feature/crm
Showing
6 changed files
with
55 additions
and
47 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
| ... | ... | @@ -31,6 +31,7 @@ import java.util.Map; |
| 31 | 31 | import java.util.stream.Stream; |
| 32 | 32 | |
| 33 | 33 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 34 | +import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; | |
| 34 | 35 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 35 | 36 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; |
| 36 | 37 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| ... | ... | @@ -115,7 +116,7 @@ public class CrmCustomerController { |
| 115 | 116 | @OperateLog(type = EXPORT) |
| 116 | 117 | public void exportCustomerExcel(@Valid CrmCustomerPageReqVO pageVO, |
| 117 | 118 | HttpServletResponse response) throws IOException { |
| 118 | - // TODO @puhui999:看看复用 getCustomerPage 方法;然后可以禁用下分页; | |
| 119 | + pageVO.setPageSize(PAGE_SIZE_NONE); // 不分页 | |
| 119 | 120 | List<CrmCustomerDO> list = customerService.getCustomerPage(pageVO, getLoginUserId()).getList(); |
| 120 | 121 | // 导出 Excel |
| 121 | 122 | List<CrmCustomerExcelVO> datas = CrmCustomerConvert.INSTANCE.convertList02(list); |
| ... | ... | @@ -168,9 +169,6 @@ public class CrmCustomerController { |
| 168 | 169 | @PreAuthorize("@ss.hasPermission('crm:customer:distribute')") |
| 169 | 170 | public CommonResult<Boolean> distributeCustomer(@RequestParam(value = "ids") List<Long> ids, |
| 170 | 171 | @RequestParam(value = "ownerUserId") Long ownerUserId) { |
| 171 | - // 校验负责人是否存在 | |
| 172 | - // TODO @puhui999:这个校验,是不是可以收到 validateUserList | |
| 173 | - adminUserApi.validateUserList(singletonList(ownerUserId)); | |
| 174 | 172 | // 领取公海数据 |
| 175 | 173 | customerService.receiveCustomer(ids, ownerUserId); |
| 176 | 174 | return success(true); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java
| ... | ... | @@ -80,7 +80,7 @@ public class CrmPermissionController { |
| 80 | 80 | @DeleteMapping("/delete-self") |
| 81 | 81 | @Operation(summary = "删除自己的数据权限") |
| 82 | 82 | @Parameter(name = "id", description = "数据权限编号", required = true, example = "1024") |
| 83 | - @PreAuthorize("@ss.hasPermission('crm:permission:delete')") // TODO puhui999: 数据权限在页面上只是已团队成员组件的形式出现,那么这个权限怎么分配? | |
| 83 | + @PreAuthorize("@ss.hasPermission('crm:permission:delete')") | |
| 84 | 84 | public CommonResult<Boolean> deleteSelfPermission(@RequestParam("id") Long id) { |
| 85 | 85 | permissionService.deleteSelfPermission(id, getLoginUserId()); |
| 86 | 86 | return success(true); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java
| ... | ... | @@ -25,47 +25,25 @@ import java.util.List; |
| 25 | 25 | @Mapper |
| 26 | 26 | public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { |
| 27 | 27 | |
| 28 | - static void appendQueryParams(MPJLambdaWrapperX<CrmCustomerDO> mpjLambdaWrapperX, CrmCustomerPageReqVO pageReqVO, Long userId) { | |
| 29 | - if (pageReqVO.getPool()) { // 情况一:公海 | |
| 30 | - mpjLambdaWrapperX.isNull(CrmCustomerDO::getOwnerUserId); | |
| 31 | - } else { // 情况二:不是公海 | |
| 32 | - mpjLambdaWrapperX.isNotNull(CrmCustomerDO::getOwnerUserId); | |
| 33 | - } | |
| 34 | - // TODO 场景数据过滤 | |
| 35 | - if (CrmSceneEnum.isOwner(pageReqVO.getSceneType())) { // 场景一:我负责的数据 | |
| 36 | - mpjLambdaWrapperX.eq(CrmCustomerDO::getOwnerUserId, userId); | |
| 37 | - } | |
| 38 | - } | |
| 39 | - | |
| 40 | - static void appendQueryParams(LambdaQueryWrapperX<CrmCustomerDO> lambdaQueryWrapperX, CrmCustomerPageReqVO pageReqVO, Long userId) { | |
| 41 | - if (pageReqVO.getPool()) { // 情况一:公海 | |
| 42 | - lambdaQueryWrapperX.isNull(CrmCustomerDO::getOwnerUserId); | |
| 43 | - } else { // 情况二:不是公海 | |
| 44 | - lambdaQueryWrapperX.isNotNull(CrmCustomerDO::getOwnerUserId); | |
| 45 | - } | |
| 46 | - // TODO 场景数据过滤 | |
| 47 | - if (CrmSceneEnum.isOwner(pageReqVO.getSceneType())) { // 场景一:我负责的数据 | |
| 48 | - lambdaQueryWrapperX.eq(CrmCustomerDO::getOwnerUserId, userId); | |
| 49 | - } | |
| 50 | - } | |
| 51 | - | |
| 52 | 28 | default int updateOwnerUserIdById(Long id, Long ownerUserId) { |
| 53 | 29 | return update(new LambdaUpdateWrapper<CrmCustomerDO>() |
| 54 | 30 | .eq(CrmCustomerDO::getId, id) |
| 55 | 31 | .set(CrmCustomerDO::getOwnerUserId, ownerUserId)); |
| 56 | 32 | } |
| 57 | 33 | |
| 58 | - default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO pageReqVO, Long userId, Boolean admin) { | |
| 59 | - if (admin) { // 情况一:管理员查看 | |
| 60 | - LambdaQueryWrapperX<CrmCustomerDO> queryWrapperX = new LambdaQueryWrapperX<>(); | |
| 61 | - appendQueryParams(queryWrapperX, pageReqVO, userId); | |
| 62 | - return selectPage(pageReqVO, queryWrapperX | |
| 63 | - .likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName()) | |
| 64 | - .eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile()) | |
| 65 | - .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId()) | |
| 66 | - .eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel()) | |
| 67 | - .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource())); | |
| 68 | - } | |
| 34 | + default PageResult<CrmCustomerDO> selectPageWithAdmin(CrmCustomerPageReqVO pageReqVO, Long userId) { | |
| 35 | + // 情况一:管理员查看 | |
| 36 | + LambdaQueryWrapperX<CrmCustomerDO> queryWrapperX = new LambdaQueryWrapperX<>(); | |
| 37 | + appendQueryParams(queryWrapperX, pageReqVO, userId); | |
| 38 | + return selectPage(pageReqVO, queryWrapperX | |
| 39 | + .likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName()) | |
| 40 | + .eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile()) | |
| 41 | + .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId()) | |
| 42 | + .eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel()) | |
| 43 | + .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource())); | |
| 44 | + } | |
| 45 | + | |
| 46 | + default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO pageReqVO, Long userId) { | |
| 69 | 47 | // 情况二:获取当前用户能看的分页数据 |
| 70 | 48 | IPage<CrmCustomerDO> mpPage = MyBatisUtils.buildPage(pageReqVO); |
| 71 | 49 | MPJLambdaWrapperX<CrmCustomerDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); |
| ... | ... | @@ -91,4 +69,28 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { |
| 91 | 69 | return new PageResult<>(mpPage.getRecords(), mpPage.getTotal()); |
| 92 | 70 | } |
| 93 | 71 | |
| 72 | + static void appendQueryParams(MPJLambdaWrapperX<CrmCustomerDO> mpjLambdaWrapperX, CrmCustomerPageReqVO pageReqVO, Long userId) { | |
| 73 | + if (pageReqVO.getPool()) { // 情况一:公海 | |
| 74 | + mpjLambdaWrapperX.isNull(CrmCustomerDO::getOwnerUserId); | |
| 75 | + } else { // 情况二:不是公海 | |
| 76 | + mpjLambdaWrapperX.isNotNull(CrmCustomerDO::getOwnerUserId); | |
| 77 | + } | |
| 78 | + // TODO 场景数据过滤 | |
| 79 | + if (CrmSceneEnum.isOwner(pageReqVO.getSceneType())) { // 场景一:我负责的数据 | |
| 80 | + mpjLambdaWrapperX.eq(CrmCustomerDO::getOwnerUserId, userId); | |
| 81 | + } | |
| 82 | + } | |
| 83 | + | |
| 84 | + static void appendQueryParams(LambdaQueryWrapperX<CrmCustomerDO> lambdaQueryWrapperX, CrmCustomerPageReqVO pageReqVO, Long userId) { | |
| 85 | + if (pageReqVO.getPool()) { // 情况一:公海 | |
| 86 | + lambdaQueryWrapperX.isNull(CrmCustomerDO::getOwnerUserId); | |
| 87 | + } else { // 情况二:不是公海 | |
| 88 | + lambdaQueryWrapperX.isNotNull(CrmCustomerDO::getOwnerUserId); | |
| 89 | + } | |
| 90 | + // TODO 场景数据过滤 | |
| 91 | + if (CrmSceneEnum.isOwner(pageReqVO.getSceneType())) { // 场景一:我负责的数据 | |
| 92 | + lambdaQueryWrapperX.eq(CrmCustomerDO::getOwnerUserId, userId); | |
| 93 | + } | |
| 94 | + } | |
| 95 | + | |
| 94 | 96 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| ... | ... | @@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum; |
| 13 | 13 | import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; |
| 14 | 14 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 15 | 15 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 16 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | |
| 16 | 17 | import org.springframework.stereotype.Service; |
| 17 | 18 | import org.springframework.transaction.annotation.Transactional; |
| 18 | 19 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -25,6 +26,7 @@ import java.util.Objects; |
| 25 | 26 | |
| 26 | 27 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 27 | 28 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; |
| 29 | +import static java.util.Collections.singletonList; | |
| 28 | 30 | |
| 29 | 31 | /** |
| 30 | 32 | * 客户 Service 实现类 |
| ... | ... | @@ -40,6 +42,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 40 | 42 | |
| 41 | 43 | @Resource |
| 42 | 44 | private CrmPermissionService crmPermissionService; |
| 45 | + @Resource | |
| 46 | + private AdminUserApi adminUserApi; | |
| 43 | 47 | |
| 44 | 48 | @Override |
| 45 | 49 | @Transactional(rollbackFor = Exception.class) |
| ... | ... | @@ -96,9 +100,12 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 96 | 100 | |
| 97 | 101 | @Override |
| 98 | 102 | public PageResult<CrmCustomerDO> getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId) { |
| 99 | - // 1.1. TODO 如果是超级管理员 | |
| 100 | 103 | boolean admin = false; |
| 101 | - return customerMapper.selectPage(pageReqVO, userId, admin); | |
| 104 | + if (admin) { // 1.1. 情况一: TODO 如果是管理员 | |
| 105 | + customerMapper.selectPageWithAdmin(pageReqVO, userId); | |
| 106 | + } | |
| 107 | + // 1.2. 情况二:获取当前用户能看的分页数据 | |
| 108 | + return customerMapper.selectPage(pageReqVO, userId); | |
| 102 | 109 | } |
| 103 | 110 | |
| 104 | 111 | /** |
| ... | ... | @@ -174,7 +181,9 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 174 | 181 | if (customers.size() != ids.size()) { |
| 175 | 182 | throw exception(CUSTOMER_NOT_EXISTS); |
| 176 | 183 | } |
| 177 | - // 1.2. 校验状态 | |
| 184 | + // 1.2. 校验负责人是否存在 | |
| 185 | + adminUserApi.validateUserList(singletonList(ownerUserId)); | |
| 186 | + // 1.3. 校验状态 | |
| 178 | 187 | customers.forEach(customer -> { |
| 179 | 188 | // 校验是否已有负责人 |
| 180 | 189 | validateCustomerOwnerExists(customer, false); | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java
| ... | ... | @@ -19,11 +19,10 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ |
| 19 | 19 | @ToString(callSuper = true) |
| 20 | 20 | public class BannerPageReqVO extends PageParam { |
| 21 | 21 | |
| 22 | - // TODO @puhui999:example | |
| 23 | - @Schema(description = "标题") | |
| 22 | + @Schema(description = "标题", example = "这是一个标题") | |
| 24 | 23 | private String title; |
| 25 | 24 | |
| 26 | - @Schema(description = "状态") | |
| 25 | + @Schema(description = "状态", example = "1") | |
| 27 | 26 | @InEnum(CommonStatusEnum.class) |
| 28 | 27 | private Integer status; |
| 29 | 28 | ... | ... |