<update id="updateByList" parameterType="java.util.List"> update t_base_contact <trim prefix="set"> name = <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end"> when #{item.id} then #{item.name} </foreach> ,phone = <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end"> when #{item.id} then #{item.phone} </foreach> ,email = <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end"> when #{item.id} then #{item.email} </foreach> ,landline = <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end"> when #{item.id} then #{item.email} </foreach> ,wechat = <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end"> when #{item.id} then #{item.wechat} </foreach> ,is_default = <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end"> when #{item.id} then #{item.isDefault} </foreach> where id in <foreach collection="list" index="index" item="item" separator="," open="(" close=")"> #{item.id} </foreach> </trim> </update>
注意,当mybatis传多个参数的时候,需要用@param来标示