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
| package com.ruoyi.common.core.enums;
|
| import com.baomidou.mybatisplus.annotation.EnumValue;
| import com.fasterxml.jackson.annotation.JsonValue;
| import lombok.AllArgsConstructor;
| import lombok.Getter;
|
|
| @Getter
| @AllArgsConstructor
| public enum GenderEnum {
|
| /* 性别 0=女,1=男,2=未知*/
|
| FEMALE(0, "女"),
| MALE(1, "男"),
| UNKNOWN(2, "未知");
| @EnumValue
| private final int code;
| @JsonValue
| private final String desc;
|
|
| /**
| * 通过code获取枚举
| *
| * @param code
| * @return
| */
| public static GenderEnum fromCode(Integer code) {
| GenderEnum[] resultTypes = GenderEnum.values();
| for (GenderEnum resultType : resultTypes) {
| if (code.equals(resultType.getCode())) {
| return resultType;
| }
| }
| return null;
| }
|
| }
|
|