package com.ningdatech.carapi.safe.constant;

import java.util.Objects;

import org.apache.commons.lang3.StringUtils;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 事故类型枚举
 * @return
 * @author CMM
 * @since 2023/05/16 15:32
 */
@Getter
@AllArgsConstructor
public enum AccidentTypeEnum {

    INJURY(0,"伤人"),

    DEAD(1,"亡人"),

    OTHER(2,"其它");

    private  Integer code;
    private  String desc;

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

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