From c5ed5e8df6eb5a439a464753b4486b3ead255298 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 12 Feb 2024 12:32:37 +0800 Subject: [PATCH] :bug: Add limitation of pagination --- pkg/services/posts.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/services/posts.go b/pkg/services/posts.go index 01f99ed..d71c709 100644 --- a/pkg/services/posts.go +++ b/pkg/services/posts.go @@ -79,6 +79,10 @@ WHERE t.id = ?`, prefix, prefix, prefix), post.ID).Scan(&reactInfo) } func ListPost(tx *gorm.DB, take int, offset int) ([]*models.Post, error) { + if take > 20 { + take = 20 + } + var posts []*models.Post if err := PreloadRelatedPost(tx). Limit(take).