dao层写法:(因为我的表名是外部拼接的所以需要传参数)
Integer updateBatch(@Param(value = "orderTableName") String orderTableName,
@Param(value = "list") List<OrderInfo> list);
语句实现:
<update id="updateBatch" parameterType="java.util.List">
UPDATE ${orderTableName}
<trim prefix="set" suffixOverrides=",">
<trim prefix="order_no =case" suffix="end,">
<foreach collection="list" item="item" index="index">
<if test="item.orderNo !=null">
when id=#{item.id} then #{item.orderNo}
</if>
</foreach>
</trim>
<trim prefix="evaluate_score =case" suffix="end,">
<foreach collection="list" item="item" index="index">
<if test="item.evaluateScore != null">
when id=#{item.id} then #{item.evaluateScore}
</if>
</foreach>
</trim>
<trim prefix="user_receive_time =case" suffix="end,">
<foreach collection="list" item="item" index="index">
<if test="item.userReceiveTime !=null">
when id=#{item.id} then #{item.userReceiveTime}
</if>
</foreach>
</trim>
<trim prefix="message_evaluate_result =case" suffix="end,">
<foreach collection="list" item="item" index="index">
<if test="item.messageEvaluateResult !=null">
when id=#{item.id} then #{item.messageEvaluateResult}
</if>
</foreach>
</trim>
<trim prefix="order_status =case" suffix="end,">
<foreach collection="list" it