✨ improve the functions related to commenting on images
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user