Mapper接口
/**
* 批量同步更新数据
* @param collectionBids
*/
void updateSyncs(@Param("collectionBids") List<CollectionBid> collectionBids);
表字段
`user_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '用户id'
`name` varchar(50) DEFAULT NULL COMMENT '用户昵称'
mybatis更新语句
<update id="updateSyncs" parameterType="list">
UPDATE `t_collection_bid`
<trim prefix="set" suffixOverrides=",">
<trim prefix="user_id=case" suffix="end,">
<foreach collection="collectionBids" item="c" index="index">
<if test="c.userId!=null">
when order_number=#{c.orderNumber} then #{c.userId}
</if>
</foreach>
</trim>
<trim prefix="name =case" suffix="end,">
<foreach collection="collectionBids" item="c" index="index">
<if test="c.name!=null">
when order_number=#{c.orderNumber} then #{c.name}
</if>
</foreach>
</trim>
</trim>
WHERE
<foreach collection="collectionBids" separator="or" item="c" index="index">
order_number=#{c.orderNumber}
</foreach>
</update>