diff --git a/community-8073/src/main/java/com/ivmiku/tutorial/entity/Comment.java b/community-8073/src/main/java/com/ivmiku/tutorial/entity/Comment.java index 0cad272..2cbfc9c 100644 --- a/community-8073/src/main/java/com/ivmiku/tutorial/entity/Comment.java +++ b/community-8073/src/main/java/com/ivmiku/tutorial/entity/Comment.java @@ -21,6 +21,7 @@ public class Comment implements Serializable { private Long postId; + @TableField("tutorialId") private Long tutorialId; // 新增字段 private String content; diff --git a/community-8073/src/main/java/com/ivmiku/tutorial/mapper/LikeMapper.java b/community-8073/src/main/java/com/ivmiku/tutorial/mapper/LikeMapper.java index c990419..4bcca60 100644 --- a/community-8073/src/main/java/com/ivmiku/tutorial/mapper/LikeMapper.java +++ b/community-8073/src/main/java/com/ivmiku/tutorial/mapper/LikeMapper.java @@ -14,11 +14,11 @@ import org.apache.ibatis.annotations.Select; public interface LikeMapper extends BaseMapper { // 获取帖子获赞数 - @Select("SELECT SUM(like_count) FROM posts WHERE user_openid = #{userOpenid}") + Long getPostLikeCount(@Param("userOpenid") String userOpenid); // 获取评论获赞数 - @Select("SELECT SUM(like_count) FROM comments WHERE user_openid = #{userOpenid}") + Long getCommentLikeCount(@Param("userOpenid") String userOpenid); // 查询帖子被点赞的总数 diff --git a/community-8073/src/main/resources/mapper/LikeMapper.xml b/community-8073/src/main/resources/mapper/LikeMapper.xml index 3609f2d..bb86670 100644 --- a/community-8073/src/main/resources/mapper/LikeMapper.xml +++ b/community-8073/src/main/resources/mapper/LikeMapper.xml @@ -5,20 +5,33 @@ - - - - - - + + + + + + - id,user_openid,post_id,tutorialId, - comment_id,is_deleted + id, user_openid, post_id, tutorial_id, comment_id, is_deleted - + SELECT COUNT(*) + FROM likee + WHERE user_openid = #{userOpenid} + AND post_id IS NOT NULL + AND is_deleted = 0; + + + + diff --git a/community-8073/src/main/resources/mapper/PostMapper.xml b/community-8073/src/main/resources/mapper/PostMapper.xml index ac56366..375e75c 100644 --- a/community-8073/src/main/resources/mapper/PostMapper.xml +++ b/community-8073/src/main/resources/mapper/PostMapper.xml @@ -86,7 +86,6 @@ SELECT title FROM post WHERE is_deleted = 0 AND is_public = 1 - ORDER BY view_count DESC, like_count DESC LIMIT 9