Interactive/pkg/models/posts.go

65 lines
1.2 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"`
}
type PostBase struct {
2024-02-02 15:42:42 +00:00
BaseModel
2024-03-10 10:38:42 +00:00
Alias string `json:"alias" gorm:"uniqueIndex"`
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
ReactionList map[string]int64 `json:"reaction_list" gorm:"-"`
2024-02-02 15:42:42 +00:00
}
2024-03-02 17:23:11 +00:00
2024-03-03 14:57:17 +00:00
func (p *PostBase) GetID() uint {
2024-03-02 17:23:11 +00:00
return p.ID
}
2024-03-03 14:57:17 +00:00
func (p *PostBase) GetReplyTo() PostInterface {
2024-03-02 17:23:11 +00:00
return nil
}
2024-03-03 14:57:17 +00:00
func (p *PostBase) GetRepostTo() PostInterface {
2024-03-02 17:23:11 +00:00
return nil
}
2024-03-03 14:57:17 +00:00
func (p *PostBase) GetAuthor() Account {
2024-03-02 17:23:11 +00:00
return p.Author
}
2024-03-03 14:57:17 +00:00
func (p *PostBase) GetRealm() *Realm {
2024-03-02 17:23:11 +00:00
return nil
}
2024-03-03 14:57:17 +00:00
func (p *PostBase) SetReactionList(list map[string]int64) {
p.ReactionList = list
}
2024-03-02 17:23:11 +00: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 14:57:17 +00:00
SetReactionList(map[string]int64)
2024-03-02 17:23:11 +00:00
}