<?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.toutiao.modules.report.mapper.BytedanceVideoReportMapper">

    <select id="queryVideoReportBy" resultType="com.alibaba.fastjson.JSONObject">
        SELECT
        t1.md5 signature,
        IFNULL(t1.toutiao_url, '') AS url,
        t1.cover_url AS converUrl,
        t1.clip_name AS clip,
        t1.shot_name AS shot,
        t1.plan_name AS plan,
        t1.material_name AS materialName,
        t1.project_name AS projectName,
        t1.material_create_time AS createTime,
        ${filed}
        FROM
        etl_report_bytedance_video t1
        WHERE
        t1.stat_datetime >= #{startDate}
        AND t1.stat_datetime &lt;= #{endDate}
        <if test="accountIds != null">
            AND t1.account_id in
            <foreach item="item" index="index" collection="accountIds"
                     open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        AND (t1.clip_name LIKE '%${clip}%')
        AND (t1.shot_name LIKE '%${shot}%')
        AND (t1.plan_name LIKE '%${plan}%')
        GROUP BY t1.md5
        ORDER BY ${target} ${order}
    </select>

    <select id="queryVideoDetailBy" resultType="com.alibaba.fastjson.JSONObject">
        SELECT
        t1.stat_datetime as statDate,
        t1.md5 signature,
        IFNULL(t1.toutiao_url, '') AS url,
        t1.cover_url AS converUrl,
        t1.material_name AS materialName,
        t1.project_name AS projectName,
        t1.advertiser_name as advertiserName,
        t1.material_create_time AS createTime,
        ${filed}
        FROM
        etl_report_bytedance_video t1
        WHERE t1.md5=#{signature}
        AND t1.stat_datetime >= #{startDate}
        AND t1.stat_datetime &lt;= #{endDate}
        <if test="accountIds != null">
            AND t1.account_id in
            <foreach item="item" index="index" collection="accountIds"
                     open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        GROUP BY t1.md5,t1.stat_datetime
        order by t1.stat_datetime desc
    </select>
</mapper>