From 4fa351b923dbbc06f8ef9fe4c49c2c14dc568e62 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 7 Jul 2024 12:31:05 +0800 Subject: [PATCH] :sparkles: Load related post tags & categories --- pkg/internal/services/posts.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index e0732fe..7aa7569 100644 --- a/pkg/internal/services/posts.go +++ b/pkg/internal/services/posts.go @@ -68,8 +68,12 @@ func GetPostWithAlias(tx *gorm.DB, alias string, ignoreLimitation ...bool) (mode Preload("Author"). Preload("ReplyTo"). Preload("ReplyTo.Author"). + Preload("ReplyTo.Tags"). + Preload("ReplyTo.Categories"). Preload("RepostTo"). Preload("RepostTo.Author"). + Preload("RepostTo.Tags"). + Preload("RepostTo.Categories"). First(&item).Error; err != nil { return item, err } @@ -91,8 +95,12 @@ func GetPost(tx *gorm.DB, id uint, ignoreLimitation ...bool) (models.Post, error Preload("Author"). Preload("ReplyTo"). Preload("ReplyTo.Author"). + Preload("ReplyTo.Tags"). + Preload("ReplyTo.Categories"). Preload("RepostTo"). Preload("RepostTo.Author"). + Preload("RepostTo.Tags"). + Preload("RepostTo.Categories"). First(&item).Error; err != nil { return item, err } @@ -146,8 +154,12 @@ func ListPost(tx *gorm.DB, take int, offset int, noReact ...bool) ([]*models.Pos Preload("Author"). Preload("ReplyTo"). Preload("ReplyTo.Author"). + Preload("ReplyTo.Tags"). + Preload("ReplyTo.Categories"). Preload("RepostTo"). Preload("RepostTo.Author"). + Preload("RepostTo.Tags"). + Preload("RepostTo.Categories"). Find(&items).Error; err != nil { return items, err }