mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-13 18:45:06 +08:00
crm: 完善数据权限的逻辑
This commit is contained in:
@ -0,0 +1,48 @@
|
||||
package cn.iocoder.yudao.module.crm.enums.common;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* CRM 业务类型枚举
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum CrmBizTypeEnum implements IntArrayValuable {
|
||||
|
||||
CRM_LEADS(1, "线索"),
|
||||
CRM_CUSTOMER(2, "客户"),
|
||||
CRM_CONTACTS(3, "联系人"),
|
||||
CRM_BUSINESS(4, "商机"),
|
||||
CRM_CONTRACT(5, "合同");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBizTypeEnum::getType).toArray();
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final Integer type;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
public static String getNameByType(Integer type) {
|
||||
CrmBizTypeEnum typeEnum = CollUtil.findOne(CollUtil.newArrayList(CrmBizTypeEnum.values()),
|
||||
item -> ObjUtil.equal(item.type, type));
|
||||
return typeEnum == null ? null : typeEnum.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.crm.enums.permission;
|
||||
|
||||
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 HUIHUI
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CrmPermissionLevelEnum implements IntArrayValuable {
|
||||
|
||||
OWNER(1, "负责人"),
|
||||
READ(2, "读"),
|
||||
WRITE(3, "写");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmPermissionLevelEnum::getLevel).toArray();
|
||||
|
||||
/**
|
||||
* 级别
|
||||
*/
|
||||
private final Integer level;
|
||||
/**
|
||||
* 级别名称
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
public static boolean isOwner(Integer level) {
|
||||
return ObjUtil.equal(OWNER.level, level);
|
||||
}
|
||||
|
||||
public static boolean isRead(Integer level) {
|
||||
return ObjUtil.equal(READ.level, level);
|
||||
}
|
||||
|
||||
public static boolean isWrite(Integer level) {
|
||||
return ObjUtil.equal(WRITE.level, level);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user