|
@@ -2,33 +2,38 @@ package com.ruoyi.info.service.enums;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.annotation.EnumValue;
|
|
|
+import com.fasterxml.jackson.annotation.JsonCreator;
|
|
|
+import com.fasterxml.jackson.annotation.JsonValue;
|
|
|
import com.ruoyi.common.enums.IIntegerEnum;
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
-public enum ServiceUnit implements IIntegerEnum<String> {
|
|
|
+public enum ServiceUnit implements IIntegerEnum<Integer> {
|
|
|
|
|
|
- day("day", "天"),
|
|
|
- hour("hour", "小时"),
|
|
|
- time("time", "次"),
|
|
|
- cover("cover", "套"),
|
|
|
+ day(0, "天"),
|
|
|
+ hour(1, "小时"),
|
|
|
+ time(2, "次"),
|
|
|
+ cover(3, "套"),
|
|
|
;
|
|
|
|
|
|
- ServiceUnit(String code, String msg) {
|
|
|
+ ServiceUnit(Integer code, String msg) {
|
|
|
this.code = code;
|
|
|
this.msg = msg;
|
|
|
}
|
|
|
|
|
|
- private String code;
|
|
|
+ @EnumValue
|
|
|
+ @JsonValue
|
|
|
+ private Integer code;
|
|
|
|
|
|
private String msg;
|
|
|
|
|
|
@Override
|
|
|
- public String getCode() {
|
|
|
+ public Integer getCode() {
|
|
|
return code;
|
|
|
}
|
|
|
|
|
|
- public void setCode(String code) {
|
|
|
+ public void setCode(Integer code) {
|
|
|
this.code = code;
|
|
|
}
|
|
|
|
|
@@ -41,7 +46,8 @@ public enum ServiceUnit implements IIntegerEnum<String> {
|
|
|
this.msg = msg;
|
|
|
}
|
|
|
|
|
|
- public static ServiceUnit getByCode(String code) {
|
|
|
+ @JsonCreator
|
|
|
+ public static ServiceUnit getByCode(Integer code) {
|
|
|
for (ServiceUnit value : ServiceUnit.values()) {
|
|
|
if (Objects.equals(code, value.getCode())) {
|
|
|
return value;
|