批量插入:
<insert id="insertWareCommentTagBatch" parameterType="java.util.List" keyProperty="id">
insert into T_WARE_COMMENT_TAG ( WARE_INFO_ID, TAG_ID,NUMBER,ORDER_ITEM_ID,ADD_TIME)
values
<foreach collection="list" item="ls" index="index" separator=",">
(#{ls.wareInfoId,jdbcType=INTEGER}, #{ls.tagId,jdbcType=INTEGER},#{ls.number,jdbcType=INTEGER},#{ls.orderItemId,jdbcType=INTEGER},#{ls.addTime,jdbcType=INTEGER})
</foreach>
</insert>
批量修改:
傳進來的是一個list對象,然後根據每個對象的id來分別修改number
<update id="updateWareCommentTagBatch" parameterType="list">
update T_WARE_COMMENT_TAG
set NUMBER =NUMBER +
<foreach collection="list" item="item" index="index"
separator=" " open="case ID" close="end">
when #{item.id} then #{item.number}
</foreach>
where ID in
<foreach collection="list" separator="," open="(" close=")" item="i" index="index" >
#{i.id,jdbcType=INTEGER}
</foreach>
</update>