2024-02-02 23:42:42 +08:00
|
|
|
package models
|
|
|
|
|
2024-03-03 01:23:11 +08:00
|
|
|
import (
|
2024-05-17 20:52:13 +08:00
|
|
|
"gorm.io/datatypes"
|
2024-03-03 01:23:11 +08:00
|
|
|
"time"
|
|
|
|
)
|
2024-02-02 23:42:42 +08:00
|
|
|
|
2024-03-03 01:23:11 +08:00
|
|
|
type PostReactInfo struct {
|
|
|
|
PostID uint `json:"post_id"`
|
|
|
|
LikeCount int64 `json:"like_count"`
|
|
|
|
DislikeCount int64 `json:"dislike_count"`
|
|
|
|
ReplyCount int64 `json:"reply_count"`
|
|
|
|
RepostCount int64 `json:"repost_count"`
|
|
|
|
}
|
|
|
|
|
2024-05-15 19:45:49 +08:00
|
|
|
type Post struct {
|
2024-02-02 23:42:42 +08:00
|
|
|
BaseModel
|
|
|
|
|
2024-05-20 22:33:39 +08:00
|
|
|
Alias string `json:"alias" gorm:"uniqueIndex"`
|
|
|
|
Content string `json:"content"`
|
|
|
|
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"`
|
2024-05-15 19:45:49 +08:00
|
|
|
|
2024-03-10 18:38:42 +08:00
|
|
|
PublishedAt *time.Time `json:"published_at"`
|
2024-03-03 01:23:11 +08:00
|
|
|
|
|
|
|
AuthorID uint `json:"author_id"`
|
|
|
|
Author Account `json:"author"`
|
2024-02-03 00:50:23 +08:00
|
|
|
|
2024-03-03 22:57:17 +08:00
|
|
|
// Dynamic Calculated Values
|
2024-05-18 16:59:58 +08:00
|
|
|
ReplyCount int64 `json:"reply_count"`
|
2024-05-15 19:45:49 +08:00
|
|
|
ReactionCount int64 `json:"reaction_count"`
|
|
|
|
ReactionList map[string]int64 `json:"reaction_list" gorm:"-"`
|
2024-03-03 01:23:11 +08:00
|
|
|
}
|