Skip to main content
 首页 » 编程设计

mybatis里使用枚举Enum判断

2022年07月18日201JeffreyZhao
<if test="dtEnum == @com.xxx.xxx.TestTypeEnum@HOUR"> 
  DATE_FORMAT(TM,'%Y-%m-%d %H') as keyStr, 
</if>

TestTypeEnum定义如下:

HOUR("hour"), 
DAY("day"), 
MONTH("month"), 
YEAR("year");

 YesOrNoEnum定义如下:
YES(1, "是"),
NO(2, "否")


<if test="e.chip ==@com.rongyi.platform.cloudwalk.enums.YesOrNoEnum@YES">
and pid != 0
</if>
<if test="e.chip == @com.rongyi.platform.cloudwalk.enums.YesOrNoEnum@NO">
and pid = 0
</if>
<if test="e.status !=null">
and status = #{e.status, jdbcType=INTEGER}
</if>

本文参考链接:https://www.cnblogs.com/maohuidong/p/14346572.html