fuliqi
2024-08-09 b04753affc29f1042d0eb75b0af87824a0f4a8aa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package enumeration.general;
 
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
 
public enum CheckScoreType {
    CHECK_SCORE_TYPE_VIDEO(1, "视频考核"),
    CHECK_SCORE_TYPE_CAR(2, "车辆考核"),
    CHECK_SCORE_TYPE_FACE(3, "人脸考核");
 
    @EnumValue
    private final Integer value;
 
    @JsonValue // 标明在转JSON时使用该字段
    private final String desc;
 
    CheckScoreType(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }
 
    public Short getValue() {
        return Short.valueOf(value+"");
    }
 
    public String getDesc() {
        return desc;
    }
 
    // 根据value返回对应的枚举实例
    public static CheckScoreType fromValue(int value) {
        for (CheckScoreType type : CheckScoreType.values()) {
            if (type.getValue() == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("没有枚举值: " + value);
    }
}