feat(posts): add preview URL fields for post images
Add PreviewURL and PreviewURLLarge fields to PostImage model and responses. Image data now supports format "url|preview_url|preview_url_large" for storing multiple image variants. Also change comment cursor pagination to sort by created_at ASC (oldest first) to display earliest comments as first floor, and make AdminReviewVerificationRequest.Approve field optional.
This commit is contained in:
@@ -495,14 +495,14 @@ func (r *commentRepository) GetCommentsByPostIDForAdmin(postID string, page, pag
|
||||
// ========== Cursor Pagination Methods ==========
|
||||
|
||||
// GetCommentsByCursor 游标分页获取帖子评论(包含回复)
|
||||
// 排序方式:created_at DESC
|
||||
// 排序方式:created_at ASC(最早发布的为一楼)
|
||||
func (r *commentRepository) GetCommentsByCursor(ctx context.Context, postID string, req *cursor.PageRequest) (*cursor.CursorPageResult[*model.Comment], error) {
|
||||
// 构建基础查询 - 只查询顶级评论
|
||||
query := r.db.WithContext(ctx).Model(&model.Comment{}).
|
||||
Where("post_id = ? AND parent_id IS NULL AND status = ?", postID, model.CommentStatusPublished)
|
||||
|
||||
// 使用游标构建器
|
||||
builder := cursor.NewBuilder(query, cursor.SortByCreatedAtDesc).
|
||||
builder := cursor.NewBuilder(query, cursor.SortByCreatedAtAsc).
|
||||
WithCursor(req.Cursor, req.Direction).
|
||||
WithPageSize(req.PageSize)
|
||||
|
||||
@@ -539,7 +539,7 @@ func (r *commentRepository) GetCommentsByCursor(ctx context.Context, postID stri
|
||||
nextCursor = cursor.NewCursor(
|
||||
cursor.FormatTime(lastComment.CreatedAt),
|
||||
lastComment.ID,
|
||||
cursor.SortByCreatedAtDesc,
|
||||
cursor.SortByCreatedAtAsc,
|
||||
).Encode()
|
||||
}
|
||||
// 上一页游标
|
||||
@@ -547,7 +547,7 @@ func (r *commentRepository) GetCommentsByCursor(ctx context.Context, postID stri
|
||||
prevCursor = cursor.NewCursor(
|
||||
cursor.FormatTime(firstComment.CreatedAt),
|
||||
firstComment.ID,
|
||||
cursor.SortByCreatedAtDesc,
|
||||
cursor.SortByCreatedAtAsc,
|
||||
).Encode()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user