crm: 完善数据权限的逻辑

This commit is contained in:
YunaiV
2023-11-30 13:42:36 +08:00
parent 53b8e37f36
commit fe4b51b9ad
22 changed files with 52 additions and 49 deletions

View File

@ -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;
}
}

View File

@ -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);
}
}