feat: 增强情绪博物馆项目功能 - 新增用户评论和帖子功能,优化前端架构和WebSocket通信 - 更新文档和部署配置

This commit is contained in:
2025-07-29 07:38:47 +08:00
parent cc886cd4d5
commit 2f3d39fb00
142 changed files with 45645 additions and 0 deletions
@@ -0,0 +1,52 @@
package com.emotionmuseum.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.emotionmuseum.entity.Comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 评论Mapper接口
*
* @author emotion-museum
* @version 1.0.0
* @since 2024-01-01
*/
@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
/**
* 分页查询内容的评论
*/
@Select("SELECT * FROM comment WHERE content_type = #{contentType} AND content_id = #{contentId} AND parent_id IS NULL AND deleted = 0 ORDER BY create_time DESC")
IPage<Comment> selectContentComments(Page<Comment> page, @Param("contentType") String contentType, @Param("contentId") String contentId);
/**
* 查询评论的回复
*/
@Select("SELECT * FROM comment WHERE parent_id = #{parentId} AND deleted = 0 ORDER BY create_time ASC")
List<Comment> selectCommentReplies(@Param("parentId") String parentId);
/**
* 统计内容的评论数量
*/
@Select("SELECT COUNT(*) FROM comment WHERE content_type = #{contentType} AND content_id = #{contentId} AND deleted = 0")
int countByContent(@Param("contentType") String contentType, @Param("contentId") String contentId);
/**
* 统计用户的评论数量
*/
@Select("SELECT COUNT(*) FROM comment WHERE user_id = #{userId} AND deleted = 0")
int countByUserId(@Param("userId") String userId);
/**
* 查询用户的最新评论
*/
@Select("SELECT * FROM comment WHERE user_id = #{userId} AND deleted = 0 ORDER BY create_time DESC LIMIT #{limit}")
List<Comment> selectUserLatestComments(@Param("userId") String userId, @Param("limit") int limit);
}