夜雨声烦 | f4b8b6f | 2025-04-24 00:58:36 +0800 | [diff] [blame^] | 1 | package com.example.g8backend.mapper; |
| 2 | |
| 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 4 | import com.example.g8backend.entity.PostView; |
| 5 | import org.apache.ibatis.annotations.Mapper; |
| 6 | import org.apache.ibatis.annotations.Param; |
| 7 | import org.apache.ibatis.annotations.Select; |
| 8 | |
| 9 | import java.util.List; |
| 10 | |
| 11 | @Mapper |
| 12 | public interface PostViewMapper extends BaseMapper<PostView> { |
| 13 | |
| 14 | |
| 15 | @Select("SELECT post_id FROM post_views WHERE user_id = #{userId}") |
| 16 | List<Long> findViewedPostIds(@Param("userId") Long userId); |
| 17 | |
| 18 | |
| 19 | @Select("SELECT * FROM post_views WHERE user_id = #{userId} ORDER BY view_time DESC LIMIT #{limit}") |
| 20 | List<PostView> selectRecentViews(@Param("userId") Long userId, @Param("limit") int limit); |
| 21 | } |