// service 层
String[] employeeIdList = eIdStr.split(","); // 店员id集合
for (int i = 0; i < employeeIdList.length; i++) {
ProjectEmployee projectEmployee = new ProjectEmployee();
projectEmployee.setEmployeeId(employeeIdList[i]);
projectEmployee.setProjectId(pIdStr);
addList.add(projectEmployee);
}
projectEmployeeMapper.insertProjectEmployee(addList);
// mapper层
void insertProjectEmployee(List<ProjectEmployee> projectEmployee);
// mybatis层
<!-- 批量新增项目-店员 -->
<insert id="insertProjectEmployee" parameterType="java.util.List" >
insert into <include refid="table_name"></include>(
project_id, employee_id
)
values
<foreach collection="list" item="item" index="index" separator=",">
( #{item.projectId}, #{item.employeeId} )
</foreach>
</insert>