package com.ningdatech.carapi.company.enumeration;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * <p>
 * ProductCompanyType
 * </p>
 *
 * @author WendyYang
 * @since 16:43 2022/11/3
 */
@Getter
public enum ProductCompanyType {
    /**
     * 生产企业类型
     */
    MORTAR(2L, "预拌砂浆生产企业"),
    CONCRETE(3L, "预拌混凝土生产企业"),
    CEMENT(4L,"水泥生产企业");

    private final Long code;
    private final String value;

    ProductCompanyType(Long code, String value) {
        this.code = code;
        this.value = value;
    }

    public static String getDescByCode(Long code) {
        if(Objects.isNull(code)){
            return StringUtils.EMPTY;
        }
        for (ProductCompanyType t : ProductCompanyType.values()) {
            if (code.equals(t.getCode())) {
                return t.value;
            }
        }
        return StringUtils.EMPTY;
    }

    public static Long getCodeByDesc(String desc) {
        if(Objects.isNull(desc)){
            return null;
        }
        for (ProductCompanyType t : ProductCompanyType.values()) {
            if (desc.equals(t.getValue())) {
                return t.code;
            }
        }
        return null;
    }

}
