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