✨ Post type
This commit is contained in:
parent
3a5a84ae56
commit
045744aa18
@ -6,9 +6,15 @@ import (
|
|||||||
"gorm.io/datatypes"
|
"gorm.io/datatypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
PostTypeStory = "story"
|
||||||
|
PostTypeArticle = "article"
|
||||||
|
)
|
||||||
|
|
||||||
type Post struct {
|
type Post struct {
|
||||||
BaseModel
|
BaseModel
|
||||||
|
|
||||||
|
Type string `json:"type"`
|
||||||
Body datatypes.JSONMap `json:"body"`
|
Body datatypes.JSONMap `json:"body"`
|
||||||
Language string `json:"language"`
|
Language string `json:"language"`
|
||||||
Tags []Tag `json:"tags" gorm:"many2many:post_tags"`
|
Tags []Tag `json:"tags" gorm:"many2many:post_tags"`
|
||||||
|
@ -46,6 +46,7 @@ func createArticle(c *fiber.Ctx) error {
|
|||||||
_ = jsoniter.Unmarshal(rawBody, &bodyMapping)
|
_ = jsoniter.Unmarshal(rawBody, &bodyMapping)
|
||||||
|
|
||||||
item := models.Post{
|
item := models.Post{
|
||||||
|
Type: models.PostTypeArticle,
|
||||||
Body: bodyMapping,
|
Body: bodyMapping,
|
||||||
Tags: data.Tags,
|
Tags: data.Tags,
|
||||||
Categories: data.Categories,
|
Categories: data.Categories,
|
||||||
|
@ -48,6 +48,7 @@ func createStory(c *fiber.Ctx) error {
|
|||||||
_ = jsoniter.Unmarshal(rawBody, &bodyMapping)
|
_ = jsoniter.Unmarshal(rawBody, &bodyMapping)
|
||||||
|
|
||||||
item := models.Post{
|
item := models.Post{
|
||||||
|
Type: models.PostTypeStory,
|
||||||
Body: bodyMapping,
|
Body: bodyMapping,
|
||||||
Tags: data.Tags,
|
Tags: data.Tags,
|
||||||
Categories: data.Categories,
|
Categories: data.Categories,
|
||||||
|
Loading…
Reference in New Issue
Block a user