package com.moral.api.pojo.enums;
|
|
import com.baomidou.mybatisplus.annotation.EnumValue;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.moral.api.exception.BusinessException;
|
import lombok.Getter;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* @ClassName InvestigationEnum
|
* @Description TODO
|
* @Author @cjl
|
* @Date 2023-09-20 14:47
|
* @Version 1.0
|
*/
|
@Getter
|
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
public enum InvestigationEnum implements IntegerValueEnum{
|
/**
|
*立行整改
|
*/
|
SCENE(1, "现场"),
|
/**
|
*限期整改
|
*/
|
TRAVELING_VEHICLE(2, "走航"),
|
|
UAV(3, "无人机"),
|
;
|
|
@EnumValue
|
public final Integer value;
|
public final String name;
|
|
InvestigationEnum(Integer value, String name) {
|
this.value = value;
|
this.name = name;
|
}
|
|
private static Map<Integer, InvestigationEnum> valueMap = new HashMap<>();
|
static {
|
for (InvestigationEnum v : InvestigationEnum.values()) {
|
valueMap.put(v.value, v);
|
}
|
}
|
@JsonCreator
|
public static InvestigationEnum getByValue(Integer value) {
|
if (value == null) {
|
return null;
|
}
|
InvestigationEnum result = valueMap.get(value);
|
if (result == null) {
|
throw new BusinessException("枚举转换异常" + value);
|
}
|
return result;
|
}
|
}
|