用parameterType="java.util.ArrayList"接收dao传递类型
String[] files= {"1","50265","50271","50309","50310","50311","50312"};
Service
public List<LimsFileManagement> findInList(String[] files) {
return limsFileManagementDao.findInList(files);
}
DAO
List<Office> findZhiDingList(@Param("files")String[] files);
<foreach>循环数组
<select id="findInList" resultType="LimsFileManagement" parameterType="java.util.ArrayList">
SELECT
<include refid="limsFileManagementColumns" />
FROM lims_file_management a
<include refid="limsFileManagementJoins" />
WHERE a.del_flag='0'
AND a.id IN
<foreach collection="files" item="file" open="(" close=")" separator=",">
#{file}
</foreach>
<choose>
<otherwise>
ORDER BY a.sort
</otherwise>
</choose>
</select>
模糊查询
<if test="sampleTitle != null and sampleTitle != ''">
AND a.sampleTitle LIKE
<if test="dbName == 'oracle'">'%'||#{sampleTitle}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{sampleTitle}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{sampleTitle},'%')</if>
</if>