bug_fix+historyview
Change-Id: I6f446c1b660a4322865cfcf5502c88cb772ca0a1
diff --git a/src/main/java/com/example/g8backend/mapper/PostMapper.java b/src/main/java/com/example/g8backend/mapper/PostMapper.java
index 8f7e029..d49125e 100644
--- a/src/main/java/com/example/g8backend/mapper/PostMapper.java
+++ b/src/main/java/com/example/g8backend/mapper/PostMapper.java
@@ -4,11 +4,7 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.g8backend.entity.Post;
import com.example.g8backend.entity.PostLike;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-import org.apache.ibatis.annotations.Delete;
-import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.*;
import java.util.List;
@@ -55,4 +51,7 @@
// 获取某个帖子点赞数
@Select("SELECT COUNT(*) FROM post_likes WHERE post_id = #{postId}")
Long selectCount(@Param("postId") Long postId);
+
+ @Update("UPDATE posts SET view_count = view_count + 1 WHERE post_id = #{postId}")
+ void incrementViewCount(Long postId);
}