<?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.batch.mapper.KuaiShouCreativeMapper">
    <insert id="replaceBatch">
        replace into ctop_kuaishou_creative(id,
        account_id,
        campaign_id,
        unit_id,
        creative_id,
        creative_name,
        creative_material_type,
        photo_id,
        material_url,
        image_tokens,
        status,
        put_status,
        create_channel,
        review_detail,
        cover_url,
        image_token,
        cover_width,
        cover_height,
        overlay_bg_url,
        overlay_bg_image_token,
        sticker_title,
        overlay_type,
        click_track_url,
        impression_url,
        ad_photo_played_t3s_url,
        description,
        action_bar_text,
        first_frame_type,
        site_id,
        programmed_creative_material,
        photo_ids,
        creative_create_time,
        creative_update_time,
        create_time,
        update_time)
        values
        <foreach collection="creatives" item="creative" separator=",">
            (#{creative.id},
            #{creative.accountId},
            #{creative.campaignId},
            #{creative.unitId},
            #{creative.creativeId},
            #{creative.creativeName},
            #{creative.creativeMaterialType},
            #{creative.photoId},
            #{creative.materialUrl},
            #{creative.imageTokens},
            #{creative.status},
            #{creative.putStatus},
            #{creative.createChannel},
            #{creative.reviewDetail},
            #{creative.coverUrl},
            #{creative.imageToken},
            #{creative.coverWidth},
            #{creative.coverHeight},
            #{creative.overlayBgUrl},
            #{creative.overlayBgImageToken},
            #{creative.stickerTitle},
            #{creative.overlayType},
            #{creative.clickTrackUrl},
            #{creative.impressionUrl},
            #{creative.adPhotoPlayedT3sUrl},
            #{creative.description},
            #{creative.actionBarText},
            #{creative.firstFrameType},
            #{creative.siteId},
            #{creative.programmedCreativeMaterial},
            #{creative.photoIds},
            #{creative.creativeCreateTime},
            #{creative.creativeUpdateTime},
            #{creative.createTime},
            #{creative.updateTime})
        </foreach>
    </insert>

    <select id="checkCreativeCount" resultType="java.lang.Integer">
     select count(1)
     from ctop_kuaishou_creative
     where  account_id = #{accountId}
     and unit_id = #{unitId}
    </select>
</mapper>
