Compare commits

...

2 Commits

Author SHA1 Message Date
苏元皓
1397512e70 Merge branch 'main' of https://gitea.xinxijishubu.asia/iVMiku/guidance-backend 2024-09-05 14:07:06 +08:00
苏元皓
117ab31c00 修复bug 2024-09-05 14:06:57 +08:00
4 changed files with 27 additions and 14 deletions

View File

@@ -21,6 +21,7 @@ public class Comment implements Serializable {
private Long postId;
@TableField("tutorialId")
private Long tutorialId; // 新增字段
private String content;

View File

@@ -14,11 +14,11 @@ import org.apache.ibatis.annotations.Select;
public interface LikeMapper extends BaseMapper<Likee> {
// 获取帖子获赞数
@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);
// 查询帖子被点赞的总数

View File

@@ -5,20 +5,33 @@
<mapper namespace="com.ivmiku.tutorial.mapper.LikeMapper">
<resultMap id="BaseResultMap" type="com.ivmiku.tutorial.entity.Likee">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="userOpenid" column="user_openid" jdbcType="VARCHAR"/>
<result property="postId" column="post_id" jdbcType="BIGINT"/>
<result property="tutorialId" column="tutorialId" jdbcType="BIGINT"/>
<result property="commentId" column="comment_id" jdbcType="BIGINT"/>
<result property="isDeleted" column="is_deleted" jdbcType="TINYINT"/>
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="userOpenid" column="user_openid" jdbcType="VARCHAR"/>
<result property="postId" column="post_id" jdbcType="BIGINT"/>
<result property="tutorialId" column="tutorial_id" jdbcType="BIGINT"/>
<result property="commentId" column="comment_id" jdbcType="BIGINT"/>
<result property="isDeleted" column="is_deleted" jdbcType="TINYINT"/>
</resultMap>
<sql id="Base_Column_List">
id,user_openid,post_id,tutorialId,
comment_id,is_deleted
id, user_openid, post_id, tutorial_id, comment_id, is_deleted
</sql>
<select id="getLikeCountByPostId" resultType="java.lang.Long">
SELECT COUNT(*) FROM likee
WHERE post_id = #{postId} AND is_deleted = 0
<!-- 查询用户所有帖子的点赞总数 -->
<select id="getPostLikeCount" resultType="java.lang.Long">
SELECT COUNT(*)
FROM likee
WHERE user_openid = #{userOpenid}
AND post_id IS NOT NULL
AND is_deleted = 0;
</select>
<!-- 查询用户所有评论的点赞总数 -->
<select id="getCommentLikeCount" resultType="java.lang.Long">
SELECT COUNT(*)
FROM likee
WHERE user_openid = #{userOpenid}
AND comment_id IS NOT NULL
AND is_deleted = 0;
</select>
</mapper>

View File

@@ -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
</select>
<select id="searchPosts" resultType="com.ivmiku.tutorial.entity.Post">