mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
CRM-客户:添加分页数据场景过滤
This commit is contained in:
parent
388e07c834
commit
f4c92089e5
@ -0,0 +1,46 @@
|
||||
package cn.iocoder.yudao.module.crm.enums.customer;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* CRM 客户等级
|
||||
*
|
||||
* @author Wanwan
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CrmCustomerSceneEnum implements IntArrayValuable {
|
||||
|
||||
OWNER(1, "我负责的客户"),
|
||||
FOLLOW(2, "我关注的客户");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerSceneEnum::getType).toArray();
|
||||
|
||||
/**
|
||||
* 场景类型
|
||||
*/
|
||||
private final Integer type;
|
||||
/**
|
||||
* 场景名称
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
public static boolean isOwner(Integer type) {
|
||||
return ObjUtil.equal(OWNER.getType(), type);
|
||||
}
|
||||
|
||||
public static boolean isFollow(Integer type) {
|
||||
return ObjUtil.equal(FOLLOW.getType(), type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerSceneEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -27,5 +28,10 @@ public class CrmCustomerPageReqVO extends PageParam {
|
||||
@Schema(description = "客户来源", example = "1")
|
||||
private Integer source;
|
||||
|
||||
// TODO @芋艿:场景;
|
||||
/**
|
||||
* 场景类型,关联 {@link CrmCustomerSceneEnum}
|
||||
*/
|
||||
@Schema(description = "场景类型", example = "1")
|
||||
private Integer sceneType;
|
||||
|
||||
}
|
||||
|
@ -59,9 +59,9 @@ public class CrmPermissionAspect {
|
||||
@Before("@annotation(crmPermission)")
|
||||
public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) throws NoSuchMethodException {
|
||||
// TODO 芋艿:临时,方便大家调试
|
||||
//if (true) {
|
||||
// return;
|
||||
//}
|
||||
if (true) {
|
||||
return;
|
||||
}
|
||||
KeyValue<Long, Integer> bizIdAndBizType = getBizIdAndBizType(joinPoint, crmPermission);
|
||||
Integer bizType = bizIdAndBizType.getValue(); // 模块类型
|
||||
Long bizId = bizIdAndBizType.getKey(); // 模块数据编号
|
||||
|
@ -3,11 +3,13 @@ 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.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper;
|
||||
import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerSceneEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum;
|
||||
@ -100,6 +102,10 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
// 1.2 获取当前用户能看的分页数据
|
||||
List<CrmPermissionDO> permissions = crmPermissionService.getPermissionListByBizTypeAndUserId(
|
||||
CrmBizTypeEnum.CRM_CUSTOMER.getType(), userId);
|
||||
// 1.3 TODO 场景数据过滤
|
||||
if (CrmCustomerSceneEnum.isOwner(pageReqVO.getSceneType())) { // 场景一:我负责的数据
|
||||
permissions = CollectionUtils.filterList(permissions, item -> CrmPermissionLevelEnum.isOwner(item.getLevel()));
|
||||
}
|
||||
Set<Long> ids = convertSet(permissions, CrmPermissionDO::getBizId);
|
||||
if (CollUtil.isEmpty(ids)) { // 没得说明没有什么给他看的
|
||||
return PageResult.empty();
|
||||
|
Loading…
Reference in New Issue
Block a user