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

猜你喜欢

转载自www.cnblogs.com/MarsMercury/p/12448605.html