1.配置连接允许批量操作
配置url后面
&allowMultiQueries=true
2.数据层
2.1 mapper
// 新增
void saveNewStudyPartyDatums(List<StudyDatum> list);
// 查询
List<Party> getParties(@Param("partIds") List<Long> partIds);
// 更新
void updateDatumIdBatchByIds(List<StudyPartyDatum> list);
2.2 mapper.xml
<!-- 新增-->
<insert id="saveNewStudyPartyDatums" useGeneratedKeys="true" keyProperty="studyId" parameterType="list">
insert into dj_study_datum
(study_title, is_study, file_url, abort_time, top_status,create_by, create_time, update_by, update_time, service_type,party_id,type,tenant_id)
values
<foreach collection="list" item="item" separator=",">
(#{item.studyTitle}, #{item.isStudy}, #{item.fileUrl}, #{item.abortTime}, #{item.topStatus},
#{item.createBy}, #{item.createTime}, #{item.updateBy},#{item.updateTime},
#{item.serviceType},#{item.partyId},#{item.type},#{item.tenantId})
</foreach>
</insert>
<!-- 查询-->
<select id="getParties" resultType="com.ysgz.web.domain.Party">
select dp.* from dj_party dp
where dp.del_flag='0'
and dp.party_id in
<foreach collection="partIds" item="partyId" open="(" separator="," close=")">
#{partyId}
</foreach>
</select>
<!-- 更新-->
<update id="updateDatumIdBatchByIds" parameterType="list">
<foreach collection="list" item="item" separator=";">
update dj_study_party_datum
<set>
datum_id=#{item.datumId}
</set>
where party_datum_id=#{item.partyDatumId}
</foreach>
</update>