批量修改
<update id="updateBatch" parameterType="java.util.List">
update membership_card
<trim prefix="set" suffixOverrides=",">
<!-- 拼接case when 这是一种写法 -->
<!--<foreach collection="list" separator="" item="cus" open="c_age = case id" close="end, ">-->
<!--when #{cus.id} then #{cus.age}-->
<!--</foreach>-->
<!-- 拼接case when 这是另一种写法,这种写着更专业的感觉 -->
<trim prefix="card_use_number =case" suffix="end,">
<foreach collection="list" item="cus">
<if test="cus.cardUseNumber!=null">
when id=#{cus.id} then #{cus.cardUseNumber}
</if>
</foreach>
</trim>
<trim prefix="card_balance =case" suffix="end,">
<foreach collection="list" item="cus">
<if test="cus.cardBalance!=null">
when id=#{cus.id} then #{cus.cardBalance}
</if>
</foreach>
</trim>
<trim prefix="card_level =case" suffix="end,">
<foreach collection="list" item="cus">
<if test="cus.cardLevel!=null">
when id=#{cus.id} then #{cus.cardLevel}
</if>
</foreach>
</trim>
<trim prefix="sell_price =case" suffix="end,">
<foreach collection="list" item="cus">
<if test="cus.sellPrice!=null">
when id=#{cus.id} then #{cus.sellPrice}
</if>
</foreach>
</trim>
<trim prefix="card_use_limit =case" suffix="end,">
<foreach collection="list" item="cus">
<if test="cus.cardUseLimit!=null">
when id=#{cus.id} then #{cus.cardUseLimit}
</if>
</foreach>
</trim>
<trim prefix="valid_time_start =case" suffix="end,">
<foreach collection="list" item="cus">
<if test="cus.validTimeStart!=null">
when id=#{cus.id} then #{cus.validTimeStart}
</if>
</foreach>
</trim>
<trim prefix="valid_time_end =case" suffix="end,">
<foreach collection="list" item="cus">
<if test="cus.validTimeEnd!=null">
when id=#{cus.id} then #{cus.validTimeEnd}
</if>
</foreach>
</trim>
<trim prefix="details =case" suffix="end,">
<foreach collection="list" item="cus">
<if test="cus.details!=null">
when id=#{cus.id} then #{cus.details}
</if>
</foreach>
</trim>
<trim prefix="card_bg =case" suffix="end,">
<foreach collection="list" item="cus">
<if test="cus.cardBg!=null">
when id=#{cus.id} then #{cus.cardBg}
</if>
</foreach>
</trim>
<trim prefix="add_time =case" suffix="end,">
<foreach collection="list" item="cus">
<if test="cus.addTime!=null">
when id=#{cus.id} then #{cus.addTime}
</if>
</foreach>
</trim>
<trim prefix="valid_date_type =case" suffix="end,">
<foreach collection="list" item="cus">
<if test="cus.validDateType!=null">
when id=#{cus.id} then #{cus.validDateType}
</if>
</foreach>
</trim>
</trim>
<where>
<foreach collection="list" separator="or" item="cus">
id = #{cus.id}
</foreach>
</where>
</update>
int updateBatch(List<MembershipCard> list)