|
|
@ -1,5 +1,6 @@ |
|
|
package cn.iocoder.yudao.module.alert.common.enums; |
|
|
package cn.iocoder.yudao.module.alert.common.enums; |
|
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonCreator; |
|
|
import com.fasterxml.jackson.annotation.JsonProperty; |
|
|
import com.fasterxml.jackson.annotation.JsonProperty; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
|
|
|
|
@ -24,6 +25,29 @@ public enum Algorithm { |
|
|
|
|
|
|
|
|
public final Integer code; |
|
|
public final Integer code; |
|
|
|
|
|
|
|
|
|
|
|
@JsonCreator |
|
|
|
|
|
public static Algorithm deserialize(Object value) { |
|
|
|
|
|
if (value == null) { |
|
|
|
|
|
return ERROR; |
|
|
|
|
|
} |
|
|
|
|
|
if (value instanceof Number) { |
|
|
|
|
|
return of(((Number) value).intValue()); |
|
|
|
|
|
} |
|
|
|
|
|
String text = String.valueOf(value); |
|
|
|
|
|
if ("ANN_O".equalsIgnoreCase(text)) { |
|
|
|
|
|
return ANN; |
|
|
|
|
|
} |
|
|
|
|
|
for (Algorithm algorithm : values()) { |
|
|
|
|
|
if (algorithm.name().equalsIgnoreCase(text)) { |
|
|
|
|
|
return algorithm; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
try { |
|
|
|
|
|
return of(Integer.parseInt(text)); |
|
|
|
|
|
} catch (NumberFormatException ignore) { |
|
|
|
|
|
return ERROR; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public static Algorithm of(Integer code) { |
|
|
public static Algorithm of(Integer code) { |
|
|
for (Algorithm algorithm : values()) { |
|
|
for (Algorithm algorithm : values()) { |
|
|
|