♻️ 一切尽在帖子表 #4

Merged
LittleSheep merged 7 commits from refactor/everything-in-post into master 2024-07-22 05:46:47 +00:00
3 changed files with 8 additions and 0 deletions
Showing only changes of commit 045744aa18 - Show all commits

View File

@ -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"`

View File

@ -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,

View File

@ -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,