65 lines
1.2 KiB
Go
Raw Normal View History

2024-02-02 23:42:42 +08:00
package models
2024-03-03 01:23:11 +08:00
import (
"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"`
}
type PostBase struct {
2024-02-02 23:42:42 +08:00
BaseModel
2024-03-10 18:38:42 +08:00
Alias string `json:"alias" gorm:"uniqueIndex"`
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
ReactionList map[string]int64 `json:"reaction_list" gorm:"-"`
2024-02-02 23:42:42 +08:00
}
2024-03-03 01:23:11 +08:00
2024-03-03 22:57:17 +08:00
func (p *PostBase) GetID() uint {
2024-03-03 01:23:11 +08:00
return p.ID
}
2024-03-03 22:57:17 +08:00
func (p *PostBase) GetReplyTo() PostInterface {
2024-03-03 01:23:11 +08:00
return nil
}
2024-03-03 22:57:17 +08:00
func (p *PostBase) GetRepostTo() PostInterface {
2024-03-03 01:23:11 +08:00
return nil
}
2024-03-03 22:57:17 +08:00
func (p *PostBase) GetAuthor() Account {
2024-03-03 01:23:11 +08:00
return p.Author
}
2024-03-03 22:57:17 +08:00
func (p *PostBase) GetRealm() *Realm {
2024-03-03 01:23:11 +08:00
return nil
}
2024-03-03 22:57:17 +08:00
func (p *PostBase) SetReactionList(list map[string]int64) {
p.ReactionList = list
}
2024-03-03 01:23:11 +08:00
type PostInterface interface {
GetID() uint
GetHashtags() []Tag
GetCategories() []Category
GetReplyTo() PostInterface
GetRepostTo() PostInterface
GetAuthor() Account
GetRealm() *Realm
SetHashtags([]Tag)
SetCategories([]Category)
2024-03-03 22:57:17 +08:00
SetReactionList(map[string]int64)
2024-03-03 01:23:11 +08:00
}