From 6c536caad40a74e25ddad516764317982c0a5d50 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 27 Nov 2023 21:47:56 +0800 Subject: [PATCH] =?UTF-8?q?crm=EF=BC=9A=E5=AE=8C=E5=96=84=20code=20review?= =?UTF-8?q?=20=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90=E6=8F=90=E5=88=B0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/customer/CrmCustomerController.java | 6 ++---- .../admin/permission/CrmPermissionController.java | 2 +- .../crm/service/customer/CrmCustomerServiceImpl.java | 8 +++++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java index 0da8f8fbf..61489f7e6 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java +++ b/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; import java.util.stream.Stream; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @@ -115,7 +116,7 @@ public class CrmCustomerController { @OperateLog(type = EXPORT) public void exportCustomerExcel(@Valid CrmCustomerPageReqVO pageVO, HttpServletResponse response) throws IOException { - // TODO @puhui999:看看复用 getCustomerPage 方法;然后可以禁用下分页; + pageVO.setPageSize(PAGE_SIZE_NONE); // 不分页 List list = customerService.getCustomerPage(pageVO, getLoginUserId()).getList(); // 导出 Excel List datas = CrmCustomerConvert.INSTANCE.convertList02(list); @@ -168,9 +169,6 @@ public class CrmCustomerController { @PreAuthorize("@ss.hasPermission('crm:customer:distribute')") public CommonResult distributeCustomer(@RequestParam(value = "ids") List ids, @RequestParam(value = "ownerUserId") Long ownerUserId) { - // 校验负责人是否存在 - // TODO @puhui999:这个校验,是不是可以收到 validateUserList - adminUserApi.validateUserList(singletonList(ownerUserId)); // 领取公海数据 customerService.receiveCustomer(ids, ownerUserId); return success(true); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java index 2d593c7ce..10b188fbb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java +++ b/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 { @DeleteMapping("/delete-self") @Operation(summary = "删除自己的数据权限") @Parameter(name = "id", description = "数据权限编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:permission:delete')") // TODO puhui999: 数据权限在页面上只是已团队成员组件的形式出现,那么这个权限怎么分配? + @PreAuthorize("@ss.hasPermission('crm:permission:delete')") public CommonResult deleteSelfPermission(@RequestParam("id") Long id) { permissionService.deleteSelfPermission(id, getLoginUserId()); return success(true); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java index 925215c23..bb389ac20 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ b/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; import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; @@ -25,6 +26,7 @@ import java.util.Objects; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; +import static java.util.Collections.singletonList; /** * 客户 Service 实现类 @@ -40,6 +42,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @Resource private CrmPermissionService crmPermissionService; + @Resource + private AdminUserApi adminUserApi; @Override @Transactional(rollbackFor = Exception.class) @@ -174,7 +178,9 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { if (customers.size() != ids.size()) { throw exception(CUSTOMER_NOT_EXISTS); } - // 1.2. 校验状态 + // 1.2. 校验负责人是否存在 + adminUserApi.validateUserList(singletonList(ownerUserId)); + // 1.3. 校验状态 customers.forEach(customer -> { // 校验是否已有负责人 validateCustomerOwnerExists(customer, false);