package net.educoder.ecsonar.enums;

/**
 * @Author: youys
 * @Date: 2022/12/20
 * @Description: 严重程度
 */
public enum DegreeEnum {

    All(0, "ALL", "全部"),
    Blocker(1, "BLOCKER", "阻断"),
    Critical(2, "CRITICAL", "严重"),
    Major(3, "MAJOR", "主要"),
    Minor(4, "MINOR", "次要"),
    Info(5, "INFO", "提示");


    /**
     * 传值类型
     */
    private Integer type;
    /**
     * 对应数据库类型
     */
    private String value;
    /**
     * 描述
     */
    private String desc;

    DegreeEnum(Integer type, String value, String desc) {
        this.type = type;
        this.value = value;
        this.desc = desc;
    }


    public static DegreeEnum getDegreeEnum(Integer type) {
        for (DegreeEnum de : values()) {
            if (de.type.equals(type)) {
                return de;
            }
        }
        throw new RuntimeException("Not Found DegreeEnum by type=" + type);
    }

    public static DegreeEnum getDegreeEnumByValue(String value) {
        for (DegreeEnum de : values()) {
            if (de.value.equals(value)) {
                return de;
            }
        }
        throw new RuntimeException("Not Found DegreeEnum by value=" + value);
    }


    public Integer getType() {
        return type;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }
}
