mybatis時間段查詢,數組

Mybatis映射文件SQL代碼:

<select id="getScheduleinfo" parameterType="Scheduleinfo" resultMap="ScheduleinfoEntity">

	SELECT * FROM scheduleinfo WHERE 1=1

<if test="fromstationname !=null and fromstationname!='' ">
	AND fromstationname  LIKE CONCAT(CONCAT('%', #{fromstationname}),'%')
</if>
 
<if test="reachstationname !=null and reachstationname!='' ">
	AND reachstationname   LIKE CONCAT(CONCAT('%', #{reachstationname}),'%')
</if>
 
<if test="iridedate!=null and iridedate!=''">
	AND iridedate =#{iridedate}
</if>

//時間段查詢處理hh:mm -——hh:mm
<if test="sixdian!=null and sixdian!=''">
	AND (TIME_FORMAT(startinfirsttime, '%H:%i') between TIME_FORMAT(#{sixdian}, '%H:%i') and TIME_FORMAT(#{twelvedian}, '%H:%i')
</if>

<if test="threejieduan!=null and threejieduan!=''">
	OR TIME_FORMAT(startinfirsttime, '%H:%i') between TIME_FORMAT(#{threejieduan}, '%H:%i') and TIME_FORMAT(#{fourjieduan}, '%H:%i')
</if>

<if test="five!=null and five!=''">
	OR TIME_FORMAT(startinfirsttime, '%H:%i') between TIME_FORMAT(#{five}, '%H:%i') and TIME_FORMAT(#{six}, '%H:%i')
</if> 

<if test="seven!=null and seven!=''">
	OR TIME_FORMAT(startinfirsttime, '%H:%i') between TIME_FORMAT(#{seven}, '%H:%i') and TIME_FORMAT(#{eight}, '%H:%i')
</if> 

<if test="sixdian!=null and sixdian!=''">
  	)
</if>

order by ${cloum} ${paixu}//升序降序列需要${} 
//傳一個數組
<!-- 
<if test="boxdate!=null and boxdate !='' ">
	AND startinfirsttime IN
<foreach collection="boxdate" index="index" item="item" open="(" separator="," close=")" >
	#{item}
</foreach>
</if>
-->

</select>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章