最后所有的 id 都会返回到之前传入的 list 对象中
Mapper
@Mapper
public interface WorkWxOperationPlanTaskMapper extends BaseMapper<WorkWxOperationPlanTaskEntity> {
void insertBatchOpPlanTask(List<WorkWxOperationPlanTaskEntity> list);
}
Dao
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.super0.sellbox.scrm.server.mapper.WorkWxOperationPlanTaskMapper">
<insert id="insertBatchOpPlanTask" parameterType="List" useGeneratedKeys="true" keyProperty="id">
INSERT INTO work_wx_operation_plan_task
(id, corp_id, op_plan_id, `name`, `type`, target_ids_data, execution_type, execution_time, end_time,
execution_num, content, attachments_data, is_deleted, create_time, update_time)
VALUES
<!-- 这个list尽量不要改 -->
<foreach collection ="list" item="opPlanTask" index="index" separator =",">
(#{opPlanTask.id}, #{opPlanTask.corpId}, #{opPlanTask.opPlanId}, #{opPlanTask.name}
, #{opPlanTask.type}, #{opPlanTask.targetIdsData}, #{opPlanTask.executionType}, #{opPlanTask.executionTime}
, #{opPlanTask.endTime}, #{opPlanTask.executionNum}, #{opPlanTask.content}, #{opPlanTask.attachmentsData}
, #{opPlanTask.deleted}, #{opPlanTask.createTime}, #{opPlanTask.updateTime})
</foreach>
</insert>
</mapper>