package com.ningdatech.carapi.common.constant;

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 = "MissCertEnum", description = "丢失证件类型-枚举")
public enum MissCertEnum {
    /**
     * 驾驶证
     */
    DRIVER_LINCENSE(1, "驾驶证"),

    /**
     * 行驶证
     */
    DRIVE_PERMIT(2, "行驶证");


    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 (MissCertEnum t : MissCertEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }


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

}
