List<Map<Long, Long>> getRecBestEjobIdBatch(List<Map<Long, String>> list)
这是我的调用接口,入参里的每个map的key value其实就是usere_id和res_ids,
<select id="getRecBestEjobId" parameterType="map"
resultType="java.lang.Long">
SELECT ejob_id
FROM e_bole_recommend_info
<where>
usere_id=#{usere_id} AND res_id IN (${res_ids}) AND delflag = 0 AND source != 4
</where>
ORDER BY feedback, source, score DESC, createtime DESC
LIMIT 1
</select>
以上这个sql如果我入参只有一个map是可以做到的,但我现在是个List
<foreach collection="list" item="i" separator=",">
and usere_id= #{i.user_id}
AND res_id IN #{i.res_ids}
</foreach>
Map的你都可以写了,这里你传递过来对象也是可以的
<select id="getRecBestEjobId" resultType="String">
SELECT ejob_id
FROM e_bole_recommend_info
<where>
<if test="[dao层或mapper层的参数对象].usere_id != null">usere_id = #{usere_id}</if>
<if test="[dao层或mapper层的参数对象].res_ids != null">
res_id IN
<foreach item="res_ids" collection="res_ids" open="(" separator="," close=")">
#{res_ids}
</foreach>
</if>
AND delflag = 0
AND source != 4
</where>
ORDER BY feedback, source, score DESC, createtime DESC
LIMIT 1
</select>