<!-- RoyaltySummaryMapper.xml -->
<mapper namespace="com.ruoyi.novel.mapper.RoyaltySummaryMapper">

    <resultMap id="RoyaltySummaryResult" type="RoyaltySummary">
        <id property="authorId" column="author_id" />
        <id property="month" column="month" />
        <result property="totalReads" column="total_reads" />
        <result property="lastSyncTime" column="last_sync_time" />
    </resultMap>

    <select id="selectMonthlySummary" resultMap="RoyaltySummaryResult">
        SELECT author_id, month, SUM(total_reads) AS total_reads
        FROM novel_royalty_detail
        WHERE month = #{month}
        GROUP BY author_id
    </select>
</mapper>