Reaction info

This commit is contained in:
2024-03-03 22:57:17 +08:00
parent 1725724758
commit 932bdf1e5a
10 changed files with 187 additions and 46 deletions

View File

@ -15,26 +15,26 @@ type Article struct {
Comments []Comment `json:"comments" gorm:"foreignKey:ArticleID"`
}
func (p Article) GetReplyTo() PostInterface {
func (p *Article) GetReplyTo() PostInterface {
return nil
}
func (p Article) GetRepostTo() PostInterface {
func (p *Article) GetRepostTo() PostInterface {
return nil
}
func (p Article) GetHashtags() []Tag {
func (p *Article) GetHashtags() []Tag {
return p.Hashtags
}
func (p Article) GetCategories() []Category {
func (p *Article) GetCategories() []Category {
return p.Categories
}
func (p Article) SetHashtags(tags []Tag) {
func (p *Article) SetHashtags(tags []Tag) {
p.Hashtags = tags
}
func (p Article) SetCategories(categories []Category) {
func (p *Article) SetCategories(categories []Category) {
p.Categories = categories
}

View File

@ -16,22 +16,22 @@ type Comment struct {
Moment *Moment `json:"moment"`
}
func (p Comment) GetReplyTo() PostInterface {
func (p *Comment) GetReplyTo() PostInterface {
return p.ReplyTo
}
func (p Comment) GetHashtags() []Tag {
func (p *Comment) GetHashtags() []Tag {
return p.Hashtags
}
func (p Comment) GetCategories() []Category {
func (p *Comment) GetCategories() []Category {
return p.Categories
}
func (p Comment) SetHashtags(tags []Tag) {
func (p *Comment) SetHashtags(tags []Tag) {
p.Hashtags = tags
}
func (p Comment) SetCategories(categories []Category) {
func (p *Comment) SetCategories(categories []Category) {
p.Categories = categories
}

View File

@ -15,26 +15,26 @@ type Moment struct {
Comments []Comment `json:"comments" gorm:"foreignKey:MomentID"`
}
func (p Moment) GetRepostTo() PostInterface {
func (p *Moment) GetRepostTo() PostInterface {
return p.RepostTo
}
func (p Moment) GetRealm() *Realm {
func (p *Moment) GetRealm() *Realm {
return p.Realm
}
func (p Moment) GetHashtags() []Tag {
func (p *Moment) GetHashtags() []Tag {
return p.Hashtags
}
func (p Moment) GetCategories() []Category {
func (p *Moment) GetCategories() []Category {
return p.Categories
}
func (p Moment) SetHashtags(tags []Tag) {
func (p *Moment) SetHashtags(tags []Tag) {
p.Hashtags = tags
}
func (p Moment) SetCategories(categories []Category) {
func (p *Moment) SetCategories(categories []Category) {
p.Categories = categories
}

View File

@ -22,29 +22,34 @@ type PostBase struct {
AuthorID uint `json:"author_id"`
Author Account `json:"author"`
// TODO Give the reactions & replies & reposts info back
// Dynamic Calculated Values
ReactionList map[string]int64 `json:"reaction_list" gorm:"-"`
}
func (p PostBase) GetID() uint {
func (p *PostBase) GetID() uint {
return p.ID
}
func (p PostBase) GetReplyTo() PostInterface {
func (p *PostBase) GetReplyTo() PostInterface {
return nil
}
func (p PostBase) GetRepostTo() PostInterface {
func (p *PostBase) GetRepostTo() PostInterface {
return nil
}
func (p PostBase) GetAuthor() Account {
func (p *PostBase) GetAuthor() Account {
return p.Author
}
func (p PostBase) GetRealm() *Realm {
func (p *PostBase) GetRealm() *Realm {
return nil
}
func (p *PostBase) SetReactionList(list map[string]int64) {
p.ReactionList = list
}
type PostInterface interface {
GetID() uint
GetHashtags() []Tag
@ -56,4 +61,5 @@ type PostInterface interface {
SetHashtags([]Tag)
SetCategories([]Category)
SetReactionList(map[string]int64)
}