Personal Page

This commit is contained in:
2024-02-03 19:22:50 +08:00
parent 1f4164e72a
commit 6c52a862a5
13 changed files with 218 additions and 68 deletions

View File

@ -10,13 +10,11 @@ import (
"gorm.io/gorm"
)
func ListPost(take int, offset int) ([]*models.Post, error) {
func ListPost(tx *gorm.DB, take int, offset int) ([]*models.Post, error) {
var posts []*models.Post
if err := database.C.
Where(&models.Post{RealmID: nil}).
if err := tx.
Limit(take).
Offset(offset).
Order("created_at desc").
Preload("Author").
Find(&posts).Error; err != nil {
return posts, err