package com.ruoyi.common.enums;

import com.ruoyi.common.utils.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 处理数据类型
 * 数据类型（院校线college，专业线profession，招生计划plan，提前批pre）
 * @author voluntarydata
 */
public enum ProcessDataType
{
    college("college", "院校线"),
    profession("profession", "专业线"),
    plan("plan", "招生计划"),
    pre("pre", "提前批"),
    planAll("planAll", "招生计划"),
    planDetail("planDetail", "招生计划"),
    professionAll("professionAll", "专业线"),
    professionDetail("professionDetail", "专业线"),
    ;

    private final String code;
    private final String info;

    ProcessDataType(String code, String info)
    {
        this.code = code;
        this.info = info;
    }

    public String getCode()
    {
        return code;
    }

    public String getInfo()
    {
        return info;
    }

    private static Map<String, ProcessDataType> codeMaps = new HashMap<>();
    private static Map<String, ProcessDataType> maps = new HashMap<>();
    static {
        for (ProcessDataType t : values()) {
            maps.put(t.name(), t);
            codeMaps.put(t.code, t);
        }
    }

    public static ProcessDataType getByCode(String code) {
        return codeMaps.get(code);
    }

    public static Boolean isPlan(String val){
        if(StringUtils.isEmpty(val)){
            return false;
        }
        return val.equalsIgnoreCase(plan.name());
    }

    public static Boolean isProfession(String val){
        if(StringUtils.isEmpty(val)){
            return false;
        }
        return val.equalsIgnoreCase(profession.name());
    }

    public static Boolean isCollege(String val){
        if(StringUtils.isEmpty(val)){
            return false;
        }
        return val.equalsIgnoreCase(college.name());
    }

    public static Boolean isPre(String val){
        if(StringUtils.isEmpty(val)){
            return false;
        }
        return val.equalsIgnoreCase(pre.name());
    }
}
