feat(posts): add preview URL fields for post images
All checks were successful
Build Backend / build (push) Successful in 4m45s
Build Backend / build-docker (push) Successful in 1m31s

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:
lafay
2026-04-10 01:13:58 +08:00
parent 539bec6f63
commit 6af6aaa9d0
5 changed files with 57 additions and 28 deletions

View File

@@ -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()
}