// Package model -----------------------------
// @file      : videoDto.go
// @author    : JJXu
// @contact   : wavingbear@163.com
// @time      : 2023/2/27 11:54
// -------------------------------------------
package db

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))
	}
}
