Skip to content

Commit

Permalink
modified
Browse files Browse the repository at this point in the history
  • Loading branch information
NeterAlex committed May 10, 2023
1 parent 28d5fb6 commit a74113a
Show file tree
Hide file tree
Showing 9 changed files with 674 additions and 25 deletions.
10 changes: 10 additions & 0 deletions biz/dal/sqlite/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ func QueryExclude[T comment.Comment | post.Post | user.User | stat.Stat](where,
return res, total, nil
}

func QueryByOrder[T comment.Comment | post.Post | user.User | stat.Stat](key, order string, limit int) ([]*T, error) {
var t T
db := DB.Model(t)
var res []*T
if err := db.Order(key + " " + order).Limit(limit).Find(&res).Error; err != nil {
return nil, err
}
return res, nil
}

func QueryAll[T comment.Comment | post.Post | user.User | stat.Stat](page, pageSize int64) ([]*T, int64, error) {
var t T
db := DB.Model(t)
Expand Down
12 changes: 12 additions & 0 deletions biz/handler/post/post_service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions biz/model/comment/comment.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a74113a

Please sign in to comment.