package top.tqx.demo_1.enums;

public enum DeptTypeEnum {
    HEADQUARTERS("HEADQUARTERS", "总公司", 1),
    BRANCH("BRANCH", "分公司", 2),
    DEPARTMENT("DEPARTMENT", "部门", 3);

    private final String code;
    private final String name;
    private final int level;

    DeptTypeEnum(String code, String name, int level) {
        this.code = code;
        this.name = name;
        this.level = level;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public int getLevel() {
        return level;
    }

    public static DeptTypeEnum getByCode(String code) {
        for (DeptTypeEnum type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return null;
    }
}