diff --git a/pkg/internal/services/articles.go b/pkg/internal/services/articles.go index 2d4abba..41354cd 100644 --- a/pkg/internal/services/articles.go +++ b/pkg/internal/services/articles.go @@ -17,15 +17,15 @@ import ( func FilterArticleWithCategory(tx *gorm.DB, alias string) *gorm.DB { prefix := viper.GetString("database.prefix") return tx.Joins(fmt.Sprintf("JOIN %sarticle_categories ON %sarticles.id = %sarticle_categories.article_id", prefix, prefix, prefix)). - Joins(fmt.Sprintf("JOIN %sarticle_categories ON %sarticle_categories.id = %sarticle_categories.category_id", prefix, prefix, prefix)). - Where(fmt.Sprintf("%sarticle_categories.alias = ?", prefix), alias) + Joins(fmt.Sprintf("JOIN %scategories ON %scategories.id = %sarticle_categories.category_id", prefix, prefix, prefix)). + Where(fmt.Sprintf("%scategories.alias = ?", prefix), alias) } func FilterArticleWithTag(tx *gorm.DB, alias string) *gorm.DB { prefix := viper.GetString("database.prefix") return tx.Joins(fmt.Sprintf("JOIN %sarticle_tags ON %sarticles.id = %sarticle_tags.article_id", prefix, prefix, prefix)). - Joins(fmt.Sprintf("JOIN %sarticle_tags ON %sarticle_tags.id = %sarticle_tags.category_id", prefix, prefix, prefix)). - Where(fmt.Sprintf("%sarticle_tags.alias = ?", prefix), alias) + Joins(fmt.Sprintf("JOIN %stags ON %stags.id = %sarticle_tags.tag_id", prefix, prefix, prefix)). + Where(fmt.Sprintf("%stags.alias = ?", prefix), alias) } func FilterArticleWithRealm(tx *gorm.DB, id uint) *gorm.DB { diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index cab3c65..0e511f7 100644 --- a/pkg/internal/services/posts.go +++ b/pkg/internal/services/posts.go @@ -17,15 +17,15 @@ import ( func FilterPostWithCategory(tx *gorm.DB, alias string) *gorm.DB { prefix := viper.GetString("database.prefix") return tx.Joins(fmt.Sprintf("JOIN %spost_categories ON %sposts.id = %spost_categories.post_id", prefix, prefix, prefix)). - Joins(fmt.Sprintf("JOIN %spost_categories ON %spost_categories.id = %spost_categories.category_id", prefix, prefix, prefix)). - Where(fmt.Sprintf("%spost_categories.alias = ?", prefix), alias) + Joins(fmt.Sprintf("JOIN %scategories ON %scategories.id = %spost_categories.category_id", prefix, prefix, prefix)). + Where(fmt.Sprintf("%scategories.alias = ?", prefix), alias) } func FilterPostWithTag(tx *gorm.DB, alias string) *gorm.DB { prefix := viper.GetString("database.prefix") return tx.Joins(fmt.Sprintf("JOIN %spost_tags ON %sposts.id = %spost_tags.post_id", prefix, prefix, prefix)). - Joins(fmt.Sprintf("JOIN %spost_tags ON %spost_tags.id = %spost_tags.category_id", prefix, prefix, prefix)). - Where(fmt.Sprintf("%spost_tags.alias = ?", prefix), alias) + Joins(fmt.Sprintf("JOIN %stags ON %stags.id = %spost_tags.tag_id", prefix, prefix, prefix)). + Where(fmt.Sprintf("%stags.alias = ?", prefix), alias) } func FilterPostWithRealm(tx *gorm.DB, id uint) *gorm.DB {