Commit c8ed99a5a41a1efdf8f296f431f9331e718f4f6d
1 parent
668fae93
CRM-客户:完善客户详情、分页、公海数据获取
Showing
15 changed files
with
192 additions
and
152 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.controller.admin.customer; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.collection.CollUtil; | |
| 4 | -import cn.hutool.core.util.NumberUtil; | |
| 5 | -import cn.hutool.core.util.ObjectUtil; | |
| 6 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 7 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | 5 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 9 | -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | |
| 10 | 6 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 11 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; |
| 12 | 8 | import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; |
| 13 | 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 10 | +import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; | |
| 11 | +import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum; | |
| 12 | +import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; | |
| 14 | 13 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| 14 | +import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; | |
| 15 | 15 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| 16 | 16 | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; |
| 17 | 17 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 18 | 18 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 19 | -import com.google.common.collect.Lists; | |
| 20 | 19 | import io.swagger.v3.oas.annotations.Operation; |
| 21 | 20 | import io.swagger.v3.oas.annotations.Parameter; |
| 22 | 21 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -28,11 +27,14 @@ import javax.annotation.Resource; |
| 28 | 27 | import javax.servlet.http.HttpServletResponse; |
| 29 | 28 | import javax.validation.Valid; |
| 30 | 29 | import java.io.IOException; |
| 31 | -import java.util.*; | |
| 32 | -import java.util.stream.Collectors; | |
| 33 | -import java.util.stream.Stream; | |
| 30 | +import java.util.Collections; | |
| 31 | +import java.util.List; | |
| 32 | +import java.util.Map; | |
| 33 | +import java.util.Set; | |
| 34 | 34 | |
| 35 | 35 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 36 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | |
| 37 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 36 | 38 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 37 | 39 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 38 | 40 | |
| ... | ... | @@ -48,6 +50,8 @@ public class CrmCustomerController { |
| 48 | 50 | private DeptApi deptApi; |
| 49 | 51 | @Resource |
| 50 | 52 | private AdminUserApi adminUserApi; |
| 53 | + @Resource | |
| 54 | + private CrmPermissionService permissionService; | |
| 51 | 55 | |
| 52 | 56 | @PostMapping("/create") |
| 53 | 57 | @Operation(summary = "创建客户") |
| ... | ... | @@ -78,49 +82,57 @@ public class CrmCustomerController { |
| 78 | 82 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 79 | 83 | @PreAuthorize("@ss.hasPermission('crm:customer:query')") |
| 80 | 84 | public CommonResult<CrmCustomerRespVO> getCustomer(@RequestParam("id") Long id) { |
| 85 | + // 1. 获取客户 | |
| 81 | 86 | CrmCustomerDO customer = customerService.getCustomer(id); |
| 82 | - CrmCustomerRespVO customerRespVO = CrmCustomerConvert.INSTANCE.convert(customer); | |
| 83 | - if (ObjectUtil.isAllNotEmpty(customer, customer.getAreaId())) { | |
| 84 | - customerRespVO.setAreaName(AreaUtils.format(customer.getAreaId())); | |
| 85 | - } | |
| 86 | - Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(CollUtil.removeNull(Lists.newArrayList(NumberUtil.parseLong(customerRespVO.getCreator()), customerRespVO.getOwnerUserId()))); | |
| 87 | - customerRespVO.setCreatorName(Optional.ofNullable(userMap.get(NumberUtil.parseLong(customerRespVO.getCreator()))).map(AdminUserRespDTO::getNickname).orElse(null)); | |
| 88 | - AdminUserRespDTO ownerUser = userMap.get(customer.getOwnerUserId()); | |
| 89 | - if (Objects.nonNull(ownerUser)) { | |
| 90 | - customerRespVO.setOwnerUserName(ownerUser.getNickname()); | |
| 91 | - DeptRespDTO dept = deptApi.getDept(ownerUser.getDeptId()); | |
| 92 | - if (Objects.nonNull(dept)) { | |
| 93 | - customerRespVO.setOwnerUserDept(dept.getName()); | |
| 94 | - } | |
| 87 | + if (customer == null) { | |
| 88 | + return success(null); | |
| 95 | 89 | } |
| 96 | - return success(customerRespVO); | |
| 90 | + | |
| 91 | + // 2. 拼接数据 | |
| 92 | + // 2.1 获取负责人 | |
| 93 | + List<CrmPermissionDO> ownerList = permissionService.getPermissionByBizTypeAndBizIdsAndLevel( | |
| 94 | + CrmBizTypeEnum.CRM_CUSTOMER.getType(), Collections.singletonList(customer.getId()), | |
| 95 | + CrmPermissionLevelEnum.OWNER.getLevel()); | |
| 96 | + Map<Long, CrmPermissionDO> ownerMap = convertMap(ownerList, CrmPermissionDO::getBizId); | |
| 97 | + // 2.2 获取负责人详情 | |
| 98 | + Set<Long> userIds = convertSet(ownerList, CrmPermissionDO::getUserId); | |
| 99 | + userIds.add(Long.parseLong(customer.getCreator())); // 加入创建者 | |
| 100 | + List<AdminUserRespDTO> userList = adminUserApi.getUserList(userIds); | |
| 101 | + Map<Long, AdminUserRespDTO> userMap = convertMap(userList, AdminUserRespDTO::getId); | |
| 102 | + // 2.3 获取部门详情 | |
| 103 | + Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userList, AdminUserRespDTO::getDeptId)); | |
| 104 | + return success(CrmCustomerConvert.INSTANCE.convert(customer, ownerMap, userMap, deptMap)); | |
| 97 | 105 | } |
| 98 | 106 | |
| 99 | 107 | @GetMapping("/page") |
| 100 | 108 | @Operation(summary = "获得客户分页") |
| 101 | 109 | @PreAuthorize("@ss.hasPermission('crm:customer:query')") |
| 102 | 110 | public CommonResult<PageResult<CrmCustomerRespVO>> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { |
| 103 | - PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(pageVO); | |
| 104 | - PageResult<CrmCustomerRespVO> pageVo = CrmCustomerConvert.INSTANCE.convertPage(pageResult); | |
| 105 | - // TODO @wanwan: 可以参考 CollectionUtils.convertListByFlatMap(),目的是简洁 | |
| 106 | - Set<Long> userSet = pageVo.getList().stream().flatMap(i -> Stream.of(NumberUtil.parseLong(i.getCreator()), i.getOwnerUserId())).collect(Collectors.toSet()); | |
| 107 | - Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userSet); | |
| 108 | - Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(userMap.values().stream().map(AdminUserRespDTO::getDeptId).collect(Collectors.toSet())); | |
| 109 | - // TODO @wanwan:这块可以形成一个 convertPage 方法,default 实现; | |
| 110 | - pageVo.getList().forEach(customerRespVO -> { | |
| 111 | - customerRespVO.setAreaName(AreaUtils.format(customerRespVO.getAreaId())); | |
| 112 | - customerRespVO.setCreatorName(Optional.ofNullable(userMap.get(NumberUtil.parseLong(customerRespVO.getCreator()))).map(AdminUserRespDTO::getNickname).orElse(null)); | |
| 113 | - // TODO @wanwan:可以使用 MapUtils.findAndThen | |
| 114 | - AdminUserRespDTO ownerUser = userMap.get(customerRespVO.getOwnerUserId()); | |
| 115 | - if (Objects.nonNull(ownerUser)) { | |
| 116 | - customerRespVO.setOwnerUserName(ownerUser.getNickname()); | |
| 117 | - DeptRespDTO dept = deptMap.get(ownerUser.getDeptId()); | |
| 118 | - if (Objects.nonNull(dept)) { | |
| 119 | - customerRespVO.setOwnerUserDept(dept.getName()); | |
| 120 | - } | |
| 121 | - } | |
| 122 | - }); | |
| 123 | - return success(pageVo); | |
| 111 | + return convertPage(customerService.getCustomerPage(pageVO, getLoginUserId())); | |
| 112 | + } | |
| 113 | + | |
| 114 | + @GetMapping("/pool-page") | |
| 115 | + @Operation(summary = "获得公海客户分页") | |
| 116 | + @PreAuthorize("@ss.hasPermission('crm:customer:query')") | |
| 117 | + public CommonResult<PageResult<CrmCustomerRespVO>> getPoolCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { | |
| 118 | + return convertPage(customerService.getCustomerPage(pageVO, CrmPermissionDO.POOL_USER_ID)); | |
| 119 | + } | |
| 120 | + | |
| 121 | + private CommonResult<PageResult<CrmCustomerRespVO>> convertPage(PageResult<CrmCustomerDO> pageResult) { | |
| 122 | + // 2. 拼接数据 | |
| 123 | + Set<Long> ids = convertSet(pageResult.getList(), CrmCustomerDO::getId); | |
| 124 | + // 2.1 获取负责人 | |
| 125 | + List<CrmPermissionDO> ownerList = permissionService.getPermissionByBizTypeAndBizIdsAndLevel( | |
| 126 | + CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, CrmPermissionLevelEnum.OWNER.getLevel()); | |
| 127 | + Map<Long, CrmPermissionDO> ownerMap = convertMap(ownerList, CrmPermissionDO::getBizId); | |
| 128 | + // 2.2 获取负责人详情 | |
| 129 | + Set<Long> userIds = convertSet(ownerList, CrmPermissionDO::getUserId); | |
| 130 | + userIds.addAll(convertSet(pageResult.getList(), item -> Long.parseLong(item.getCreator()))); // 加入创建者 | |
| 131 | + List<AdminUserRespDTO> userList = adminUserApi.getUserList(userIds); | |
| 132 | + Map<Long, AdminUserRespDTO> userMap = convertMap(userList, AdminUserRespDTO::getId); | |
| 133 | + // 2.3 获取部门详情 | |
| 134 | + Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userList, AdminUserRespDTO::getDeptId)); | |
| 135 | + return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, ownerMap, userMap, deptMap)); | |
| 124 | 136 | } |
| 125 | 137 | |
| 126 | 138 | @GetMapping("/export-excel") | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java
| ... | ... | @@ -33,7 +33,7 @@ public class CrmCustomerRespVO extends CrmCustomerBaseVO { |
| 33 | 33 | @Schema(description = "负责人名字", example = "25682") |
| 34 | 34 | private String ownerUserName; |
| 35 | 35 | @Schema(description = "负责人部门") |
| 36 | - private String ownerUserDept; | |
| 36 | + private String ownerUserDeptName; | |
| 37 | 37 | |
| 38 | 38 | @Schema(description = "地区名称", example = "北京市") |
| 39 | 39 | private String areaName; | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java
| ... | ... | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.crm.convert.business; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; |
| 5 | 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 6 | -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionPageReqBO; | |
| 7 | 6 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| 8 | 7 | import org.mapstruct.Mapper; |
| 9 | 8 | import org.mapstruct.Mapping; |
| ... | ... | @@ -38,6 +37,4 @@ public interface CrmBusinessConvert { |
| 38 | 37 | }) |
| 39 | 38 | CrmPermissionTransferReqBO convert(CrmBusinessTransferReqVO reqVO, Long userId); |
| 40 | 39 | |
| 41 | - CrmPermissionPageReqBO convert(CrmBusinessPageReqVO pageReqVO); | |
| 42 | - | |
| 43 | 40 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.convert.customer; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | |
| 4 | 5 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; |
| 5 | 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 7 | +import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; | |
| 6 | 8 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| 9 | +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | |
| 10 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | |
| 7 | 11 | import org.mapstruct.Mapper; |
| 8 | 12 | import org.mapstruct.Mapping; |
| 9 | 13 | import org.mapstruct.Mappings; |
| 10 | 14 | import org.mapstruct.factory.Mappers; |
| 11 | 15 | |
| 12 | 16 | import java.util.List; |
| 17 | +import java.util.Map; | |
| 18 | + | |
| 19 | +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | |
| 13 | 20 | |
| 14 | 21 | /** |
| 15 | 22 | * 客户 Convert |
| ... | ... | @@ -27,7 +34,24 @@ public interface CrmCustomerConvert { |
| 27 | 34 | |
| 28 | 35 | CrmCustomerRespVO convert(CrmCustomerDO bean); |
| 29 | 36 | |
| 30 | - PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page); | |
| 37 | + default CrmCustomerRespVO convert(CrmCustomerDO customer, Map<Long, CrmPermissionDO> ownerMap, | |
| 38 | + Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) { | |
| 39 | + CrmCustomerRespVO customerResp = convert(customer); | |
| 40 | + findAndThen(ownerMap, customerResp.getId(), owner -> { | |
| 41 | + customerResp.setOwnerUserId(owner.getUserId()); | |
| 42 | + customerResp.setAreaName(AreaUtils.format(customerResp.getAreaId())); | |
| 43 | + findAndThen(userMap, owner.getUserId(), user -> { | |
| 44 | + customerResp.setOwnerUserName(user.getNickname()); | |
| 45 | + }); | |
| 46 | + findAndThen(userMap, Long.parseLong(customerResp.getCreator()), user -> { | |
| 47 | + customerResp.setCreatorName(user.getNickname()); | |
| 48 | + }); | |
| 49 | + findAndThen(deptMap, customerResp.getOwnerUserId(), dept -> { | |
| 50 | + customerResp.setOwnerUserDeptName(dept.getName()); | |
| 51 | + }); | |
| 52 | + }); | |
| 53 | + return customerResp; | |
| 54 | + } | |
| 31 | 55 | |
| 32 | 56 | List<CrmCustomerExcelVO> convertList02(List<CrmCustomerDO> list); |
| 33 | 57 | |
| ... | ... | @@ -37,4 +61,27 @@ public interface CrmCustomerConvert { |
| 37 | 61 | }) |
| 38 | 62 | CrmPermissionTransferReqBO convert(CrmCustomerTransferReqVO reqVO, Long userId); |
| 39 | 63 | |
| 64 | + PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page); | |
| 65 | + | |
| 66 | + default PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> pageResult, Map<Long, CrmPermissionDO> ownerMap, | |
| 67 | + Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) { | |
| 68 | + PageResult<CrmCustomerRespVO> result = convertPage(pageResult); | |
| 69 | + result.getList().forEach(item -> { | |
| 70 | + findAndThen(ownerMap, item.getId(), owner -> { | |
| 71 | + item.setOwnerUserId(owner.getUserId()); | |
| 72 | + item.setAreaName(AreaUtils.format(item.getAreaId())); | |
| 73 | + findAndThen(userMap, owner.getUserId(), user -> { | |
| 74 | + item.setOwnerUserName(user.getNickname()); | |
| 75 | + }); | |
| 76 | + findAndThen(userMap, Long.parseLong(item.getCreator()), user -> { | |
| 77 | + item.setCreatorName(user.getNickname()); | |
| 78 | + }); | |
| 79 | + findAndThen(deptMap, item.getOwnerUserId(), dept -> { | |
| 80 | + item.setOwnerUserDeptName(dept.getName()); | |
| 81 | + }); | |
| 82 | + }); | |
| 83 | + }); | |
| 84 | + return result; | |
| 85 | + } | |
| 86 | + | |
| 40 | 87 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.dal.dataobject.customer; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | +import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; | |
| 4 | 5 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 5 | 6 | import com.baomidou.mybatisplus.annotation.TableId; |
| 6 | 7 | import com.baomidou.mybatisplus.annotation.TableName; |
| ... | ... | @@ -49,19 +50,19 @@ public class CrmCustomerDO extends BaseDO { |
| 49 | 50 | /** |
| 50 | 51 | * 所属行业 |
| 51 | 52 | * |
| 52 | - * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_CUSTOMER_INDUSTRY} | |
| 53 | + * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_INDUSTRY} | |
| 53 | 54 | */ |
| 54 | 55 | private Integer industryId; |
| 55 | 56 | /** |
| 56 | 57 | * 客户等级 |
| 57 | 58 | * |
| 58 | - * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_CUSTOMER_LEVEL} | |
| 59 | + * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_LEVEL} | |
| 59 | 60 | */ |
| 60 | 61 | private Integer level; |
| 61 | 62 | /** |
| 62 | 63 | * 客户来源 |
| 63 | 64 | * |
| 64 | - * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_CUSTOMER_SOURCE} | |
| 65 | + * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_SOURCE} | |
| 65 | 66 | */ |
| 66 | 67 | private Integer source; |
| 67 | 68 | /** |
| ... | ... | @@ -97,21 +98,6 @@ public class CrmCustomerDO extends BaseDO { |
| 97 | 98 | */ |
| 98 | 99 | private String remark; |
| 99 | 100 | /** |
| 100 | - * 负责人的用户编号 | |
| 101 | - * | |
| 102 | - * 关联 AdminUserDO 的 id 字段 | |
| 103 | - */ | |
| 104 | - private Long ownerUserId; | |
| 105 | - // TODO @puhui999:这块抽到 permission 里; | |
| 106 | - /** | |
| 107 | - * 只读权限的用户编号数组 | |
| 108 | - */ | |
| 109 | - private String roUserIds; | |
| 110 | - /** | |
| 111 | - * 读写权限的用户编号数组 | |
| 112 | - */ | |
| 113 | - private String rwUserIds; | |
| 114 | - /** | |
| 115 | 101 | * 地区编号 |
| 116 | 102 | */ |
| 117 | 103 | private Integer areaId; | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.dal.mysql.business; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 3 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 5 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO; |
| ... | ... | @@ -18,14 +19,14 @@ import java.util.List; |
| 18 | 19 | @Mapper |
| 19 | 20 | public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> { |
| 20 | 21 | |
| 21 | - default List<CrmBusinessDO> selectList(CrmBusinessPageReqVO reqVO, Collection<Long> ids) { | |
| 22 | - return selectList(new LambdaQueryWrapperX<CrmBusinessDO>() | |
| 22 | + default PageResult<CrmBusinessDO> selectPage(CrmBusinessPageReqVO reqVO, Collection<Long> ids) { | |
| 23 | + return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessDO>() | |
| 23 | 24 | .in(CrmBusinessDO::getId, ids) |
| 24 | 25 | .likeIfPresent(CrmBusinessDO::getName, reqVO.getName()) |
| 25 | 26 | .orderByDesc(CrmBusinessDO::getId)); |
| 26 | 27 | } |
| 27 | 28 | |
| 28 | - default List<CrmBusinessDO> selectList(CrmBusinessExportReqVO reqVO) { | |
| 29 | + default List<CrmBusinessDO> selectPage(CrmBusinessExportReqVO reqVO) { | |
| 29 | 30 | return selectList(new LambdaQueryWrapperX<CrmBusinessDO>() |
| 30 | 31 | .likeIfPresent(CrmBusinessDO::getName, reqVO.getName()) |
| 31 | 32 | .eqIfPresent(CrmBusinessDO::getStatusTypeId, reqVO.getStatusTypeId()) | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java
| ... | ... | @@ -3,12 +3,11 @@ package cn.iocoder.yudao.module.crm.dal.mysql.customer; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerExportReqVO; | |
| 7 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; |
| 8 | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 9 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 9 | |
| 11 | -import java.util.List; | |
| 10 | +import java.util.Collection; | |
| 12 | 11 | |
| 13 | 12 | /** |
| 14 | 13 | * 客户 Mapper |
| ... | ... | @@ -18,21 +17,14 @@ import java.util.List; |
| 18 | 17 | @Mapper |
| 19 | 18 | public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { |
| 20 | 19 | |
| 21 | - default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO reqVO) { | |
| 22 | - return selectPage(reqVO, new LambdaQueryWrapperX<CrmCustomerDO>() | |
| 23 | - .likeIfPresent(CrmCustomerDO::getName, reqVO.getName()) | |
| 24 | - .eqIfPresent(CrmCustomerDO::getMobile, reqVO.getMobile()) | |
| 25 | - .eqIfPresent(CrmCustomerDO::getIndustryId, reqVO.getIndustryId()) | |
| 26 | - .eqIfPresent(CrmCustomerDO::getLevel, reqVO.getLevel()) | |
| 27 | - .eqIfPresent(CrmCustomerDO::getSource, reqVO.getSource()) | |
| 28 | - .orderByDesc(CrmCustomerDO::getId)); | |
| 29 | - } | |
| 30 | - | |
| 31 | - default List<CrmCustomerDO> selectList(CrmCustomerExportReqVO reqVO) { | |
| 32 | - return selectList(new LambdaQueryWrapperX<CrmCustomerDO>() | |
| 33 | - .likeIfPresent(CrmCustomerDO::getName, reqVO.getName()) | |
| 34 | - .eqIfPresent(CrmCustomerDO::getMobile, reqVO.getMobile()) | |
| 35 | - .orderByDesc(CrmCustomerDO::getId)); | |
| 20 | + default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO pageReqVO, Collection<Long> ids) { | |
| 21 | + return selectPage(pageReqVO, new LambdaQueryWrapperX<CrmCustomerDO>() | |
| 22 | + .inIfPresent(CrmCustomerDO::getId, ids) | |
| 23 | + .likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName()) | |
| 24 | + .eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile()) | |
| 25 | + .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId()) | |
| 26 | + .eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel()) | |
| 27 | + .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource())); | |
| 36 | 28 | } |
| 37 | 29 | |
| 38 | 30 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.dal.mysql.permission; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 4 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; |
| 7 | -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionPageReqBO; | |
| 8 | 6 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 7 | |
| 8 | +import java.util.Collection; | |
| 10 | 9 | import java.util.List; |
| 11 | 10 | |
| 12 | 11 | /** |
| ... | ... | @@ -30,10 +29,17 @@ public interface CrmPermissionMapper extends BaseMapperX<CrmPermissionDO> { |
| 30 | 29 | .eq(CrmPermissionDO::getBizId, bizId)); |
| 31 | 30 | } |
| 32 | 31 | |
| 33 | - default PageResult<CrmPermissionDO> selectPage(CrmPermissionPageReqBO pageReqBO) { | |
| 34 | - return selectPage(pageReqBO, new LambdaQueryWrapperX<CrmPermissionDO>() | |
| 35 | - .eq(CrmPermissionDO::getBizType, pageReqBO.getBizType()) | |
| 36 | - .eq(CrmPermissionDO::getUserId, pageReqBO.getUserId())); // 只要是团队成员都有读取的权限 | |
| 32 | + default List<CrmPermissionDO> selectListByBizTypeAndUserId(Integer bizType, Long userId) { | |
| 33 | + return selectList(new LambdaQueryWrapperX<CrmPermissionDO>() | |
| 34 | + .eq(CrmPermissionDO::getBizType, bizType) | |
| 35 | + .eq(CrmPermissionDO::getUserId, userId)); | |
| 36 | + } | |
| 37 | + | |
| 38 | + default List<CrmPermissionDO> selectListByBizTypeAndBizIdsAndLevel(Integer bizType, Collection<Long> bizIds, Integer level) { | |
| 39 | + return selectList(new LambdaQueryWrapperX<CrmPermissionDO>() | |
| 40 | + .eq(CrmPermissionDO::getBizType, bizType) | |
| 41 | + .in(CrmPermissionDO::getBizId, bizIds) | |
| 42 | + .eq(CrmPermissionDO::getLevel, level)); | |
| 37 | 43 | } |
| 38 | 44 | |
| 39 | 45 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| ... | ... | @@ -103,21 +103,20 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 103 | 103 | @Override |
| 104 | 104 | public PageResult<CrmBusinessDO> getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId) { |
| 105 | 105 | // 1. 获取当前用户能看的分页数据 |
| 106 | - PageResult<CrmPermissionDO> permissionPage = crmPermissionService.getPermissionPage( | |
| 107 | - CrmBusinessConvert.INSTANCE.convert(pageReqVO).setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()).setUserId(userId)); | |
| 108 | - Set<Long> ids = convertSet(permissionPage.getList(), CrmPermissionDO::getBizId); | |
| 106 | + List<CrmPermissionDO> permissions = crmPermissionService.getPermissionListByBizTypeAndUserId( | |
| 107 | + CrmBizTypeEnum.CRM_BUSINESS.getType(), userId); | |
| 108 | + Set<Long> ids = convertSet(permissions, CrmPermissionDO::getBizId); | |
| 109 | 109 | if (CollUtil.isEmpty(ids)) { // 没得说明没有什么给他看的 |
| 110 | 110 | return PageResult.empty(); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // 2. 获取商机分页数据 |
| 114 | - List<CrmBusinessDO> businessList = businessMapper.selectList(pageReqVO, ids); | |
| 115 | - return new PageResult<>(businessList, (long) businessList.size()); | |
| 114 | + return businessMapper.selectPage(pageReqVO, ids); | |
| 116 | 115 | } |
| 117 | 116 | |
| 118 | 117 | @Override |
| 119 | 118 | public List<CrmBusinessDO> getBusinessList(CrmBusinessExportReqVO exportReqVO) { |
| 120 | - return businessMapper.selectList(exportReqVO); | |
| 119 | + return businessMapper.selectPage(exportReqVO); | |
| 121 | 120 | } |
| 122 | 121 | |
| 123 | 122 | @Override | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java
| ... | ... | @@ -5,7 +5,6 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; |
| 5 | 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 6 | 6 | |
| 7 | 7 | import javax.validation.Valid; |
| 8 | -import java.util.Collection; | |
| 9 | 8 | import java.util.List; |
| 10 | 9 | |
| 11 | 10 | /** |
| ... | ... | @@ -50,9 +49,10 @@ public interface CrmCustomerService { |
| 50 | 49 | * 获得客户分页 |
| 51 | 50 | * |
| 52 | 51 | * @param pageReqVO 分页查询 |
| 52 | + * @param userId 用户编号 | |
| 53 | 53 | * @return 客户分页 |
| 54 | 54 | */ |
| 55 | - PageResult<CrmCustomerDO> getCustomerPage(CrmCustomerPageReqVO pageReqVO); | |
| 55 | + PageResult<CrmCustomerDO> getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId); | |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * 获得客户列表, 用于 Excel 导出 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.service.customer; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.hutool.core.util.ObjUtil; | |
| 3 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; |
| 5 | 7 | import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; |
| 6 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 9 | +import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; | |
| 7 | 10 | import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; |
| 8 | 11 | import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; |
| 9 | 12 | import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum; |
| ... | ... | @@ -15,10 +18,13 @@ import org.springframework.transaction.annotation.Transactional; |
| 15 | 18 | import org.springframework.validation.annotation.Validated; |
| 16 | 19 | |
| 17 | 20 | import javax.annotation.Resource; |
| 21 | +import java.util.Collections; | |
| 18 | 22 | import java.util.List; |
| 19 | 23 | import java.util.Objects; |
| 24 | +import java.util.Set; | |
| 20 | 25 | |
| 21 | 26 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 27 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 22 | 28 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; |
| 23 | 29 | |
| 24 | 30 | /** |
| ... | ... | @@ -51,11 +57,10 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 51 | 57 | |
| 52 | 58 | @Override |
| 53 | 59 | @Transactional(rollbackFor = Exception.class) |
| 54 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, level = CrmPermissionLevelEnum.WRITE) | |
| 60 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) | |
| 55 | 61 | public void updateCustomer(CrmCustomerUpdateReqVO updateReqVO) { |
| 56 | 62 | // 校验存在 |
| 57 | 63 | validateCustomerExists(updateReqVO.getId()); |
| 58 | - // TODO 芋艿:数据权限,校验是否可以操作 | |
| 59 | 64 | |
| 60 | 65 | // 更新 |
| 61 | 66 | CrmCustomerDO updateObj = CrmCustomerConvert.INSTANCE.convert(updateReqVO); |
| ... | ... | @@ -64,11 +69,10 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 64 | 69 | |
| 65 | 70 | @Override |
| 66 | 71 | @Transactional(rollbackFor = Exception.class) |
| 67 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, level = CrmPermissionLevelEnum.WRITE) | |
| 72 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) | |
| 68 | 73 | public void deleteCustomer(Long id) { |
| 69 | 74 | // 校验存在 |
| 70 | 75 | validateCustomerExists(id); |
| 71 | - // TODO 芋艿:数据权限,校验是否可以操作 | |
| 72 | 76 | |
| 73 | 77 | // 删除 |
| 74 | 78 | customerMapper.deleteById(id); |
| ... | ... | @@ -81,20 +85,34 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 81 | 85 | } |
| 82 | 86 | |
| 83 | 87 | @Override |
| 84 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, level = CrmPermissionLevelEnum.READ) | |
| 88 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.READ) | |
| 85 | 89 | public CrmCustomerDO getCustomer(Long id) { |
| 86 | 90 | return customerMapper.selectById(id); |
| 87 | 91 | } |
| 88 | 92 | |
| 89 | 93 | @Override |
| 90 | - public PageResult<CrmCustomerDO> getCustomerPage(CrmCustomerPageReqVO pageReqVO) { | |
| 91 | - // TODO 芋艿:数据权限,是否可以查询到; | |
| 92 | - return customerMapper.selectPage(pageReqVO); | |
| 94 | + public PageResult<CrmCustomerDO> getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId) { | |
| 95 | + // 1.1 TODO 如果是超级管理员 | |
| 96 | + boolean admin = false; | |
| 97 | + if (admin && ObjUtil.notEqual(userId, CrmPermissionDO.POOL_USER_ID)) { | |
| 98 | + return customerMapper.selectPage(pageReqVO, Collections.emptyList()); | |
| 99 | + } | |
| 100 | + // 1.2 获取当前用户能看的分页数据 | |
| 101 | + List<CrmPermissionDO> permissions = crmPermissionService.getPermissionListByBizTypeAndUserId( | |
| 102 | + CrmBizTypeEnum.CRM_CUSTOMER.getType(), userId); | |
| 103 | + Set<Long> ids = convertSet(permissions, CrmPermissionDO::getBizId); | |
| 104 | + if (CollUtil.isEmpty(ids)) { // 没得说明没有什么给他看的 | |
| 105 | + return PageResult.empty(); | |
| 106 | + } | |
| 107 | + | |
| 108 | + // 2. 获取客户分页数据 | |
| 109 | + return customerMapper.selectPage(pageReqVO, ids); | |
| 93 | 110 | } |
| 94 | 111 | |
| 95 | 112 | @Override |
| 96 | 113 | public List<CrmCustomerDO> getCustomerList(CrmCustomerExportReqVO exportReqVO) { |
| 97 | - return customerMapper.selectList(exportReqVO); | |
| 114 | + //return customerMapper.selectList(exportReqVO); | |
| 115 | + return Collections.emptyList(); | |
| 98 | 116 | } |
| 99 | 117 | |
| 100 | 118 | /** | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.service.permission; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | 4 | import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; |
| 6 | 5 | import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum; |
| 7 | 6 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 8 | -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionPageReqBO; | |
| 9 | 7 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| 10 | 8 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionUpdateReqBO; |
| 11 | 9 | |
| 12 | 10 | import javax.validation.Valid; |
| 11 | +import java.util.Collection; | |
| 13 | 12 | import java.util.List; |
| 14 | 13 | |
| 15 | 14 | /** |
| ... | ... | @@ -61,6 +60,16 @@ public interface CrmPermissionService { |
| 61 | 60 | List<CrmPermissionDO> getPermissionByBizTypeAndBizId(Integer bizType, Long bizId); |
| 62 | 61 | |
| 63 | 62 | /** |
| 63 | + * 获取数据权限列表,通过 数据类型 x 某个数据 | |
| 64 | + * | |
| 65 | + * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} | |
| 66 | + * @param bizIds 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() | |
| 67 | + * @param level 权限级别 | |
| 68 | + * @return Crm 数据权限列表 | |
| 69 | + */ | |
| 70 | + List<CrmPermissionDO> getPermissionByBizTypeAndBizIdsAndLevel(Integer bizType, Collection<Long> bizIds, Integer level); | |
| 71 | + | |
| 72 | + /** | |
| 64 | 73 | * 数据权限转移 |
| 65 | 74 | * |
| 66 | 75 | * @param crmPermissionTransferReqBO 数据权限转移请求 |
| ... | ... | @@ -68,11 +77,12 @@ public interface CrmPermissionService { |
| 68 | 77 | void transferPermission(@Valid CrmPermissionTransferReqBO crmPermissionTransferReqBO); |
| 69 | 78 | |
| 70 | 79 | /** |
| 71 | - * 获取数据权限分页数据 | |
| 80 | + * 获取用户参与的模块数据列表 | |
| 72 | 81 | * |
| 73 | - * @param pageReqBO 分页请求 | |
| 74 | - * @return 数据权限分页数据 | |
| 82 | + * @param bizType 模块类型 | |
| 83 | + * @param userId 用户编号 | |
| 84 | + * @return 模块数据列表 | |
| 75 | 85 | */ |
| 76 | - PageResult<CrmPermissionDO> getPermissionPage(CrmPermissionPageReqBO pageReqBO); | |
| 86 | + List<CrmPermissionDO> getPermissionListByBizTypeAndUserId(Integer bizType, Long userId); | |
| 77 | 87 | |
| 78 | 88 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java
| ... | ... | @@ -2,14 +2,12 @@ package cn.iocoder.yudao.module.crm.service.permission; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.util.ObjUtil; |
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | 5 | import cn.iocoder.yudao.module.crm.convert.permission.CrmPermissionConvert; |
| 7 | 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; |
| 8 | 7 | import cn.iocoder.yudao.module.crm.dal.mysql.permission.CrmPermissionMapper; |
| 9 | 8 | import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum; |
| 10 | 9 | import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; |
| 11 | 10 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 12 | -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionPageReqBO; | |
| 13 | 11 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| 14 | 12 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionUpdateReqBO; |
| 15 | 13 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| ... | ... | @@ -18,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional; |
| 18 | 16 | import org.springframework.validation.annotation.Validated; |
| 19 | 17 | |
| 20 | 18 | import javax.annotation.Resource; |
| 19 | +import java.util.Collection; | |
| 21 | 20 | import java.util.Collections; |
| 22 | 21 | import java.util.List; |
| 23 | 22 | |
| ... | ... | @@ -85,6 +84,11 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { |
| 85 | 84 | return crmPermissionMapper.selectByBizTypeAndBizId(bizType, bizId); |
| 86 | 85 | } |
| 87 | 86 | |
| 87 | + @Override | |
| 88 | + public List<CrmPermissionDO> getPermissionByBizTypeAndBizIdsAndLevel(Integer bizType, Collection<Long> bizIds, Integer level) { | |
| 89 | + return crmPermissionMapper.selectListByBizTypeAndBizIdsAndLevel(bizType, bizIds, level); | |
| 90 | + } | |
| 91 | + | |
| 88 | 92 | private void validateCrmPermissionExists(Long id) { |
| 89 | 93 | if (crmPermissionMapper.selectById(id) == null) { |
| 90 | 94 | throw exception(CRM_PERMISSION_NOT_EXISTS); |
| ... | ... | @@ -133,8 +137,8 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { |
| 133 | 137 | } |
| 134 | 138 | |
| 135 | 139 | @Override |
| 136 | - public PageResult<CrmPermissionDO> getPermissionPage(CrmPermissionPageReqBO pageReqBO) { | |
| 137 | - return crmPermissionMapper.selectPage(pageReqBO); | |
| 140 | + public List<CrmPermissionDO> getPermissionListByBizTypeAndUserId(Integer bizType, Long userId) { | |
| 141 | + return crmPermissionMapper.selectListByBizTypeAndUserId(bizType, userId); | |
| 138 | 142 | } |
| 139 | 143 | |
| 140 | 144 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionPageReqBO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.permission.bo; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 5 | -import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum; | |
| 6 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 7 | -import lombok.Data; | |
| 8 | -import lombok.EqualsAndHashCode; | |
| 9 | -import lombok.ToString; | |
| 10 | - | |
| 11 | -import javax.validation.constraints.NotNull; | |
| 12 | - | |
| 13 | -@Schema(description = "管理后台 - CRM 数据权限分页 Request BO") | |
| 14 | -@Data | |
| 15 | -@EqualsAndHashCode(callSuper = true) | |
| 16 | -@ToString(callSuper = true) | |
| 17 | -public class CrmPermissionPageReqBO extends PageParam { | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * 当前登录用户编号 | |
| 21 | - */ | |
| 22 | - @NotNull(message = "用户编号不能为空") | |
| 23 | - private Long userId; | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * Crm 类型 | |
| 27 | - */ | |
| 28 | - @NotNull(message = "Crm 类型不能为空") | |
| 29 | - @InEnum(CrmBizTypeEnum.class) | |
| 30 | - private Integer bizType; | |
| 31 | - | |
| 32 | -} |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java
| ... | ... | @@ -130,7 +130,7 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest { |
| 130 | 130 | //reqVO.setWebsite(null); |
| 131 | 131 | |
| 132 | 132 | // 调用 |
| 133 | - PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(reqVO); | |
| 133 | + PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(reqVO, 1L); | |
| 134 | 134 | // 断言 |
| 135 | 135 | assertEquals(1, pageResult.getTotal()); |
| 136 | 136 | assertEquals(1, pageResult.getList().size()); | ... | ... |