<?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="cn.com.ctop.kuaishou.modules.material.mapper.EtlKuaishouVideoInfoMapper">
    <insert id="replaceVideoInfo" parameterType="cn.com.ctop.kuaishou.modules.material.entity.EtlKuaishouVideoInfo">
        replace into ctop_etl_kuaishou_video_info
            (
            company_id,
            company_name,
            video_code,
            video_name,
            state_date,
            url,
            cover_url,
            channel_type,
            channel_name,
            plan_id,
            plan_name,
            clip_id,
            clip_name,
            shot_id,
            shot_name,
            design_team_leader_id,
            design_team_leader_name)
            values
            (
                #{etlKuaishouVideoInfo.companyId},
                #{etlKuaishouVideoInfo.companyName},
                #{etlKuaishouVideoInfo.videoCode},
                #{etlKuaishouVideoInfo.videoName},
                #{etlKuaishouVideoInfo.stateDate},
                #{etlKuaishouVideoInfo.url},
                #{etlKuaishouVideoInfo.coverUrl},
                #{etlKuaishouVideoInfo.channelType},
                #{etlKuaishouVideoInfo.channelName},
                #{etlKuaishouVideoInfo.planId},
                #{etlKuaishouVideoInfo.planName},
                #{etlKuaishouVideoInfo.clipId},
                #{etlKuaishouVideoInfo.clipName},
                #{etlKuaishouVideoInfo.shotId},
                #{etlKuaishouVideoInfo.shotName},
                #{etlKuaishouVideoInfo.designTeamLeaderId},
                #{etlKuaishouVideoInfo.designTeamLeaderName}
        )
    </insert>
    <insert id="addBatch">
        replace into ctop_etl_kuaishou_video_info
        (
        company_id,
        company_name,
        video_code,
        video_name,
        state_date,
        url,
        cover_url,
        channel_type,
        channel_name,
        plan_id,
        plan_name,
        clip_id,
        clip_name,
        shot_id,
        shot_name,
        design_team_leader_id,
        design_team_leader_name)
        values
        <foreach collection="addList" item="ad" separator=",">
            (
            #{ad.companyId},
            #{ad.companyName},
            #{ad.videoCode},
            #{ad.videoName},
            #{ad.stateDate},
            #{ad.url},
            #{ad.coverUrl},
            #{ad.channelType},
            #{ad.channelName},
            #{ad.planId},
            #{ad.planName},
            #{ad.clipId},
            #{ad.clipName},
            #{ad.shotId},
            #{ad.shotName},
            #{ad.designTeamLeaderId},
            #{ad.designTeamLeaderName}
            )
        </foreach>
    </insert>

    <select id="getVideoMinDate" resultType="java.lang.String">
        select min(stat_date) from ctop_kuaishou_report_daily_material where signature = #{signature}
    </select>
</mapper>
