Interactive/pkg/models/posts.go

42 lines
1.3 KiB
Go
Raw Normal View History

2024-02-02 15:42:42 +00:00
package models
2024-03-02 17:23:11 +00:00
import (
"time"
)
2024-02-02 15:42:42 +00:00
2024-03-02 17:23:11 +00: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 11:45:49 +00:00
type Post struct {
2024-02-02 15:42:42 +00:00
BaseModel
2024-05-15 11:45:49 +00: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"`
Attachments []Attachment `json:"attachments"`
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"`
2024-03-10 10:38:42 +00:00
PublishedAt *time.Time `json:"published_at"`
2024-03-02 17:23:11 +00:00
AuthorID uint `json:"author_id"`
Author Account `json:"author"`
2024-02-02 16:50:23 +00:00
2024-03-03 14:57:17 +00:00
// Dynamic Calculated Values
2024-05-15 11:45:49 +00:00
ReplyCount int64 `json:"comment_count"`
ReactionCount int64 `json:"reaction_count"`
ReactionList map[string]int64 `json:"reaction_list" gorm:"-"`
2024-03-02 17:23:11 +00:00
}