mapper.java:
int modifySortOfGoods(@Param("idlist") List<String> goodsIds, @Param("goodsSortId")Long goodsSortId);
mapper.xml
<update id="modifySortOfGoods" parameterType="java.util.List"> UPDATE goods SET goods_sort_id = #{goodsSortId} WHERE id in <foreach item="goodsId" collection="idlist" separator="," open="(" close=")" index=""> #{goodsId} </foreach> </update>
result:
UPDATE goods SET goods_sort_id = 4 WHERE id in ( '1' , '2' );
foreanch 标签中的 collection的值要对应mapper.java中的@param("") 里面的值