<?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="org.linlinjava.jz.db.dao.JzBuiltListBatchMapper">
    <select id="builtList"  parameterType="java.lang.String" resultType="org.linlinjava.jz.db.domain.JzBuiltList">
        ${value}
    </select>
    <!-- 批量插入生成的任务 -->
    <insert id ="insertBuiltBatch" parameterType="java.util.List" >
        <selectKey resultType ="java.lang.Integer" keyProperty= ""
                   order= "AFTER">
            SELECT LAST_INSERT_ID()
        </selectKey >
        insert into jz_built_list
        (campaign_id, customer_id,call_source, next_call_time,create_time,shop_id)
        values
        <foreach collection ="list" item="item" index= "index" separator =",">
            (
            #{item.campaignId},
            #{item.customerId},
            #{item.callSource},
            #{item.nextCallTime},
            #{item.createTime},
            #{item.shopId}
            )
        </foreach >
    </insert >
    <!--批量更新built中的归属人字段-->
    <update id="updateBuiltBatch" parameterType="java.util.List" >
        <foreach collection="list" item="item" index="index" open="" close="" separator=";">
            update jz_built_list
            <set >
                <if test="item.userId != null" >
                    user_id = #{item.userId,jdbcType=INTEGER},
                </if>
                <if test="item.assignedTime != null" >
                    assigned_time = #{item.assignedTime,jdbcType=TIMESTAMP},
                </if>
            </set>
            where id = #{item.id,jdbcType=INTEGER}
        </foreach>
    </update>



</mapper>