package com.ningdatech.carapi.company.enumeration;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * 企业失信类型枚举
 * @author CMM
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "CompanyBlackListTypeEnum", description = "企业失信类型-枚举")
public enum CompanyBlackListTypeEnum {
    /**
     * 存在不正当竞争关系
     */

    UNFAIR_COMPETITION_RELATION(0, "存在不正当竞争关系"),

    /**
     * 重大质量事故
     */
    MAJOR_QUALITY_ACCIDENT(1, "重大质量事故"),

    /**
     * 严重扰乱市场秩序
     */
    DISRUPT_MARKET_ORDER(2,"严重扰乱市场秩序"),

    /**
     * 严重环保问题
     */
    ENVIRONMENTAL_PROBLEMS(3,"严重环保问题");


    private Integer code;
    private String desc;

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static String getDescByCode(Integer code) {
        if(Objects.isNull(code)){
            return StringUtils.EMPTY;
        }
        for (CompanyBlackListTypeEnum t : CompanyBlackListTypeEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }

    public static CompanyBlackListTypeEnum getEnumByValue(Integer code) {
        if(Objects.isNull(code)){
            return null;
        }
        for (CompanyBlackListTypeEnum t : CompanyBlackListTypeEnum.values()) {
            if (code.equals(t.getCode())) {
                return t;
            }
        }
        return null;
    }

    public boolean eq(String val) {
        return this.name().equals(val);
    }
}
