crm:完善 code review 数据权限提到的问题

This commit is contained in:
puhui999 2023-11-27 21:47:56 +08:00
parent fd2af50202
commit 6c536caad4
3 changed files with 10 additions and 6 deletions

View File

@ -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<CrmCustomerDO> list = customerService.getCustomerPage(pageVO, getLoginUserId()).getList();
// 导出 Excel
List<CrmCustomerExcelVO> datas = CrmCustomerConvert.INSTANCE.convertList02(list);
@ -168,9 +169,6 @@ public class CrmCustomerController {
@PreAuthorize("@ss.hasPermission('crm:customer:distribute')")
public CommonResult<Boolean> distributeCustomer(@RequestParam(value = "ids") List<Long> ids,
@RequestParam(value = "ownerUserId") Long ownerUserId) {
// 校验负责人是否存在
// TODO @puhui999这个校验是不是可以收到 validateUserList
adminUserApi.validateUserList(singletonList(ownerUserId));
// 领取公海数据
customerService.receiveCustomer(ids, ownerUserId);
return success(true);

View File

@ -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<Boolean> deleteSelfPermission(@RequestParam("id") Long id) {
permissionService.deleteSelfPermission(id, getLoginUserId());
return success(true);

View File

@ -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);