package com.ruoyi.info.collection.enums;

/**
 * 企业来源枚举
 *
 * @author ruoyi
 */
public enum EnterpriseSource {

    GENERAL("GENERAL", "一般企业"),
    EMP_RELATION("EMP_RELATION", "员工关系人"),
    CREDIT_CUSTOMER("CREDIT_CUSTOMER", "信贷客户"),
    SUPPLIER("SUPPLIER", "供应商"),
    INTERMEDIARY("INTERMEDIARY", "中介"),
    BOTH("BOTH", "兼有");

    private final String code;
    private final String desc;

    EnterpriseSource(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(String code) {
        for (EnterpriseSource value : values()) {
            if (value.code.equals(code)) {
                return value.desc;
            }
        }
        return null;
    }

    public static boolean contains(String code) {
        for (EnterpriseSource value : values()) {
            if (value.code.equals(code)) {
                return true;
            }
        }
        return false;
    }

    public static String resolveCode(String value) {
        for (EnterpriseSource item : values()) {
            if (item.code.equals(value) || item.desc.equals(value)) {
                return item.code;
            }
        }
        return null;
    }
}
