From 74cfd7ed2363ddca5bfe153b7caa7b41248d0534 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 7 Jul 2024 11:58:30 +0800 Subject: [PATCH] :bug: Fix list post didn't preload tags & categories --- pkg/internal/services/articles.go | 2 ++ pkg/internal/services/posts.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pkg/internal/services/articles.go b/pkg/internal/services/articles.go index 4288f51..f3bfb41 100644 --- a/pkg/internal/services/articles.go +++ b/pkg/internal/services/articles.go @@ -113,6 +113,8 @@ func ListArticle(tx *gorm.DB, take int, offset int, noReact ...bool) ([]*models. if err := tx. Limit(take).Offset(offset). Order("created_at DESC"). + Preload("Tags"). + Preload("Categories"). Preload("Realm"). Preload("Author"). Find(&items).Error; err != nil { diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index b9fd418..e0732fe 100644 --- a/pkg/internal/services/posts.go +++ b/pkg/internal/services/posts.go @@ -140,6 +140,8 @@ func ListPost(tx *gorm.DB, take int, offset int, noReact ...bool) ([]*models.Pos if err := tx. Limit(take).Offset(offset). Order("created_at DESC"). + Preload("Tags"). + Preload("Categories"). Preload("Realm"). Preload("Author"). Preload("ReplyTo").