修改枚举的处理
This commit is contained in:
parent
c256461c59
commit
174bedac08
|
|
@ -1,5 +1,8 @@
|
|||
package com.ruoyi.task.api.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public enum ExecuteTypeEnum {
|
||||
ONCE("once", "单次执行"),
|
||||
CONTINUOUS("continuous", "连续执行");
|
||||
|
|
@ -12,6 +15,7 @@ public enum ExecuteTypeEnum {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
|
@ -20,9 +24,13 @@ public enum ExecuteTypeEnum {
|
|||
return name;
|
||||
}
|
||||
|
||||
public static ExecuteTypeEnum getByCode(String code) {
|
||||
@JsonCreator
|
||||
public static ExecuteTypeEnum getByCode(String value) {
|
||||
if (value == null || value.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (ExecuteTypeEnum type : values()) {
|
||||
if (type.code.equals(code)) {
|
||||
if (type.code.equals(value) || type.name().equals(value)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.ruoyi.task.api.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public enum StatusEnum {
|
||||
PENDING("pending", "待执行"),
|
||||
RUNNING("running", "执行中"),
|
||||
|
|
@ -15,6 +18,7 @@ public enum StatusEnum {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
|
@ -23,9 +27,13 @@ public enum StatusEnum {
|
|||
return name;
|
||||
}
|
||||
|
||||
public static StatusEnum getByCode(String code) {
|
||||
@JsonCreator
|
||||
public static StatusEnum getByCode(String value) {
|
||||
if (value == null || value.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (StatusEnum status : values()) {
|
||||
if (status.code.equals(code)) {
|
||||
if (status.code.equals(value) || status.name().equals(value)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.ruoyi.task.api.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public enum TaskCategoryEnum {
|
||||
MANUAL_FLIGHT("manual_flight", "人工执飞"),
|
||||
PLAN_TASK("plan_task", "计划任务"),
|
||||
|
|
@ -13,6 +16,7 @@ public enum TaskCategoryEnum {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
|
@ -21,9 +25,13 @@ public enum TaskCategoryEnum {
|
|||
return name;
|
||||
}
|
||||
|
||||
public static TaskCategoryEnum getByCode(String code) {
|
||||
@JsonCreator
|
||||
public static TaskCategoryEnum getByCode(String value) {
|
||||
if (value == null || value.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (TaskCategoryEnum category : values()) {
|
||||
if (category.code.equals(code)) {
|
||||
if (category.code.equals(value) || category.name().equals(value)) {
|
||||
return category;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,12 @@ public enum TaskTypeEnum {
|
|||
}
|
||||
|
||||
@JsonCreator
|
||||
public static TaskTypeEnum getByCode(String code) {
|
||||
public static TaskTypeEnum getByCode(String value) {
|
||||
if (value == null || value.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (TaskTypeEnum type : values()) {
|
||||
if (type.code.equals(code)) {
|
||||
if (type.code.equals(value) || type.name().equals(value)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue