package com.ningdatech.carapi.company.enumeration;

import org.apache.commons.lang3.StringUtils;

import lombok.Getter;

/**
 * CompanyCreditLevelEnum
 * @return
 * @author CMM
 * @since 2023/05/26 13:36
 */
@Getter
public enum CompanyCreditLevelEnum {
    /**
     * 企业信用等级
     */
    A("A", "信用优秀"),
    B("B", "信用良好"),
    C("C","信用一般"),
    D("D","信用较差"),
    E("E","信用差");

    private final String code;
    private final String desc;

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

    public static String getDescByCode(String code) {
        if(StringUtils.isBlank(code)){
            return StringUtils.EMPTY;
        }
        for (CompanyCreditLevelEnum t : CompanyCreditLevelEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }

    public static String getCodeByDesc(String desc) {
        if(StringUtils.isBlank(desc)){
            return null;
        }
        for (CompanyCreditLevelEnum t : CompanyCreditLevelEnum.values()) {
            if (desc.equals(t.getDesc())) {
                return t.code;
            }
        }
        return null;
    }

}
