package com.fs.his.enums.hsyy;

/**
 * @Author：peicj
 * @Description: 学历代码
 * @Date：2026/1/5 11:21
 */
public enum EducationLevel {

    DOCTORAL_GRADUATE(11, "博士研究生"),
    MASTER_GRADUATE(14, "硕士研究生"),
    BACHELOR(21, "本科"),
    ASSOCIATE(31, "专科"),
    OTHER(90, "其他");

    private final int code;
    private final String description;

    EducationLevel(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    // 根据code获取枚举
    public static EducationLevel fromCode(int code) {
        for (EducationLevel level : values()) {
            if (level.code == code) {
                return level;
            }
        }
        return OTHER; // 默认返回其他
    }

    // 根据code获取描述
    public static String getDescriptionByCode(int code) {
        return fromCode(code).getDescription();
    }
    // 根据描述获取code
    public static int getCodeByDescription(String description) {
        for (EducationLevel level : values()) {
            if (level.description.equals(description)) {
                return level.code;
            }
        }
        return OTHER.code;
    }
}
