package com.ruoyi.novel.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.novel.domain.AdLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

// AdLogMapper.java
@Mapper
public interface AdLogMapper extends BaseMapper<AdLog> {

    @Select("SELECT COUNT(*) FROM novel_ad_log WHERE user_id = #{userId} AND chapter_id = #{chapterId}")
    int countByUserAndChapter(@Param("userId") Long userId, @Param("chapterId") Long chapterId);

    @Select("SELECT * FROM novel_ad_log WHERE sync_status = 0 ORDER BY view_time ASC LIMIT 100")
    List<AdLog> selectUnsyncedLogs();
}