摘抄自:https://blog.csdn.net/LQQianLee/article/details/79771618
二、批量更新——单条件
-
<update id="update" parameterType="java.util.List">
-
update nt_menu
-
<trim prefix="set" suffixOverrides=",">
-
<trim prefix="breakfast =case" suffix="end,">
-
<foreach collection="list" item="cus">
-
<if test="cus.breakfast != null">
-
when menuId=#{cus.menuId} then #{cus.breakfast}
-
</if>
-
</foreach>
-
</trim>
-
<trim prefix="lunch =case" suffix="end,">
-
<foreach collection="list" item="cus">
-
<if test="cus.lunch != null">
-
when menuId=#{cus.menuId} then #{cus.lunch}
-
</if>
-
</foreach>
-
</trim>
-
<trim prefix="dinner =case" suffix="end,">
-
<foreach collection="list" item="cus">
-
<if test="cus.dinner != null">
-
when menuId=#{cus.menuId} then #{cus.dinner}
-
</if>
-
</foreach>
-
</trim>
-
<trim prefix="modifier =case" suffix="end,">
-
<foreach collection="list" item="cus">
-
<if test="cus.modifier != null">
-
when menuId=#{cus.menuId} then #{cus.modifier}
-
</if>
-
</foreach>
-
</trim>
-
</trim>
-
<where>
-
<foreach collection="list" separator="or" item="cus">
-
menuId=#{cus.menuId}
-
</foreach>
-
</where>
-
</update>
批量更新——多条件