mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-02-20 19:20:32 +08:00
📈 CRM:code review 数据权限
This commit is contained in:
parent
d430063eec
commit
3707662187
@ -72,7 +72,4 @@ public interface ErrorCodeConstants {
|
||||
// ========== 客户公海规则设置 1_020_012_000 ==========
|
||||
ErrorCode CUSTOMER_LIMIT_CONFIG_NOT_EXISTS = new ErrorCode(1_020_012_000, "客户限制配置不存在");
|
||||
|
||||
// ========== 关注的数据 1_020_013_000 ==========
|
||||
ErrorCode CRM_CONCERNED_NOT_EXISTS = new ErrorCode(1_020_013_000, "关注数据不存在");
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
// TODO @puhui999:这个枚举,要不改成 CrmSceneTypeEnum
|
||||
/**
|
||||
* CRM 列表检索场景
|
||||
*
|
||||
@ -18,6 +19,7 @@ public enum CrmSceneEnum implements IntArrayValuable {
|
||||
|
||||
OWNER(1, "我负责的"),
|
||||
FOLLOW(2, "我关注的"),
|
||||
// TODO @puhui999:还有一个我参与的
|
||||
SUBORDINATE(3, "下属负责的");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneEnum::getType).toArray();
|
||||
|
@ -139,24 +139,6 @@ public class CrmCustomerController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/concern")
|
||||
@Operation(summary = "关注客户")
|
||||
@Parameter(name = "ids", description = "编号", required = true, example = "[1024]")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
||||
public CommonResult<Boolean> concernCustomer(@RequestParam("ids") List<Long> ids) {
|
||||
customerService.concernCustomer(ids, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/cancel-concern")
|
||||
@Operation(summary = "取消关注客户")
|
||||
@Parameter(name = "ids", description = "编号", required = true, example = "[1024]")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
||||
public CommonResult<Boolean> cancelConcernCustomer(@RequestParam("ids") List<Long> ids) {
|
||||
customerService.cancelConcernCustomer(ids, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// ==================== 公海相关操作 ====================
|
||||
|
||||
@PutMapping("/put-pool")
|
||||
|
@ -1,51 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.dataobject.concerned;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* CRM 关注的数据 DO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@TableName("crm_concerned")
|
||||
@KeySequence("crm_concerned_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CrmConcernedDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号,主键自增
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 数据类型
|
||||
*
|
||||
* 枚举 {@link CrmBizTypeEnum}
|
||||
*/
|
||||
private Integer bizType;
|
||||
/**
|
||||
* 数据编号
|
||||
*
|
||||
* 关联 {@link CrmBizTypeEnum} 对应模块 DO 的 id 字段
|
||||
*/
|
||||
private Long bizId;
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*
|
||||
* 关联 AdminUser 的 id 字段
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.mysql.concerned;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.concerned.CrmConcernedDO;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* CRM 关注的数据 Mapper
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Mapper
|
||||
public interface CrmConcernedMapper extends BaseMapperX<CrmConcernedDO> {
|
||||
|
||||
/**
|
||||
* 查询用户关注的数据
|
||||
*
|
||||
* @param bizType 数据类型,关联 {@link CrmBizTypeEnum}
|
||||
* @param bizIds 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId()
|
||||
* @param userId 用户编号
|
||||
* @return 关注的数据
|
||||
*/
|
||||
default List<CrmConcernedDO> selectList(Integer bizType, Collection<Long> bizIds, Long userId) {
|
||||
return selectList(new LambdaQueryWrapperX<CrmConcernedDO>()
|
||||
.eq(CrmConcernedDO::getBizType, bizType)
|
||||
.in(CrmConcernedDO::getBizId, bizIds)
|
||||
.eq(CrmConcernedDO::getUserId, userId));
|
||||
}
|
||||
|
||||
}
|
@ -45,14 +45,14 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
|
||||
// 构建数据权限连表条件
|
||||
CrmQueryPageUtils.builderQuery(mpjLambdaWrapperX, pageReqVO, userId,
|
||||
CrmBizTypeEnum.CRM_CUSTOMER.getType(), CrmCustomerDO::getId, subordinateIds, isAdmin);
|
||||
mpjLambdaWrapperX
|
||||
.selectAll(CrmCustomerDO.class)
|
||||
mpjLambdaWrapperX.selectAll(CrmCustomerDO.class)
|
||||
.likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName())
|
||||
.eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile())
|
||||
.eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId())
|
||||
.eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel())
|
||||
.eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource());
|
||||
// 特殊:不分页,直接查询全部
|
||||
// TODO @puhui999:下面这个,封装一个方法;从 56 到 61 这里哈;
|
||||
if (PageParam.PAGE_SIZE_NONE.equals(pageReqVO.getPageNo())) {
|
||||
List<CrmCustomerDO> list = selectJoinList(CrmCustomerDO.class, mpjLambdaWrapperX);
|
||||
return new PageResult<>(list, (long) list.size());
|
||||
|
@ -13,9 +13,7 @@ import lombok.EqualsAndHashCode;
|
||||
public class CrmBasePageReqVO extends PageParam {
|
||||
|
||||
/**
|
||||
* 场景类型, 为 null 时则表示全部
|
||||
*
|
||||
* 关联 {@link CrmSceneEnum}
|
||||
* 场景类型,为 null 时则表示全部
|
||||
*/
|
||||
@Schema(description = "场景类型", example = "1")
|
||||
@InEnum(CrmSceneEnum.class)
|
||||
|
@ -1,40 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.service.concerned;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.service.concerned.bo.CrmConcernedCreateReqBO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* CRM 关注的数据 Service 接口
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
public interface CrmConcernedService {
|
||||
|
||||
/**
|
||||
* 创建关注数据
|
||||
*
|
||||
* @param createReqBO 创建请求
|
||||
* @return 编号
|
||||
*/
|
||||
Long createConcerned(@Valid CrmConcernedCreateReqBO createReqBO);
|
||||
|
||||
/**
|
||||
* 批量创建关注数据
|
||||
*
|
||||
* @param createReqBO 创建请求
|
||||
*/
|
||||
void createConcernedBatch(@Valid Collection<CrmConcernedCreateReqBO> createReqBO);
|
||||
|
||||
/**
|
||||
* 删除关注数据
|
||||
*
|
||||
* @param bizType 数据类型,关联 {@link CrmBizTypeEnum}
|
||||
* @param bizIds 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId()
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void deleteConcerned(Integer bizType, Collection<Long> bizIds, Long userId);
|
||||
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.service.concerned;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.concerned.CrmConcernedDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.concerned.CrmConcernedMapper;
|
||||
import cn.iocoder.yudao.module.crm.service.concerned.bo.CrmConcernedCreateReqBO;
|
||||
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;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_CONCERNED_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* CRM 关注的数据 Service 接口实现类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class CrmConcernedServiceImpl implements CrmConcernedService {
|
||||
|
||||
@Resource
|
||||
private CrmConcernedMapper concernedMapper;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createConcerned(CrmConcernedCreateReqBO createReqBO) {
|
||||
// 1. 校验用户是否存在
|
||||
adminUserApi.validateUserList(Collections.singletonList(createReqBO.getUserId()));
|
||||
|
||||
// 2. 创建
|
||||
CrmConcernedDO concerned = BeanUtils.toBean(createReqBO, CrmConcernedDO.class);
|
||||
concernedMapper.insert(concerned);
|
||||
return concerned.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createConcernedBatch(Collection<CrmConcernedCreateReqBO> createReqBO) {
|
||||
// 1. 校验用户是否存在
|
||||
adminUserApi.validateUserList(convertSet(createReqBO, CrmConcernedCreateReqBO::getUserId));
|
||||
|
||||
// 2. 创建
|
||||
List<CrmConcernedDO> concernedList = convertList(createReqBO, item -> BeanUtils.toBean(item, CrmConcernedDO.class));
|
||||
concernedMapper.insertBatch(concernedList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteConcerned(Integer bizType, Collection<Long> bizIds, Long userId) {
|
||||
// 1. 查询关注数据
|
||||
List<CrmConcernedDO> concernedList = concernedMapper.selectList(bizType, bizIds, userId);
|
||||
if (ObjUtil.notEqual(bizIds.size(), concernedList.size())) {
|
||||
throw exception(CRM_CONCERNED_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 删除
|
||||
concernedMapper.deleteBatchIds(convertList(concernedList, CrmConcernedDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.service.concerned.bo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* CRM 关注的数据 Create Req BO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Data
|
||||
public class CrmConcernedCreateReqBO {
|
||||
|
||||
/**
|
||||
* 当前登录用户编号
|
||||
*/
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* Crm 类型
|
||||
*/
|
||||
@NotNull(message = "Crm 类型不能为空")
|
||||
@InEnum(CrmBizTypeEnum.class)
|
||||
private Integer bizType;
|
||||
/**
|
||||
* 数据编号
|
||||
*/
|
||||
@NotNull(message = "Crm 数据编号不能为空")
|
||||
private Long bizId;
|
||||
|
||||
}
|
@ -90,22 +90,6 @@ public interface CrmCustomerService {
|
||||
*/
|
||||
void lockCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 关注客户
|
||||
*
|
||||
* @param ids 客户编号
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void concernCustomer(List<Long> ids, Long userId);
|
||||
|
||||
/**
|
||||
* 取消关注客户
|
||||
*
|
||||
* @param ids 客户编号
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void cancelConcernCustomer(List<Long> ids, Long userId);
|
||||
|
||||
// ==================== 公海相关操作 ====================
|
||||
|
||||
/**
|
||||
|
@ -1,9 +1,7 @@
|
||||
package cn.iocoder.yudao.module.crm.service.customer;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
|
||||
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;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.service.concerned.CrmConcernedService;
|
||||
import cn.iocoder.yudao.module.crm.service.concerned.bo.CrmConcernedCreateReqBO;
|
||||
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;
|
||||
@ -27,7 +23,6 @@ import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
@ -46,9 +41,6 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
@Resource
|
||||
private CrmPermissionService crmPermissionService;
|
||||
|
||||
@Resource
|
||||
private CrmConcernedService crmConcernedService;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@ -155,33 +147,6 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
customerMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void concernCustomer(List<Long> ids, Long userId) {
|
||||
// 1. 校验客户是否存在
|
||||
validateCustomerExists(ids);
|
||||
|
||||
// 2. 创建关注
|
||||
List<CrmConcernedCreateReqBO> createReqBOs = BeanUtils.toBean(convertList(ids, id -> new CrmConcernedCreateReqBO()
|
||||
.setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()).setBizId(id).setUserId(userId)), CrmConcernedCreateReqBO.class);
|
||||
crmConcernedService.createConcernedBatch(createReqBOs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelConcernCustomer(List<Long> ids, Long userId) {
|
||||
// 1. 校验客户是否存在
|
||||
validateCustomerExists(ids);
|
||||
|
||||
// 2. 取消关注
|
||||
crmConcernedService.deleteConcerned(CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, userId);
|
||||
}
|
||||
|
||||
private void validateCustomerExists(List<Long> ids) {
|
||||
List<CrmCustomerDO> customerList = customerMapper.selectBatchIds(ids);
|
||||
if (ObjUtil.notEqual(ids.size(), customerList.size())) {
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
||||
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.concerned.CrmConcernedDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneEnum;
|
||||
@ -20,8 +19,9 @@ import java.util.Collection;
|
||||
*/
|
||||
public class CrmQueryPageUtils {
|
||||
|
||||
// TODO @puhui999:是不是弱化 CrmBasePageReqVO,把 sceneType 作为参数传入。默认其实 pool 不一定要传递的
|
||||
/**
|
||||
* 构造 crm 数据类型数据分页查询条件
|
||||
* 构造 CRM 数据类型数据分页查询条件
|
||||
*
|
||||
* @param queryMapper 连表查询对象
|
||||
* @param reqVO 查询条件
|
||||
@ -30,31 +30,34 @@ public class CrmQueryPageUtils {
|
||||
* @param bizId 数据编号
|
||||
* @param subordinateIds 下属用户编号,可为空
|
||||
*/
|
||||
public static <T extends MPJLambdaWrapper<?>, V extends CrmBasePageReqVO, S> void builderQuery(T queryMapper, V reqVO, Long userId,
|
||||
Integer bizType, SFunction<S, ?> bizId,
|
||||
@Nullable Collection<Long> subordinateIds,
|
||||
Boolean isAdmin) {
|
||||
// 构建数据权限连表条件
|
||||
public static <T extends MPJLambdaWrapper<?>, V extends CrmBasePageReqVO, S> void builderQuery(
|
||||
T queryMapper, V reqVO, Long userId,
|
||||
Integer bizType, SFunction<S, ?> bizId,
|
||||
@Nullable Collection<Long> subordinateIds, // TODO @puhui999:subordinateIds 可以优化成 subordinateUserIds
|
||||
Boolean isAdmin) {
|
||||
// TODO @puhui999:是不是特殊处理,让这个 util 有状态,这样 isAdmin 直接从这里读取;subordinateIds 也是;这样,可以简化参数;
|
||||
// 1. 构建数据权限连表条件
|
||||
if (ObjUtil.notEqual(isAdmin, Boolean.TRUE)) { // 管理员不需要数据权限
|
||||
queryMapper.innerJoin(CrmPermissionDO.class, on ->
|
||||
on.eq(CrmPermissionDO::getBizType, bizType).eq(CrmPermissionDO::getBizId, bizId)
|
||||
.eq(CrmPermissionDO::getUserId, userId));
|
||||
}
|
||||
// 2. 拼接公海的查询条件
|
||||
if (ObjUtil.equal(reqVO.getPool(), Boolean.TRUE)) { // 情况一:公海
|
||||
queryMapper.isNull("owner_user_id");
|
||||
} else { // 情况二:不是公海
|
||||
queryMapper.isNotNull("owner_user_id");
|
||||
}
|
||||
// 场景数据过滤
|
||||
// 3. 拼接场景的查询条件
|
||||
// TODO @puhui999::1 处的数据权限,应该和 3 处的场景是结合的?
|
||||
// null 时:一种处理
|
||||
// 1:一种条件;
|
||||
// 2:一种条件;
|
||||
// 3:一种条件;
|
||||
if (CrmSceneEnum.isOwner(reqVO.getSceneType())) { // 场景一:我负责的数据
|
||||
queryMapper.eq("owner_user_id", userId);
|
||||
}
|
||||
if (CrmSceneEnum.isFollow(reqVO.getSceneType())) { // 场景二:我关注的数据
|
||||
queryMapper.innerJoin(CrmConcernedDO.class, on ->
|
||||
on.eq(CrmConcernedDO::getBizType, bizType).eq(CrmConcernedDO::getBizId, bizId)
|
||||
.eq(CrmConcernedDO::getUserId, userId));
|
||||
}
|
||||
// TODO puhui999: 这里有一个疑问:如果下属负责的数据权限中没有自己的话还能看吗?
|
||||
// TODO puhui999: 这里有一个疑问:如果下属负责的数据权限中没有自己的话还能看吗?回复:不能
|
||||
if (CrmSceneEnum.isSubordinate(reqVO.getSceneType()) && CollUtil.isNotEmpty(subordinateIds)) { // 场景三:下属负责的数据
|
||||
queryMapper.in("owner_user_id", subordinateIds);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ public interface AdminUserApi {
|
||||
*/
|
||||
AdminUserRespDTO getUser(Long id);
|
||||
|
||||
// TODO @puhui999:这里返回 List<AdminUserRespDTO> 方法名可以改成 getUserListBySubordinate
|
||||
/**
|
||||
* 通过用户 ID 查询用户下属
|
||||
*
|
||||
|
@ -1,9 +1,8 @@
|
||||
package cn.iocoder.yudao.module.system.api.user;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import cn.iocoder.yudao.module.system.convert.user.UserConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||
@ -46,6 +45,8 @@ public class AdminUserApiImpl implements AdminUserApi {
|
||||
|
||||
Set<Long> subordinateIds = null; // 下属用户编号
|
||||
DeptDO dept = deptService.getDept(user.getDeptId());
|
||||
// TODO @puhui999:需要递归查询到子部门;并且要排除到自己噢。
|
||||
// TODO @puhui999:保持 if return 原则,这里其实要判断不等于,则返回 null;最好返回 空集合,上面也是
|
||||
if (ObjUtil.equal(dept.getLeaderUserId(), id)) { // 校验是否是该部门的负责人
|
||||
List<AdminUserDO> users = userService.getUserListByDeptIds(Collections.singletonList(dept.getId()));
|
||||
subordinateIds = convertSet(users, AdminUserDO::getId);
|
||||
|
Loading…
Reference in New Issue
Block a user