package com.bonus.zlpt.company.api.enums;

/**
 * 企业类似枚举类
 */
public enum CompanyTypeEnum {

    /** 社会企业 */
    SOCIAL_ENTERpRISE(2, "社会企业"),
    /** 南网集团企业 */
    NAN_WANG(3, "南网集团企业"),
    /** 南网控股企业 */
    NANWANG_COMPANY(4, "南网控股企业");

    private final Integer code;
    private final String name;

    CompanyTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    /**
     * 根据code获取name
     * @param code
     * @return
     */
    public static String getNameByCode(int code) {
        CompanyTypeEnum[] companyTypeEnums = values();
        for (CompanyTypeEnum companyLtdEnum : companyTypeEnums) {
            if (companyLtdEnum.getCode() == code) {
                return companyLtdEnum.getName();
            }
        }
        return null;
    }

    /**
     *
     * @param msg
     * @return
     */
    public static Integer getCodeByName(String msg) {
        CompanyTypeEnum[] companyLtdEnums = values();
        for (CompanyTypeEnum companyLtdEnum : companyLtdEnums) {
            if (companyLtdEnum.getName() == msg) {
                return companyLtdEnum.getCode();
            }
        }
        return null;
    }

}
