批量创建
<insert id="insertBatch">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into shopee_item (item_id, item_seller)
<foreach collection="records" item="record" separator=",">
(#{record.itemId,jdbcType=VARCHAR}, #{record.itemSeller,jdbcType=VARCHAR})
</foreach>
</insert>
批量修改
<update id="updateBatch" parameterType="java.util.List">
update shopee_item
<trim prefix="set" suffixOverrides=",">
<trim prefix="item_status =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when id=#{item.id} then #{item.itemStatus}
</foreach>
</trim>
<trim prefix="name =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when id=#{item.id} then <![CDATA[#{item.name}]]>
</foreach>
</trim>
where id in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item.id,jdbcType=BIGINT}
</foreach>
</update>