<?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.TencentImagesMapper">

    <resultMap id="BaseResultMap" type="com.moka.gdtauto.entity.TencentImages">
        <id column="id" property="id"/>
        <result column="account_id" property="accountId"/>
        <result column="image_id" property="imageId"/>
        <result column="image_width" property="imageWidth"/>
        <result column="image_height" property="imageHeight"/>
        <result column="image_file_size" property="imageFileSize"/>
        <result column="image_type" property="imageType"/>
        <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="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_images 
        GROUP BY account_id 
        ORDER BY count DESC 
        LIMIT 5
    </select>

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

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

</mapper>
