19 lines
404 B
Go
19 lines
404 B
Go
package helper
|
|
|
|
type Pagination struct {
|
|
Page int `json:"page"` // 页
|
|
Size int `json:"size"` // 页大小
|
|
}
|
|
|
|
//func SetBaseQuery(page *Pagination, order string) func(db *gorm.DB) *gorm.DB {
|
|
// return func(db *gorm.DB) *gorm.DB {
|
|
// if page != nil {
|
|
// db = db.Offset((page.Page - 1) * page.Size).Limit(page.Size)
|
|
// }
|
|
// if len(order) > 0 {
|
|
// db = db.Order(order)
|
|
// }
|
|
// return db
|
|
// }
|
|
//}
|