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
| package com.ruoyi.common.core.enums;
|
| import lombok.Getter;
|
| /**
| * @Description
| * @Author xiaochen
| * @Date 2023/6/8 16:42
| */
| public enum CarColorEnum {
|
| /*1=白色、2=黑色、3=银色、4=灰色、5=红色、6=蓝色、7=绿色、8=黄色、9=金色、10=紫色、11=橙色、12=其他*/
|
| WHITE(1, "白色"),
| BLACK(2, "黑色"),
| SILVERY(3, "银色"),
| GREY(4, "灰色"),
| RED(5, "红色"),
| BLUE(6, "蓝色"),
| GREEN(7, "绿色"),
| YELLOW(8, "黄色"),
| GOLDEN(9, "金色"),
| PURPLE(10, "紫色"),
| ORANGE(11, "橙色"),
| OTHER(12, "其他");
|
| @Getter
| private String desc;
|
|
| @Getter
| private int code;
|
|
| CarColorEnum(int code, String desc) {
| this.code = code;
| this.desc = desc;
| }
|
| /**
| * 通过code获取枚举
| *
| * @param code
| * @return
| */
| public static CarColorEnum fromCode(Integer code) {
| CarColorEnum[] resultTypes = CarColorEnum.values();
| for (CarColorEnum resultType : resultTypes) {
| if (code.equals(resultType.getCode())) {
| return resultType;
| }
| }
| return null;
| }
|
| }
|
|