<?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="com.moka.gdtauto.mapper.TencentVideoMapper">

    <resultMap id="BaseResultMap" type="com.moka.gdtauto.entity.TencentVideo">
        <id column="id" property="id"/>
        <result column="account_id" property="accountId"/>
        <result column="video_id" property="videoId"/>
        <result column="video_name" property="videoName"/>
        <result column="video_width" property="videoWidth"/>
        <result column="video_height" property="videoHeight"/>
        <result column="video_duration" property="videoDuration"/>
        <result column="video_size" property="videoSize"/>
        <result column="video_format" property="videoFormat"/>
        <result column="cover_image_url" property="coverImageUrl"/>
        <result column="preview_url" property="previewUrl"/>
        <result column="original_filename" property="originalFilename"/>
        <result column="has_watermark" property="hasWatermark"/>
        <result column="watermark_text" property="watermarkText"/>
        <result column="drama_id" property="dramaId"/>
        <result column="watermark_duration" property="watermarkDuration"/>
        <result column="description" property="description"/>
        <result column="upload_status" property="uploadStatus"/>
        <result column="error_message" property="errorMessage"/>
        <result column="created_by" property="createdBy"/>
        <result column="created_time" property="createdTime"/>
        <result column="updated_time" property="updatedTime"/>
    </resultMap>

    <!-- 按账户统计视频数量 -->
    <select id="selectCountByAccount" resultType="map">
        SELECT 
            account_id as accountId,
            COUNT(*) as count
        FROM tencent_video 
        GROUP BY account_id 
        ORDER BY count DESC 
        LIMIT 5
    </select>

    <!-- 统计今日新增视频数量 -->
    <select id="selectTodayCount" resultType="long">
        SELECT COUNT(*) 
        FROM tencent_video 
        WHERE created_time BETWEEN #{startTime} AND #{endTime}
    </select>

    <!-- 统计指定时间段内的视频数量 -->
    <select id="selectPeriodCount" resultType="long">
        SELECT COUNT(*) 
        FROM tencent_video 
        WHERE created_time BETWEEN #{startTime} AND #{endTime}
    </select>

</mapper>