最后所有的 id 都会返回到之前传入的 list 对象中

Mapper

  1. @Mapper
  2. public interface WorkWxOperationPlanTaskMapper extends BaseMapper<WorkWxOperationPlanTaskEntity> {
  3. void insertBatchOpPlanTask(List<WorkWxOperationPlanTaskEntity> list);
  4. }

Dao

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="net.super0.sellbox.scrm.server.mapper.WorkWxOperationPlanTaskMapper">
  5. <insert id="insertBatchOpPlanTask" parameterType="List" useGeneratedKeys="true" keyProperty="id">
  6. INSERT INTO work_wx_operation_plan_task
  7. (id, corp_id, op_plan_id, `name`, `type`, target_ids_data, execution_type, execution_time, end_time,
  8. execution_num, content, attachments_data, is_deleted, create_time, update_time)
  9. VALUES
  10. <!-- 这个list尽量不要改 -->
  11. <foreach collection ="list" item="opPlanTask" index="index" separator =",">
  12. (#{opPlanTask.id}, #{opPlanTask.corpId}, #{opPlanTask.opPlanId}, #{opPlanTask.name}
  13. , #{opPlanTask.type}, #{opPlanTask.targetIdsData}, #{opPlanTask.executionType}, #{opPlanTask.executionTime}
  14. , #{opPlanTask.endTime}, #{opPlanTask.executionNum}, #{opPlanTask.content}, #{opPlanTask.attachmentsData}
  15. , #{opPlanTask.deleted}, #{opPlanTask.createTime}, #{opPlanTask.updateTime})
  16. </foreach>
  17. </insert>
  18. </mapper>