一、根据id更新多个字段
XML
<update id="batchUpdate">
update food
<trim prefix="set" suffixOverrides=",">
<trim prefix="open_id =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when id=#{item.id} then #{item.openId}
</foreach>
</trim>
<trim prefix="create_by =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when id=#{item.id} then #{item.createBy}
</foreach>
</trim>
</trim>
where id in
<foreach collection="list" index="index" item="item"
separator="," open="(" close=")">
#{item.id}
</foreach>
</update>