You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
509 B
Go

// Package model -----------------------------
// @file : videoDto.go
// @author : JJXu
// @contact : wavingbear@163.com
// @time : 2023/2/27 11:54
// -------------------------------------------
package model
import "gorm.io/gorm"
func Pagination[T int | int32 | int64](page T, pageSize T) func(db *gorm.DB) *gorm.DB {
if page == 0 || pageSize == 0 {
page = 1
pageSize = 15
}
return func(db *gorm.DB) *gorm.DB {
return db.Limit(int(pageSize)).Offset(int((page - 1) * pageSize))
}
}