List<TouristInfo> touristInfoList = new ArrayList<>();
TouristInfo touristInfo = new TouristInfo();
touristInfo.setAge(20);
touristInfo.setName("张三222");
touristInfo.setIdcard("1354461364");
touristInfo.setTime(localDateTime);
touristInfoList.add(touristInfo);
TouristInfo touristInfo1 = new TouristInfo();
touristInfo1.setAge(22);
touristInfo1.setName("张d三222");
touristInfo1.setIdcard("1354dddd461364");
touristInfo1.setTime(localDateTime);
touristInfoList.add(touristInfo1);
Integer integer = touristInfoService.insertTouristInfo(touristInfoList);
@Insert("<script> " +
"insert into tourist_info" +
"(name,idcard,age,time)" +
"values" +
"<foreach item='item' inde='index' collection='touristInfoList' separator=',' >" +
"(" +
"#{item.name}, " +
"#{item.idcard}, " +
"#{item.age}, " +
"#{item.time}" +
") " +
"</foreach>" +
"</script>")
Integer insertTouristInfo(@Param("touristInfoList") List<TouristInfo> touristInfoList);
必须要在mapper中参数前加上@param()