传多个参数到mybatis中进行查询,包括list,int类型数据,String类型数据等等
Dao层://按条件查询
public List<CabHistoryAndDevice> findAllCabInfoByCon(@Param("adaids")List<Integer> alist, @Param("bt")String bt, @Param("et")String et, @Param("ty")String ty, @Param("cc")String cc,@Param("vn")String vn, @Param("re")String re);
mybatis:
<!-- 按条件查询所有记录 -->
<select id = "findAllCabInfoByCon" resultType = "com.chemguan.bean.CabHistoryAndDevice">
SELECT
d.i_Type,
d.vc_Name,
h.i_time,
h.i_ControlCode,
h.i_Reason,
h.i_UserType,
h.i_Authorization,
h.AdapterID,
h.UserID
FROM
cab_deviceinfo AS d
INNER JOIN cab_historydata AS h
ON
d.AdapterID=h.AdapterID and d.DeviceID=h.DeviceID and h.AdapterID in
<foreach item="ada" index="index" collection="adaids" open="(" separator="," close=")">
#{ada.AdapterID}
</foreach>
<if test="ty != null">
and d.i_Type = #{ty}
</if>
<if test="cc != null">
and h.i_ControlCode = #{cc}
</if>
<if test="vn != null">
and d.vc_Name = #{vn}
</if>
<if test="re != null">
and h.i_Reason = #{re}
</if>
<if test="bt != null">
and h.i_time >=#{bt}
</if>
<if test="et != null">
and h.i_time <=#{et}
</if>
</select>
个人小笔记,仅供参考~~~