方法1:?> 大于 ,?< 小于
<if test="startTime != null ">
and a.create_time >= #{startTime}
</if>
<if test="endTime != null ">
and a.create_time <= #{endTime}
</if>
方法2(建议写这个):?
在idea输入CD应该就自动出来了
<if test="deviceId != null and deviceId != '' ">
and a.device_id = #{deviceId}
</if>
<if test="partsIdList != null ">
and b.id in
<foreach item="item" index="index" collection="partsIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test='phone!=null and phone!=""' >
where b.phone LIKE concat('%',#{phone},'%')
</if>
<if test="dataRole == 0">
AND pn.org_code LIKE CONCAT(#{orgCode},'%')
</if>
满足when条件走when,否则执行otherwise?
<choose>
<when test="dto!=null and dto.dataRole='0'">
AND i.org_code like concat(#{dto.orgCode},'%')
</when>
<otherwise>
AND i.org_code = #{dto.orgCode}
</otherwise>
</choose>
?
------------------------------------------与正文内容无关------------------------------------
如果觉的文章写对各位读者老爷们有帮助的话,麻烦点赞加关注呗!小弟在这拜谢了!
如果您觉得我的文章在某些地方写的不尽人意或者写的不对,从而让你对你人生观产生颠覆(概不负责),需要斧正,麻烦在评论区不吝赐教,作者看到后会根据您的提示查阅文章进行修改,还这世间一个公理一片蓝天