今天試了一下
1、##mapper: /** * 批量更新排序 * @param sortMap * @return */ int updateSortMore(@Param("sortMap")Map<Integer, Short> sortMap);
2##sql
<update id="updateSortMore"> <foreach collection="sortMap.entrySet()" index="id" item="sort" separator=";"> <if test="id!=null and sort!=null"> update media_module set sort=#{sort} where id=#{id} </if> </foreach> </update>
3、返回來的是int=> 1
4、配置要加這個allowMultiQueries=true
spring.datasource.url=jdbc:mysql://172.16.20.71:3306/jdocloud_media-back?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=GMT%2B8 #spring中入庫時間時區設定 spring.jackson.time-zone = GMT+8 spring.datasource.username=root