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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM