cjl
2023-10-27 e3bac98f092a10c0e897143bece3abbcc59469f2
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.moral.api.pojo.enums;
 
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.Getter;
 
import java.util.HashMap;
import java.util.Map;
 
/**
 * @ClassName FileType
 * @Description
 * @Author fan
 * @Date 2021/2/1 13:48
 * @Version 1.0
 **/
@Getter
public enum FileType {
 
    /**
     * 其他
     */
    NON(-1),
    /**
     * 图片
     */
    PICTURE(1),
    /**
     * word
     */
    WORD(2),
    /**
     * excel
     */
    EXCEL(3),
    /**
     * pdf
     */
    PDF(4),
    /**
     * 压缩包
     */
    ZIP(5),
 
    /**
     * 压缩包
     */
    MP4(6),
    ;
 
    @EnumValue
    private final Integer value;
 
    FileType(Integer value) {
        this.value = value;
    }
 
    private static final Map<Integer, FileType> VALUE_MAP = new HashMap<>();
 
    static {
        for (FileType var : values()) {
            VALUE_MAP.put(var.getValue(), var);
        }
    }
 
    @JsonCreator
    public static FileType getEnumByCode(Integer value) {
        FileType fileType = VALUE_MAP.get(value);
        if (fileType == null) {
            throw new RuntimeException("enum not find element, [" + value + "]");
        }
        return fileType;
    }
}