枚举类处理

枚举类处理

如果传递枚举类型则使用@EnumVaLue获取其中的数据当作查询的参数

@EnumValue

当对象转化为JSON串时如果遇到枚举类型则使用其中的值当作JSON

@JsonValue

public enum ItemType implements BaseEnum {
    APARTMENT(1, "公寓"),
    ROOM(2, "房间");

    @EnumValue //使用code为mybatis-plus查询时作为参数;
    @JsonValue //使用code为转换成JSON串时的之值;
    private Integer code;
    private String name;
    
   ItemType(Integer code, String name) {
        this.code = code;
        this.name = name;
    }
}
posted @ 2024-11-05 21:24  CH_song  阅读(28)  评论(0)    收藏  举报