feat(posts): 优化帖子评论统计性能

- 在 Post 模型中添加 commentCount 和 lastReplyAt 字段
- 在 CommentService 中实现更新帖子评论统计的方法
- 在 PostMapper 中使用 Post 模型中的评论统计字段
- 新增数据库迁移脚本,添加评论统计字段和索引
- 更新相关测试用例
This commit is contained in:
sivdead
2025-09-12 11:08:59 +08:00
parent d2ce203236
commit 1a21ba8935
7 changed files with 178 additions and 2 deletions

View File

@@ -72,4 +72,10 @@ public class Post {
@Column(nullable = true)
private Boolean rssExcluded = true;
@Column(nullable = false)
private long commentCount = 0;
@Column(nullable = true)
private LocalDateTime lastReplyAt;
}