dangsn
2024-06-06 33321f5486fd586fda6fd3f46b7e71754fede28b
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package com.vci.starter.web.enumpck;
 
import com.vci.starter.web.annotation.VciEnum;
 
/**
 * 用户密级
 * @author weidy
 * @date 2019-07-14
 */
@VciEnum(name = "usersecurityenum",text = "人员密级",description = "用户,人员的密级")
public enum UserSecretEnum implements BaseEnumInt{
 
    /**
     * 内部
     */
    NONE(10,"内部"),
    /**
     * 一般
     */
    SECRET(20,"一般"),
    /**
     * 重要
     */
    PRIVACY(30,"重要");
 
    /**
     * 枚举值
     */
    private int value;
 
    /**
     * 枚举显示值
     */
    private String text;
    /**
     * 获取枚举值
     * @return 枚举值
     */
    public int getValue() {
        return value;
    }
 
    /**
     * 设置枚举值
     * @param value 枚举值
     */
    public void setValue(int value) {
        this.value = value;
    }
 
    /**
     * 获取显示文本
     * @return 显示文本
     */
    public String getText() {
        return text;
    }
 
    /**
     * 设置显示文本
     * @param text 显示文本
     */
    public void setText(String text) {
        this.text = text;
    }
 
    /**
     * 枚举内部构造方法
     * @param secret 枚举值
     * @param secretText 显示文本
     */
    private UserSecretEnum(int secret, String secretText){
        this.value = secret;
        this.text = secretText;
    }
 
    /**
     * 根据枚举的值获取显示文本
     * @param secret 枚举值
     * @return 显示文本
     */
    public static String getSecretText(int secret){
        for(UserSecretEnum eu:UserSecretEnum.values()){
            if(eu.value == secret){
                return eu.text;
            }
        }
        return NONE.text;
    }
 
 
    /**
     * 是否有效的密级值
     * @param secret 密级值
     * @return 符合范围要求则返回true
     */
    public static boolean isValid(int secret){
        for(UserSecretEnum eu:UserSecretEnum.values()){
            if(eu.value == secret){
                return true;
            }
        }
        return false;
    }
 
    /**
     * 根据枚举显示文本获取枚举值
     * @param text 显示文本
     * @return 枚举值
     */
    public static int getSecretValueByText(String text){
        for(UserSecretEnum eu:UserSecretEnum.values()){
            if(eu.text.equalsIgnoreCase(text)){
                return eu.value;
            }
        }
        return NONE.value;
    }
}