Commit 3707662187c718f53ad969e1b876168e1f06b1c2
1 parent
d430063e
📈 CRM:code review 数据权限
Showing
15 changed files
with
26 additions
and
325 deletions
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
| @@ -72,7 +72,4 @@ public interface ErrorCodeConstants { | @@ -72,7 +72,4 @@ public interface ErrorCodeConstants { | ||
| 72 | // ========== 客户公海规则设置 1_020_012_000 ========== | 72 | // ========== 客户公海规则设置 1_020_012_000 ========== |
| 73 | ErrorCode CUSTOMER_LIMIT_CONFIG_NOT_EXISTS = new ErrorCode(1_020_012_000, "客户限制配置不存在"); | 73 | ErrorCode CUSTOMER_LIMIT_CONFIG_NOT_EXISTS = new ErrorCode(1_020_012_000, "客户限制配置不存在"); |
| 74 | 74 | ||
| 75 | - // ========== 关注的数据 1_020_013_000 ========== | ||
| 76 | - ErrorCode CRM_CONCERNED_NOT_EXISTS = new ErrorCode(1_020_013_000, "关注数据不存在"); | ||
| 77 | - | ||
| 78 | } | 75 | } |
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmSceneEnum.java
| @@ -7,6 +7,7 @@ import lombok.Getter; | @@ -7,6 +7,7 @@ import lombok.Getter; | ||
| 7 | 7 | ||
| 8 | import java.util.Arrays; | 8 | import java.util.Arrays; |
| 9 | 9 | ||
| 10 | +// TODO @puhui999:这个枚举,要不改成 CrmSceneTypeEnum | ||
| 10 | /** | 11 | /** |
| 11 | * CRM 列表检索场景 | 12 | * CRM 列表检索场景 |
| 12 | * | 13 | * |
| @@ -18,6 +19,7 @@ public enum CrmSceneEnum implements IntArrayValuable { | @@ -18,6 +19,7 @@ public enum CrmSceneEnum implements IntArrayValuable { | ||
| 18 | 19 | ||
| 19 | OWNER(1, "我负责的"), | 20 | OWNER(1, "我负责的"), |
| 20 | FOLLOW(2, "我关注的"), | 21 | FOLLOW(2, "我关注的"), |
| 22 | + // TODO @puhui999:还有一个我参与的 | ||
| 21 | SUBORDINATE(3, "下属负责的"); | 23 | SUBORDINATE(3, "下属负责的"); |
| 22 | 24 | ||
| 23 | public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneEnum::getType).toArray(); | 25 | public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneEnum::getType).toArray(); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
| @@ -139,24 +139,6 @@ public class CrmCustomerController { | @@ -139,24 +139,6 @@ public class CrmCustomerController { | ||
| 139 | return success(true); | 139 | return success(true); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | - @PutMapping("/concern") | ||
| 143 | - @Operation(summary = "关注客户") | ||
| 144 | - @Parameter(name = "ids", description = "编号", required = true, example = "[1024]") | ||
| 145 | - @PreAuthorize("@ss.hasPermission('crm:customer:update')") | ||
| 146 | - public CommonResult<Boolean> concernCustomer(@RequestParam("ids") List<Long> ids) { | ||
| 147 | - customerService.concernCustomer(ids, getLoginUserId()); | ||
| 148 | - return success(true); | ||
| 149 | - } | ||
| 150 | - | ||
| 151 | - @PutMapping("/cancel-concern") | ||
| 152 | - @Operation(summary = "取消关注客户") | ||
| 153 | - @Parameter(name = "ids", description = "编号", required = true, example = "[1024]") | ||
| 154 | - @PreAuthorize("@ss.hasPermission('crm:customer:update')") | ||
| 155 | - public CommonResult<Boolean> cancelConcernCustomer(@RequestParam("ids") List<Long> ids) { | ||
| 156 | - customerService.cancelConcernCustomer(ids, getLoginUserId()); | ||
| 157 | - return success(true); | ||
| 158 | - } | ||
| 159 | - | ||
| 160 | // ==================== 公海相关操作 ==================== | 142 | // ==================== 公海相关操作 ==================== |
| 161 | 143 | ||
| 162 | @PutMapping("/put-pool") | 144 | @PutMapping("/put-pool") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/concerned/CrmConcernedDO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.dal.dataobject.concerned; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | ||
| 5 | -import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 6 | -import com.baomidou.mybatisplus.annotation.TableId; | ||
| 7 | -import com.baomidou.mybatisplus.annotation.TableName; | ||
| 8 | -import lombok.*; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * CRM 关注的数据 DO | ||
| 12 | - * | ||
| 13 | - * @author HUIHUI | ||
| 14 | - */ | ||
| 15 | -@TableName("crm_concerned") | ||
| 16 | -@KeySequence("crm_concerned_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 17 | -@Data | ||
| 18 | -@EqualsAndHashCode(callSuper = true) | ||
| 19 | -@ToString(callSuper = true) | ||
| 20 | -@Builder | ||
| 21 | -@NoArgsConstructor | ||
| 22 | -@AllArgsConstructor | ||
| 23 | -public class CrmConcernedDO extends BaseDO { | ||
| 24 | - | ||
| 25 | - /** | ||
| 26 | - * 编号,主键自增 | ||
| 27 | - */ | ||
| 28 | - @TableId | ||
| 29 | - private Long id; | ||
| 30 | - | ||
| 31 | - /** | ||
| 32 | - * 数据类型 | ||
| 33 | - * | ||
| 34 | - * 枚举 {@link CrmBizTypeEnum} | ||
| 35 | - */ | ||
| 36 | - private Integer bizType; | ||
| 37 | - /** | ||
| 38 | - * 数据编号 | ||
| 39 | - * | ||
| 40 | - * 关联 {@link CrmBizTypeEnum} 对应模块 DO 的 id 字段 | ||
| 41 | - */ | ||
| 42 | - private Long bizId; | ||
| 43 | - | ||
| 44 | - /** | ||
| 45 | - * 用户编号 | ||
| 46 | - * | ||
| 47 | - * 关联 AdminUser 的 id 字段 | ||
| 48 | - */ | ||
| 49 | - private Long userId; | ||
| 50 | - | ||
| 51 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/concerned/CrmConcernedMapper.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.dal.mysql.concerned; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 4 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 5 | -import cn.iocoder.yudao.module.crm.dal.dataobject.concerned.CrmConcernedDO; | ||
| 6 | -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | ||
| 7 | -import org.apache.ibatis.annotations.Mapper; | ||
| 8 | - | ||
| 9 | -import java.util.Collection; | ||
| 10 | -import java.util.List; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * CRM 关注的数据 Mapper | ||
| 14 | - * | ||
| 15 | - * @author HUIHUI | ||
| 16 | - */ | ||
| 17 | -@Mapper | ||
| 18 | -public interface CrmConcernedMapper extends BaseMapperX<CrmConcernedDO> { | ||
| 19 | - | ||
| 20 | - /** | ||
| 21 | - * 查询用户关注的数据 | ||
| 22 | - * | ||
| 23 | - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} | ||
| 24 | - * @param bizIds 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() | ||
| 25 | - * @param userId 用户编号 | ||
| 26 | - * @return 关注的数据 | ||
| 27 | - */ | ||
| 28 | - default List<CrmConcernedDO> selectList(Integer bizType, Collection<Long> bizIds, Long userId) { | ||
| 29 | - return selectList(new LambdaQueryWrapperX<CrmConcernedDO>() | ||
| 30 | - .eq(CrmConcernedDO::getBizType, bizType) | ||
| 31 | - .in(CrmConcernedDO::getBizId, bizIds) | ||
| 32 | - .eq(CrmConcernedDO::getUserId, userId)); | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | -} | ||
| 36 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java
| @@ -45,14 +45,14 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | @@ -45,14 +45,14 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | ||
| 45 | // 构建数据权限连表条件 | 45 | // 构建数据权限连表条件 |
| 46 | CrmQueryPageUtils.builderQuery(mpjLambdaWrapperX, pageReqVO, userId, | 46 | CrmQueryPageUtils.builderQuery(mpjLambdaWrapperX, pageReqVO, userId, |
| 47 | CrmBizTypeEnum.CRM_CUSTOMER.getType(), CrmCustomerDO::getId, subordinateIds, isAdmin); | 47 | CrmBizTypeEnum.CRM_CUSTOMER.getType(), CrmCustomerDO::getId, subordinateIds, isAdmin); |
| 48 | - mpjLambdaWrapperX | ||
| 49 | - .selectAll(CrmCustomerDO.class) | 48 | + mpjLambdaWrapperX.selectAll(CrmCustomerDO.class) |
| 50 | .likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName()) | 49 | .likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName()) |
| 51 | .eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile()) | 50 | .eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile()) |
| 52 | .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId()) | 51 | .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId()) |
| 53 | .eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel()) | 52 | .eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel()) |
| 54 | .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource()); | 53 | .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource()); |
| 55 | // 特殊:不分页,直接查询全部 | 54 | // 特殊:不分页,直接查询全部 |
| 55 | + // TODO @puhui999:下面这个,封装一个方法;从 56 到 61 这里哈; | ||
| 56 | if (PageParam.PAGE_SIZE_NONE.equals(pageReqVO.getPageNo())) { | 56 | if (PageParam.PAGE_SIZE_NONE.equals(pageReqVO.getPageNo())) { |
| 57 | List<CrmCustomerDO> list = selectJoinList(CrmCustomerDO.class, mpjLambdaWrapperX); | 57 | List<CrmCustomerDO> list = selectJoinList(CrmCustomerDO.class, mpjLambdaWrapperX); |
| 58 | return new PageResult<>(list, (long) list.size()); | 58 | return new PageResult<>(list, (long) list.size()); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/vo/CrmBasePageReqVO.java
| @@ -13,9 +13,7 @@ import lombok.EqualsAndHashCode; | @@ -13,9 +13,7 @@ import lombok.EqualsAndHashCode; | ||
| 13 | public class CrmBasePageReqVO extends PageParam { | 13 | public class CrmBasePageReqVO extends PageParam { |
| 14 | 14 | ||
| 15 | /** | 15 | /** |
| 16 | - * 场景类型, 为 null 时则表示全部 | ||
| 17 | - * | ||
| 18 | - * 关联 {@link CrmSceneEnum} | 16 | + * 场景类型,为 null 时则表示全部 |
| 19 | */ | 17 | */ |
| 20 | @Schema(description = "场景类型", example = "1") | 18 | @Schema(description = "场景类型", example = "1") |
| 21 | @InEnum(CrmSceneEnum.class) | 19 | @InEnum(CrmSceneEnum.class) |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/concerned/CrmConcernedService.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.concerned; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | ||
| 4 | -import cn.iocoder.yudao.module.crm.service.concerned.bo.CrmConcernedCreateReqBO; | ||
| 5 | - | ||
| 6 | -import javax.validation.Valid; | ||
| 7 | -import java.util.Collection; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * CRM 关注的数据 Service 接口 | ||
| 11 | - * | ||
| 12 | - * @author HUIHUI | ||
| 13 | - */ | ||
| 14 | -public interface CrmConcernedService { | ||
| 15 | - | ||
| 16 | - /** | ||
| 17 | - * 创建关注数据 | ||
| 18 | - * | ||
| 19 | - * @param createReqBO 创建请求 | ||
| 20 | - * @return 编号 | ||
| 21 | - */ | ||
| 22 | - Long createConcerned(@Valid CrmConcernedCreateReqBO createReqBO); | ||
| 23 | - | ||
| 24 | - /** | ||
| 25 | - * 批量创建关注数据 | ||
| 26 | - * | ||
| 27 | - * @param createReqBO 创建请求 | ||
| 28 | - */ | ||
| 29 | - void createConcernedBatch(@Valid Collection<CrmConcernedCreateReqBO> createReqBO); | ||
| 30 | - | ||
| 31 | - /** | ||
| 32 | - * 删除关注数据 | ||
| 33 | - * | ||
| 34 | - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} | ||
| 35 | - * @param bizIds 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() | ||
| 36 | - * @param userId 用户编号 | ||
| 37 | - */ | ||
| 38 | - void deleteConcerned(Integer bizType, Collection<Long> bizIds, Long userId); | ||
| 39 | - | ||
| 40 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/concerned/CrmConcernedServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.concerned; | ||
| 2 | - | ||
| 3 | -import cn.hutool.core.util.ObjUtil; | ||
| 4 | -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 5 | -import cn.iocoder.yudao.module.crm.dal.dataobject.concerned.CrmConcernedDO; | ||
| 6 | -import cn.iocoder.yudao.module.crm.dal.mysql.concerned.CrmConcernedMapper; | ||
| 7 | -import cn.iocoder.yudao.module.crm.service.concerned.bo.CrmConcernedCreateReqBO; | ||
| 8 | -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||
| 9 | -import org.springframework.stereotype.Service; | ||
| 10 | -import org.springframework.transaction.annotation.Transactional; | ||
| 11 | -import org.springframework.validation.annotation.Validated; | ||
| 12 | - | ||
| 13 | -import javax.annotation.Resource; | ||
| 14 | -import java.util.Collection; | ||
| 15 | -import java.util.Collections; | ||
| 16 | -import java.util.List; | ||
| 17 | - | ||
| 18 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 19 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | ||
| 20 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 21 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_CONCERNED_NOT_EXISTS; | ||
| 22 | - | ||
| 23 | -/** | ||
| 24 | - * CRM 关注的数据 Service 接口实现类 | ||
| 25 | - * | ||
| 26 | - * @author HUIHUI | ||
| 27 | - */ | ||
| 28 | -@Service | ||
| 29 | -@Validated | ||
| 30 | -public class CrmConcernedServiceImpl implements CrmConcernedService { | ||
| 31 | - | ||
| 32 | - @Resource | ||
| 33 | - private CrmConcernedMapper concernedMapper; | ||
| 34 | - @Resource | ||
| 35 | - private AdminUserApi adminUserApi; | ||
| 36 | - | ||
| 37 | - @Override | ||
| 38 | - @Transactional(rollbackFor = Exception.class) | ||
| 39 | - public Long createConcerned(CrmConcernedCreateReqBO createReqBO) { | ||
| 40 | - // 1. 校验用户是否存在 | ||
| 41 | - adminUserApi.validateUserList(Collections.singletonList(createReqBO.getUserId())); | ||
| 42 | - | ||
| 43 | - // 2. 创建 | ||
| 44 | - CrmConcernedDO concerned = BeanUtils.toBean(createReqBO, CrmConcernedDO.class); | ||
| 45 | - concernedMapper.insert(concerned); | ||
| 46 | - return concerned.getId(); | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - @Override | ||
| 50 | - public void createConcernedBatch(Collection<CrmConcernedCreateReqBO> createReqBO) { | ||
| 51 | - // 1. 校验用户是否存在 | ||
| 52 | - adminUserApi.validateUserList(convertSet(createReqBO, CrmConcernedCreateReqBO::getUserId)); | ||
| 53 | - | ||
| 54 | - // 2. 创建 | ||
| 55 | - List<CrmConcernedDO> concernedList = convertList(createReqBO, item -> BeanUtils.toBean(item, CrmConcernedDO.class)); | ||
| 56 | - concernedMapper.insertBatch(concernedList); | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - @Override | ||
| 60 | - public void deleteConcerned(Integer bizType, Collection<Long> bizIds, Long userId) { | ||
| 61 | - // 1. 查询关注数据 | ||
| 62 | - List<CrmConcernedDO> concernedList = concernedMapper.selectList(bizType, bizIds, userId); | ||
| 63 | - if (ObjUtil.notEqual(bizIds.size(), concernedList.size())) { | ||
| 64 | - throw exception(CRM_CONCERNED_NOT_EXISTS); | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - // 2. 删除 | ||
| 68 | - concernedMapper.deleteBatchIds(convertList(concernedList, CrmConcernedDO::getId)); | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/concerned/bo/CrmConcernedCreateReqBO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.concerned.bo; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 4 | -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | ||
| 5 | -import lombok.Data; | ||
| 6 | - | ||
| 7 | -import javax.validation.constraints.NotNull; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * CRM 关注的数据 Create Req BO | ||
| 11 | - * | ||
| 12 | - * @author HUIHUI | ||
| 13 | - */ | ||
| 14 | -@Data | ||
| 15 | -public class CrmConcernedCreateReqBO { | ||
| 16 | - | ||
| 17 | - /** | ||
| 18 | - * 当前登录用户编号 | ||
| 19 | - */ | ||
| 20 | - @NotNull(message = "用户编号不能为空") | ||
| 21 | - private Long userId; | ||
| 22 | - | ||
| 23 | - /** | ||
| 24 | - * Crm 类型 | ||
| 25 | - */ | ||
| 26 | - @NotNull(message = "Crm 类型不能为空") | ||
| 27 | - @InEnum(CrmBizTypeEnum.class) | ||
| 28 | - private Integer bizType; | ||
| 29 | - /** | ||
| 30 | - * 数据编号 | ||
| 31 | - */ | ||
| 32 | - @NotNull(message = "Crm 数据编号不能为空") | ||
| 33 | - private Long bizId; | ||
| 34 | - | ||
| 35 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java
| @@ -90,22 +90,6 @@ public interface CrmCustomerService { | @@ -90,22 +90,6 @@ public interface CrmCustomerService { | ||
| 90 | */ | 90 | */ |
| 91 | void lockCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO); | 91 | void lockCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO); |
| 92 | 92 | ||
| 93 | - /** | ||
| 94 | - * 关注客户 | ||
| 95 | - * | ||
| 96 | - * @param ids 客户编号 | ||
| 97 | - * @param userId 用户编号 | ||
| 98 | - */ | ||
| 99 | - void concernCustomer(List<Long> ids, Long userId); | ||
| 100 | - | ||
| 101 | - /** | ||
| 102 | - * 取消关注客户 | ||
| 103 | - * | ||
| 104 | - * @param ids 客户编号 | ||
| 105 | - * @param userId 用户编号 | ||
| 106 | - */ | ||
| 107 | - void cancelConcernCustomer(List<Long> ids, Long userId); | ||
| 108 | - | ||
| 109 | // ==================== 公海相关操作 ==================== | 93 | // ==================== 公海相关操作 ==================== |
| 110 | 94 | ||
| 111 | /** | 95 | /** |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| 1 | package cn.iocoder.yudao.module.crm.service.customer; | 1 | package cn.iocoder.yudao.module.crm.service.customer; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | -import cn.hutool.core.util.ObjUtil; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 7 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; | 5 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; |
| 8 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; | 6 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; |
| 9 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO; | 7 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO; |
| @@ -14,8 +12,6 @@ import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; | @@ -14,8 +12,6 @@ import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; | ||
| 14 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | 12 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 15 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | 13 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 16 | import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; | 14 | import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; |
| 17 | -import cn.iocoder.yudao.module.crm.service.concerned.CrmConcernedService; | ||
| 18 | -import cn.iocoder.yudao.module.crm.service.concerned.bo.CrmConcernedCreateReqBO; | ||
| 19 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; | 15 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 20 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; | 16 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 21 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 17 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| @@ -27,7 +23,6 @@ import javax.annotation.Resource; | @@ -27,7 +23,6 @@ import javax.annotation.Resource; | ||
| 27 | import java.util.*; | 23 | import java.util.*; |
| 28 | 24 | ||
| 29 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 25 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 30 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | ||
| 31 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | 26 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; |
| 32 | import static java.util.Collections.singletonList; | 27 | import static java.util.Collections.singletonList; |
| 33 | 28 | ||
| @@ -47,9 +42,6 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -47,9 +42,6 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 47 | private CrmPermissionService crmPermissionService; | 42 | private CrmPermissionService crmPermissionService; |
| 48 | 43 | ||
| 49 | @Resource | 44 | @Resource |
| 50 | - private CrmConcernedService crmConcernedService; | ||
| 51 | - | ||
| 52 | - @Resource | ||
| 53 | private AdminUserApi adminUserApi; | 45 | private AdminUserApi adminUserApi; |
| 54 | 46 | ||
| 55 | @Override | 47 | @Override |
| @@ -156,33 +148,6 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -156,33 +148,6 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 156 | } | 148 | } |
| 157 | 149 | ||
| 158 | @Override | 150 | @Override |
| 159 | - public void concernCustomer(List<Long> ids, Long userId) { | ||
| 160 | - // 1. 校验客户是否存在 | ||
| 161 | - validateCustomerExists(ids); | ||
| 162 | - | ||
| 163 | - // 2. 创建关注 | ||
| 164 | - List<CrmConcernedCreateReqBO> createReqBOs = BeanUtils.toBean(convertList(ids, id -> new CrmConcernedCreateReqBO() | ||
| 165 | - .setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()).setBizId(id).setUserId(userId)), CrmConcernedCreateReqBO.class); | ||
| 166 | - crmConcernedService.createConcernedBatch(createReqBOs); | ||
| 167 | - } | ||
| 168 | - | ||
| 169 | - @Override | ||
| 170 | - public void cancelConcernCustomer(List<Long> ids, Long userId) { | ||
| 171 | - // 1. 校验客户是否存在 | ||
| 172 | - validateCustomerExists(ids); | ||
| 173 | - | ||
| 174 | - // 2. 取消关注 | ||
| 175 | - crmConcernedService.deleteConcerned(CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, userId); | ||
| 176 | - } | ||
| 177 | - | ||
| 178 | - private void validateCustomerExists(List<Long> ids) { | ||
| 179 | - List<CrmCustomerDO> customerList = customerMapper.selectBatchIds(ids); | ||
| 180 | - if (ObjUtil.notEqual(ids.size(), customerList.size())) { | ||
| 181 | - throw exception(CUSTOMER_NOT_EXISTS); | ||
| 182 | - } | ||
| 183 | - } | ||
| 184 | - | ||
| 185 | - @Override | ||
| 186 | @Transactional(rollbackFor = Exception.class) | 151 | @Transactional(rollbackFor = Exception.class) |
| 187 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) | 152 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) |
| 188 | public void putCustomerPool(Long id) { | 153 | public void putCustomerPool(Long id) { |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmQueryPageUtils.java
| @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.util; | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.util; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.util.ObjUtil; | 4 | import cn.hutool.core.util.ObjUtil; |
| 5 | -import cn.iocoder.yudao.module.crm.dal.dataobject.concerned.CrmConcernedDO; | ||
| 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; | 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; |
| 7 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | 6 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 8 | import cn.iocoder.yudao.module.crm.enums.common.CrmSceneEnum; | 7 | import cn.iocoder.yudao.module.crm.enums.common.CrmSceneEnum; |
| @@ -20,8 +19,9 @@ import java.util.Collection; | @@ -20,8 +19,9 @@ import java.util.Collection; | ||
| 20 | */ | 19 | */ |
| 21 | public class CrmQueryPageUtils { | 20 | public class CrmQueryPageUtils { |
| 22 | 21 | ||
| 22 | + // TODO @puhui999:是不是弱化 CrmBasePageReqVO,把 sceneType 作为参数传入。默认其实 pool 不一定要传递的 | ||
| 23 | /** | 23 | /** |
| 24 | - * 构造 crm 数据类型数据分页查询条件 | 24 | + * 构造 CRM 数据类型数据分页查询条件 |
| 25 | * | 25 | * |
| 26 | * @param queryMapper 连表查询对象 | 26 | * @param queryMapper 连表查询对象 |
| 27 | * @param reqVO 查询条件 | 27 | * @param reqVO 查询条件 |
| @@ -30,31 +30,34 @@ public class CrmQueryPageUtils { | @@ -30,31 +30,34 @@ public class CrmQueryPageUtils { | ||
| 30 | * @param bizId 数据编号 | 30 | * @param bizId 数据编号 |
| 31 | * @param subordinateIds 下属用户编号,可为空 | 31 | * @param subordinateIds 下属用户编号,可为空 |
| 32 | */ | 32 | */ |
| 33 | - public static <T extends MPJLambdaWrapper<?>, V extends CrmBasePageReqVO, S> void builderQuery(T queryMapper, V reqVO, Long userId, | ||
| 34 | - Integer bizType, SFunction<S, ?> bizId, | ||
| 35 | - @Nullable Collection<Long> subordinateIds, | ||
| 36 | - Boolean isAdmin) { | ||
| 37 | - // 构建数据权限连表条件 | 33 | + public static <T extends MPJLambdaWrapper<?>, V extends CrmBasePageReqVO, S> void builderQuery( |
| 34 | + T queryMapper, V reqVO, Long userId, | ||
| 35 | + Integer bizType, SFunction<S, ?> bizId, | ||
| 36 | + @Nullable Collection<Long> subordinateIds, // TODO @puhui999:subordinateIds 可以优化成 subordinateUserIds | ||
| 37 | + Boolean isAdmin) { | ||
| 38 | + // TODO @puhui999:是不是特殊处理,让这个 util 有状态,这样 isAdmin 直接从这里读取;subordinateIds 也是;这样,可以简化参数; | ||
| 39 | + // 1. 构建数据权限连表条件 | ||
| 38 | if (ObjUtil.notEqual(isAdmin, Boolean.TRUE)) { // 管理员不需要数据权限 | 40 | if (ObjUtil.notEqual(isAdmin, Boolean.TRUE)) { // 管理员不需要数据权限 |
| 39 | queryMapper.innerJoin(CrmPermissionDO.class, on -> | 41 | queryMapper.innerJoin(CrmPermissionDO.class, on -> |
| 40 | on.eq(CrmPermissionDO::getBizType, bizType).eq(CrmPermissionDO::getBizId, bizId) | 42 | on.eq(CrmPermissionDO::getBizType, bizType).eq(CrmPermissionDO::getBizId, bizId) |
| 41 | .eq(CrmPermissionDO::getUserId, userId)); | 43 | .eq(CrmPermissionDO::getUserId, userId)); |
| 42 | } | 44 | } |
| 45 | + // 2. 拼接公海的查询条件 | ||
| 43 | if (ObjUtil.equal(reqVO.getPool(), Boolean.TRUE)) { // 情况一:公海 | 46 | if (ObjUtil.equal(reqVO.getPool(), Boolean.TRUE)) { // 情况一:公海 |
| 44 | queryMapper.isNull("owner_user_id"); | 47 | queryMapper.isNull("owner_user_id"); |
| 45 | } else { // 情况二:不是公海 | 48 | } else { // 情况二:不是公海 |
| 46 | queryMapper.isNotNull("owner_user_id"); | 49 | queryMapper.isNotNull("owner_user_id"); |
| 47 | } | 50 | } |
| 48 | - // 场景数据过滤 | 51 | + // 3. 拼接场景的查询条件 |
| 52 | + // TODO @puhui999::1 处的数据权限,应该和 3 处的场景是结合的? | ||
| 53 | + // null 时:一种处理 | ||
| 54 | + // 1:一种条件; | ||
| 55 | + // 2:一种条件; | ||
| 56 | + // 3:一种条件; | ||
| 49 | if (CrmSceneEnum.isOwner(reqVO.getSceneType())) { // 场景一:我负责的数据 | 57 | if (CrmSceneEnum.isOwner(reqVO.getSceneType())) { // 场景一:我负责的数据 |
| 50 | queryMapper.eq("owner_user_id", userId); | 58 | queryMapper.eq("owner_user_id", userId); |
| 51 | } | 59 | } |
| 52 | - if (CrmSceneEnum.isFollow(reqVO.getSceneType())) { // 场景二:我关注的数据 | ||
| 53 | - queryMapper.innerJoin(CrmConcernedDO.class, on -> | ||
| 54 | - on.eq(CrmConcernedDO::getBizType, bizType).eq(CrmConcernedDO::getBizId, bizId) | ||
| 55 | - .eq(CrmConcernedDO::getUserId, userId)); | ||
| 56 | - } | ||
| 57 | - // TODO puhui999: 这里有一个疑问:如果下属负责的数据权限中没有自己的话还能看吗? | 60 | + // TODO puhui999: 这里有一个疑问:如果下属负责的数据权限中没有自己的话还能看吗?回复:不能 |
| 58 | if (CrmSceneEnum.isSubordinate(reqVO.getSceneType()) && CollUtil.isNotEmpty(subordinateIds)) { // 场景三:下属负责的数据 | 61 | if (CrmSceneEnum.isSubordinate(reqVO.getSceneType()) && CollUtil.isNotEmpty(subordinateIds)) { // 场景三:下属负责的数据 |
| 59 | queryMapper.in("owner_user_id", subordinateIds); | 62 | queryMapper.in("owner_user_id", subordinateIds); |
| 60 | } | 63 | } |
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java
| @@ -23,6 +23,7 @@ public interface AdminUserApi { | @@ -23,6 +23,7 @@ public interface AdminUserApi { | ||
| 23 | */ | 23 | */ |
| 24 | AdminUserRespDTO getUser(Long id); | 24 | AdminUserRespDTO getUser(Long id); |
| 25 | 25 | ||
| 26 | + // TODO @puhui999:这里返回 List<AdminUserRespDTO> 方法名可以改成 getUserListBySubordinate | ||
| 26 | /** | 27 | /** |
| 27 | * 通过用户 ID 查询用户下属 | 28 | * 通过用户 ID 查询用户下属 |
| 28 | * | 29 | * |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java
| 1 | package cn.iocoder.yudao.module.system.api.user; | 1 | package cn.iocoder.yudao.module.system.api.user; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 4 | import cn.hutool.core.util.ObjUtil; | 3 | import cn.hutool.core.util.ObjUtil; |
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 5 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 5 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 6 | -import cn.iocoder.yudao.module.system.convert.user.UserConvert; | ||
| 7 | import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; |
| 8 | import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; | 7 | import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; |
| 9 | import cn.iocoder.yudao.module.system.service.dept.DeptService; | 8 | import cn.iocoder.yudao.module.system.service.dept.DeptService; |
| @@ -46,6 +45,8 @@ public class AdminUserApiImpl implements AdminUserApi { | @@ -46,6 +45,8 @@ public class AdminUserApiImpl implements AdminUserApi { | ||
| 46 | 45 | ||
| 47 | Set<Long> subordinateIds = null; // 下属用户编号 | 46 | Set<Long> subordinateIds = null; // 下属用户编号 |
| 48 | DeptDO dept = deptService.getDept(user.getDeptId()); | 47 | DeptDO dept = deptService.getDept(user.getDeptId()); |
| 48 | + // TODO @puhui999:需要递归查询到子部门;并且要排除到自己噢。 | ||
| 49 | + // TODO @puhui999:保持 if return 原则,这里其实要判断不等于,则返回 null;最好返回 空集合,上面也是 | ||
| 49 | if (ObjUtil.equal(dept.getLeaderUserId(), id)) { // 校验是否是该部门的负责人 | 50 | if (ObjUtil.equal(dept.getLeaderUserId(), id)) { // 校验是否是该部门的负责人 |
| 50 | List<AdminUserDO> users = userService.getUserListByDeptIds(Collections.singletonList(dept.getId())); | 51 | List<AdminUserDO> users = userService.getUserListByDeptIds(Collections.singletonList(dept.getId())); |
| 51 | subordinateIds = convertSet(users, AdminUserDO::getId); | 52 | subordinateIds = convertSet(users, AdminUserDO::getId); |