MyBatis批量执行查询语句,入参是集合

List<Map<Long, Long>> getRecBestEjobIdBatch(List<Map<Long, String>> list)

这是我的调用接口,入参里的每个mapkey value其实就是usere_idres_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,我想把这个sql循环执行,遍历list中的map执行 用mybatis该怎么做呢


 <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>