| package com.pt5.pthouduan.mapper; |
| import com.pt5.pthouduan.entity.Post; |
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| import org.apache.ibatis.annotations.Mapper; |
| import org.apache.ibatis.annotations.Param; |
| * 功能:增、删、改、查(按关键词)、点赞、置顶、用户帖子查询、置顶帖子查询 |
| public interface PostMapper extends BaseMapper<Post> { |
| int deleteByPostid(@Param("postid") Integer postid); |
| int updatePost(Post post); |
| List<Post> searchByKeyword(@Param("keyword") String keyword); |
| int incrementLikes(@Param("postid") Integer postid); |
| int decrementLikes(@Param("postid") Integer postid); |
| int updatePinnedStatus(@Param("postid") Integer postid, @Param("isPinned") boolean isPinned); |
| List<Post> findByUserid(@Param("userid") Long userid); |
| List<Post> findPinnedPosts(); |
| List<Post> selectAllSorted(); |
| // ✅ 根据帖子ID查询单个帖子(用于 togglePin 等功能) |
| Post selectById(@Param("postid") Integer postid); |