diff --git a/pkg/internal/models/categories.go b/pkg/internal/models/categories.go index 1eb7b37..31c5867 100644 --- a/pkg/internal/models/categories.go +++ b/pkg/internal/models/categories.go @@ -3,7 +3,7 @@ package models type Tag struct { BaseModel - Alias string `json:"alias" gorm:"uniqueIndex" validate:"lowercase,alphanum,min=4,max=24"` + Alias string `json:"alias" gorm:"uniqueIndex" validate:"lowercase,alphanum"` Name string `json:"name"` Description string `json:"description"` Posts []Post `json:"posts" gorm:"many2many:post_tags"` @@ -13,7 +13,7 @@ type Tag struct { type Category struct { BaseModel - Alias string `json:"alias" gorm:"uniqueIndex" validate:"lowercase,alphanum,min=4,max=24"` + Alias string `json:"alias" gorm:"uniqueIndex" validate:"lowercase,alphanum"` Name string `json:"name"` Description string `json:"description"` Posts []Post `json:"posts" gorm:"many2many:post_categories"` diff --git a/pkg/internal/services/articles.go b/pkg/internal/services/articles.go index ee37aa9..4288f51 100644 --- a/pkg/internal/services/articles.go +++ b/pkg/internal/services/articles.go @@ -54,6 +54,8 @@ func GetArticleWithAlias(tx *gorm.DB, alias string, ignoreLimitation ...bool) (m var item models.Article if err := tx. Where("alias = ?", alias). + Preload("Tags"). + Preload("Categories"). Preload("Realm"). Preload("Author"). First(&item).Error; err != nil { @@ -71,6 +73,8 @@ func GetArticle(tx *gorm.DB, id uint, ignoreLimitation ...bool) (models.Article, var item models.Article if err := tx. Where("id = ?", id). + Preload("Tags"). + Preload("Categories"). Preload("Realm"). Preload("Author"). First(&item).Error; err != nil { diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index 0776a8e..b9fd418 100644 --- a/pkg/internal/services/posts.go +++ b/pkg/internal/services/posts.go @@ -62,6 +62,8 @@ func GetPostWithAlias(tx *gorm.DB, alias string, ignoreLimitation ...bool) (mode var item models.Post if err := tx. Where("alias = ?", alias). + Preload("Tags"). + Preload("Categories"). Preload("Realm"). Preload("Author"). Preload("ReplyTo"). @@ -83,6 +85,8 @@ func GetPost(tx *gorm.DB, id uint, ignoreLimitation ...bool) (models.Post, error var item models.Post if err := tx. Where("id = ?", id). + Preload("Tags"). + Preload("Categories"). Preload("Realm"). Preload("Author"). Preload("ReplyTo").