feat(REQ-3488): 删除多余的枚举

This commit is contained in:
zhanghonghao 2025-01-02 11:02:57 +08:00
parent f4cbf00742
commit 6d39e24827

View File

@ -1,94 +0,0 @@
package cn.axzo.orgmanax.dto.unit.enums;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 组织节点类型枚举
*
* @author zhangran
* @since 2022/5/22 19:50
**/
@Getter
@AllArgsConstructor
public enum OrganizationalNodeTypeEnum {
/**
* 默认单位位为65535
*/
ALL_TYPE(0, "默认节点类型", 65535),
/**
* 部门(团队也归属于部门)
*/
DEPARTMENT(1, "部门", 1),
/**
* 平台班组
*/
TEAM(2, "平台班组", 2),
/**
* 小组
*/
GROUP(3, "小组", 3),
/**
* 项目内班组
*/
PROJECT_TEAM(4, "项目内班组", 4),
/**
* 项目内小组
*/
PROJECT_GROUP(5, "项目内小组", 5),
;
@JsonValue
private final Integer value;
private final String desc;
private final Integer bitValue;
private static Map<Integer, OrganizationalNodeTypeEnum> bitMap;
public boolean isSameOrChildNodeType(Integer nodeType) {
OrganizationalNodeTypeEnum typeByeCode = getByNodeType(nodeType);
if (typeByeCode == null) {
return false;
}
return isSameOrChildNodeType(typeByeCode);
}
public boolean isSameOrChildNodeType(OrganizationalNodeTypeEnum type) {
if (this == type)
return true;
if (this == OrganizationalNodeTypeEnum.PROJECT_TEAM)
return type == OrganizationalNodeTypeEnum.PROJECT_GROUP;
return false;
}
public static OrganizationalNodeTypeEnum bitValueOf(Integer valueBit) {
if (valueBit == null) {
return null;
}
if (bitMap == null) {
bitMap = Arrays.stream(values())
.collect(
Collectors.toMap(OrganizationalNodeTypeEnum::getBitValue, Function.identity()));
}
return bitMap.get(valueBit);
}
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public static OrganizationalNodeTypeEnum getByNodeType(Integer value) {
return Arrays.stream(values()).filter(o -> o.getValue().equals(value)).findFirst()
.orElse(null);
}
}