Commit 6c536caad40a74e25ddad516764317982c0a5d50
1 parent
fd2af502
crm:完善 code review 数据权限提到的问题
Showing
3 changed files
with
10 additions
and
6 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/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) |
| ... | ... | @@ -174,7 +178,9 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 174 | 178 | if (customers.size() != ids.size()) { |
| 175 | 179 | throw exception(CUSTOMER_NOT_EXISTS); |
| 176 | 180 | } |
| 177 | - // 1.2. 校验状态 | |
| 181 | + // 1.2. 校验负责人是否存在 | |
| 182 | + adminUserApi.validateUserList(singletonList(ownerUserId)); | |
| 183 | + // 1.3. 校验状态 | |
| 178 | 184 | customers.forEach(customer -> { |
| 179 | 185 | // 校验是否已有负责人 |
| 180 | 186 | validateCustomerOwnerExists(customer, false); | ... | ... |