New story & article create & edit api

This commit is contained in:
2024-07-22 00:49:36 +08:00
parent 18dedfc493
commit 3a5a84ae56
7 changed files with 317 additions and 206 deletions

View File

@ -9,20 +9,18 @@ import (
type Post struct {
BaseModel
Alias string `json:"alias" gorm:"uniqueIndex"`
Content *string `json:"content"`
Language string `json:"language"`
Tags []Tag `json:"tags" gorm:"many2many:post_tags"`
Categories []Category `json:"categories" gorm:"many2many:post_categories"`
Reactions []Reaction `json:"reactions"`
Replies []Post `json:"replies" gorm:"foreignKey:ReplyID"`
Attachments datatypes.JSONSlice[uint] `json:"attachments"`
ReplyID *uint `json:"reply_id"`
RepostID *uint `json:"repost_id"`
RealmID *uint `json:"realm_id"`
ReplyTo *Post `json:"reply_to" gorm:"foreignKey:ReplyID"`
RepostTo *Post `json:"repost_to" gorm:"foreignKey:RepostID"`
Realm *Realm `json:"realm"`
Body datatypes.JSONMap `json:"body"`
Language string `json:"language"`
Tags []Tag `json:"tags" gorm:"many2many:post_tags"`
Categories []Category `json:"categories" gorm:"many2many:post_categories"`
Reactions []Reaction `json:"reactions"`
Replies []Post `json:"replies" gorm:"foreignKey:ReplyID"`
ReplyID *uint `json:"reply_id"`
RepostID *uint `json:"repost_id"`
RealmID *uint `json:"realm_id"`
ReplyTo *Post `json:"reply_to" gorm:"foreignKey:ReplyID"`
RepostTo *Post `json:"repost_to" gorm:"foreignKey:RepostID"`
Realm *Realm `json:"realm"`
IsDraft bool `json:"is_draft"`
PublishedAt *time.Time `json:"published_at"`
@ -32,3 +30,17 @@ type Post struct {
Metric PostMetric `json:"metric" gorm:"-"`
}
type PostStoryBody struct {
Title *string `json:"title"`
Content string `json:"content"`
Location *string `json:"location"`
Attachments []uint `json:"attachments"`
}
type PostArticleBody struct {
Title string `json:"title"`
Description *string `json:"description"`
Content string `json:"content"`
Attachments []uint `json:"attachments"`
}