IWithCode 相关接口的使用调整。
This commit is contained in:
@@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import xyz.zhouxy.plusone.commons.exception.IWithIntCode;
|
||||
import xyz.zhouxy.plusone.constant.EntityStatus;
|
||||
import xyz.zhouxy.plusone.domain.AggregateRoot;
|
||||
import xyz.zhouxy.plusone.domain.IWithOrderNumber;
|
||||
@@ -129,12 +130,28 @@ public class Menu extends AggregateRoot<Long> implements IWithOrderNumber, IWith
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public enum MenuType {
|
||||
MENU_LIST, MENU_ITEM;
|
||||
public enum MenuType implements IWithIntCode {
|
||||
MENU_LIST(0), MENU_ITEM(1);
|
||||
|
||||
private final int code;
|
||||
|
||||
private MenuType(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int value() {
|
||||
return ordinal();
|
||||
@Override
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static MenuType valueOf(int code) {
|
||||
for (MenuType value : values()) {
|
||||
if (value.code == code) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new EnumConstantNotPresentException(MenuType.class, Integer.toString(code));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user