package com.ningdatech.carapi.industry.enums;

import com.ningdatech.carapi.common.constant.GenderEnum;
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 PoffyZhang
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "AbnormalDataTypeEnum", description = "异常数据类型-枚举")
public enum AbnormalDataTypeEnum {
    /**
     * 运政
     */
    TRANSPORT_ADMINISTRATION(1, "运政"),

    /**
     *运营商
     */
    OPERATOR(2, "运营商"),

    /**
     * 电子路单
     */
    ELECTRONIC_WAYBILL(3, "电子路单");


    private Integer code;
    private String desc;

    public String getDesc() {
        return desc;
    }

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


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

}
