Frontend move to union feed

This commit is contained in:
2024-03-03 21:24:08 +08:00
parent e1822e5363
commit 1725724758
15 changed files with 199 additions and 47 deletions

View File

@ -37,8 +37,7 @@ func (v *PostTypeContext[T]) Preload() *PostTypeContext[T] {
v.Tx.Preload("Author").
Preload("Attachments").
Preload("Categories").
Preload("Hashtags").
Preload("Reactions")
Preload("Hashtags")
if v.CanReply {
v.Tx.Preload("ReplyTo")
@ -99,6 +98,15 @@ func (v *PostTypeContext[T]) SortCreatedAt(order string) *PostTypeContext[T] {
return v
}
func (v *PostTypeContext[T]) GetViaAlias(alias string) (T, error) {
var item T
if err := v.Preload().Tx.Where("alias = ?", alias).First(&item).Error; err != nil {
return item, err
}
return item, nil
}
func (v *PostTypeContext[T]) Get(id uint) (T, error) {
var item T
if err := v.Preload().Tx.Where("id = ?", id).First(&item).Error; err != nil {