diff --git a/pkg/internal/models/posts.go b/pkg/internal/models/posts.go index f15eb66..03f90e8 100644 --- a/pkg/internal/models/posts.go +++ b/pkg/internal/models/posts.go @@ -6,9 +6,15 @@ import ( "gorm.io/datatypes" ) +const ( + PostTypeStory = "story" + PostTypeArticle = "article" +) + type Post struct { BaseModel + Type string `json:"type"` Body datatypes.JSONMap `json:"body"` Language string `json:"language"` Tags []Tag `json:"tags" gorm:"many2many:post_tags"` diff --git a/pkg/internal/server/api/articles_api.go b/pkg/internal/server/api/articles_api.go index 5d87551..5f8d070 100644 --- a/pkg/internal/server/api/articles_api.go +++ b/pkg/internal/server/api/articles_api.go @@ -46,6 +46,7 @@ func createArticle(c *fiber.Ctx) error { _ = jsoniter.Unmarshal(rawBody, &bodyMapping) item := models.Post{ + Type: models.PostTypeArticle, Body: bodyMapping, Tags: data.Tags, Categories: data.Categories, diff --git a/pkg/internal/server/api/stories_api.go b/pkg/internal/server/api/stories_api.go index df35f48..655114c 100644 --- a/pkg/internal/server/api/stories_api.go +++ b/pkg/internal/server/api/stories_api.go @@ -48,6 +48,7 @@ func createStory(c *fiber.Ctx) error { _ = jsoniter.Unmarshal(rawBody, &bodyMapping) item := models.Post{ + Type: models.PostTypeStory, Body: bodyMapping, Tags: data.Tags, Categories: data.Categories,