mybatisplus的枚举值映射

1.定义枚举值

 

@Getter
public enum AlarmType{

Live(1, "XXX"),
BD(2, "XXX"),
Server(3,"XXX")

;

@JsonCreator
AlarmType(Integer val, String desc) {
this.val = val;
this.desc = desc;
}

@EnumValue
private final Integer val;
@JsonValue
private final String desc;

}

2.改一下实体类
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class alarmtable implements Serializable {

private static final long serialVersionUID=1L;

@TableId("id")
private Integer id;

@TableField("AlarmType")
private AlarmType alarmType;

}

3.在配置文件中加
mybatis-plus.typeEnumsPackage=com.xx.xxx.xxx.enums
posted @ 2020-03-09 14:32  地表最强队队员  阅读(5883)  评论(0编辑  收藏  举报