Mapper文件:
List<Test> getResult(@Param("s") TestReq req);
当做查询条件的集合为:
private List<String> idList;
xml文件:
<select id="getResult" resultMap="BaseResultMap">
select * from test t <include refid="where" />
</select>
<sql id="where">
<where>
<if test="s.idList != null and s.idList.size() > 0">
<foreach collection="s.idList"
item="data"
open="and t.id in (" close=")"
separator=",">
#{data,jdbcType=VARCHAR}
</foreach>
</if>
</where>
</sql>