foreach嵌套批量添加
<insert id="insertAll" parameterType="java.util.List"> insert into kpi_indicator_user_link (indicator_id,user_id,check_id,weight,ord,org_id) values <foreach collection="listuser" index="index1" item="user" separator=","> <foreach collection="kpiIndicatorUserLinklist" item="link" index="index" separator=","> ( #{link.indicatorId,jdbcType=INTEGER}, #{user}, #{link.checkId,jdbcType=INTEGER}, #{link.weight,jdbcType=INTEGER}, #{link.ord,jdbcType=INTEGER}, #{link.orgId,jdbcType=INTEGER} ) </foreach> </foreach> </insert>
//批量添加指标(dao层)
int insertAll(@Param("kpiIndicatorUserLinklist") List<KpiIndicatorUserLink> kpiIndicatorUserLinklist,@Param("listuser") List<Integer> listuser);