improve the functions related to commenting on images

This commit is contained in:
landaiqing
2024-09-23 00:53:43 +08:00
parent 8d5d918a7d
commit 7aae53e533
32 changed files with 1004 additions and 86 deletions

View File

@@ -12,3 +12,29 @@ func (CommentReplyService) CreateCommentReply(comment *model.ScaCommentReply) er
}
return nil
}
// GetCommentListOrderByCreatedTimeDesc 通过topic_id获取评论列表
func (CommentReplyService) GetCommentListOrderByCreatedTimeDesc(topicID uint, page, pageSize int) ([]model.ScaCommentReply, error) {
var comments []model.ScaCommentReply
// 计算偏移量
offset := (page - 1) * pageSize
if err := global.DB.Where("topic_id =? and deleted = 0", topicID).Order("created_time desc").
Offset(offset).Limit(pageSize).Find(&comments).Error; err != nil {
return nil, err
}
return comments, nil
}
// GetCommentListOrderByLikesDesc 通过topic_id获取评论列表
func (CommentReplyService) GetCommentListOrderByLikesDesc(topicID uint, page, pageSize int) ([]model.ScaCommentReply, error) {
var comments []model.ScaCommentReply
// 计算偏移量
offset := (page - 1) * pageSize
if err := global.DB.Where("topic_id =? and deleted = 0", topicID).Order("likes desc").
Offset(offset).Limit(pageSize).Find(&comments).Error; err != nil {
return nil, err
}
return comments, nil
}