optimize the list of comments

This commit is contained in:
landaiqing
2024-09-24 21:37:37 +08:00
parent 5d86914cb7
commit bb2f49fe74
12 changed files with 411 additions and 258 deletions

View File

@@ -45,7 +45,7 @@ func (CommentReplyService) GetCommentListOrderByLikesDesc(topicID uint, page, pa
func (CommentReplyService) UpdateCommentReplyCount(commentID int64) error {
// 使用事务处理错误
err := global.DB.Transaction(func(tx *gorm.DB) error {
result := tx.Model(&model.ScaCommentReply{}).Where("id = ?", commentID).Update("reply_count", gorm.Expr("reply_count + ?", 1))
result := tx.Model(&model.ScaCommentReply{}).Where("id = ? and deleted = 0", commentID).Update("reply_count", gorm.Expr("reply_count + ?", 1))
if result.Error != nil {
return result.Error // 返回更新错误
}