package com.moral.api.pojo.query;
|
|
import com.baomidou.mybatisplus.annotation.EnumValue;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
import lombok.Getter;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* @Description
|
*
|
* @Date 2020/10/27 11:00
|
* @Version 1.0
|
*/
|
@Getter
|
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
public enum OrderType {
|
|
/**
|
* ASC
|
*/
|
ASC("ascending"),
|
/**
|
* DESC
|
*/
|
DESC("descending"),
|
;
|
|
private static Map<String, OrderType> valueMap = new HashMap<>();
|
|
static {
|
for (OrderType orderType : OrderType.values()) {
|
valueMap.put(orderType.code, orderType);
|
}
|
}
|
|
@EnumValue
|
public final String code;
|
|
OrderType(String code) {
|
this.code = code;
|
}
|
|
@JsonCreator
|
public static OrderType getByValue(String code) {
|
OrderType result = valueMap.get(code);
|
if (result == null) {
|
throw new IllegalArgumentException("No element matches " + code);
|
}
|
return result;
|
}
|
|
}
|