Posts

This commit is contained in:
2024-02-02 23:42:42 +08:00
parent 19e1775476
commit 89521c15af
20 changed files with 426 additions and 62 deletions

View File

@ -6,9 +6,12 @@ package models
type Account struct {
BaseModel
Name string `json:"name"`
Avatar string `json:"avatar"`
EmailAddress string `json:"email_address"`
PowerLevel int `json:"power_level"`
ExternalID uint `json:"external_id"`
Name string `json:"name"`
Avatar string `json:"avatar"`
Description string `json:"description"`
EmailAddress string `json:"email_address"`
PowerLevel int `json:"power_level"`
Posts []Post `json:"posts" gorm:"foreignKey:AuthorID"`
Realms []Realm `json:"realms"`
ExternalID uint `json:"external_id"`
}

19
pkg/models/categories.go Normal file
View File

@ -0,0 +1,19 @@
package models
type Tag struct {
BaseModel
Alias string `json:"alias" gorm:"uniqueIndex"`
Name string `json:"name"`
Description string `json:"description"`
Posts []Post `json:"posts" gorm:"many2many:post_tags"`
}
type Category struct {
BaseModel
Alias string `json:"alias" gorm:"uniqueIndex"`
Name string `json:"name"`
Description string `json:"description"`
Posts []Post `json:"categories" gorm:"many2many:post_categories"`
}

17
pkg/models/posts.go Normal file
View File

@ -0,0 +1,17 @@
package models
import "time"
type Post struct {
BaseModel
Alias string `json:"alias" gorm:"uniqueIndex"`
Title string `json:"title"`
Content string `json:"content"`
Tags []Tag `gorm:"many2many:post_tags"`
Categories []Category `gorm:"many2many:post_categories"`
PublishedAt time.Time `json:"published_at"`
RealmID *uint `json:"realm_id"`
AuthorID uint `json:"author_id"`
Author Account `json:"author"`
}

10
pkg/models/realms.go Normal file
View File

@ -0,0 +1,10 @@
package models
type Realm struct {
BaseModel
Name string `json:"name"`
Description string `json:"description"`
Posts []Post `json:"posts"`
AccountID uint `json:"account_id"`
}