package com.ningdatech.carapi.common.constant;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * 车辆类型限速
 *
 * @author PoffyZhang
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "VehicleLimitSpeedEnum", description = "车辆类型限速-枚举")
public enum VehicleLimitSpeedEnum {
    /**
     * 散装水泥运输车
     */
    BULK_CEMENT_TRUCK_LIMITSPEED(1, "散装水泥运输车",60),

    /**
     *预拌砂浆运输车
     */
    READY_MIXED_MORTAR_TRUC(2, "预拌砂浆运输车",60),

    /**
     * 混凝土搅拌车
     */
    MIXER(3, "混凝土搅拌车",50),

    /**
     * 移动泵车
     */
    KRHP(4, "移动泵车",50);


    private Integer code;
    private String desc;
    private Integer limitSpeed;

    public String getDesc() {
        return desc;
    }

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

    public static Integer getLimitSpeedByCode(Integer code) {
        if(Objects.isNull(code)){
            return 60;
        }
        for (VehicleLimitSpeedEnum t : VehicleLimitSpeedEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.limitSpeed;
            }
        }
        return 60;
    }


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

}
