parent
6a6d2c7042
commit
56821c2833
|
@ -11,9 +11,14 @@ import (
|
||||||
func GetTotalPages(database *gorm.DB, paginationLimit int, any interface{}, whereQuery interface{}, args ...interface{}) int {
|
func GetTotalPages(database *gorm.DB, paginationLimit int, any interface{}, whereQuery interface{}, args ...interface{}) int {
|
||||||
var totalPages int64
|
var totalPages int64
|
||||||
|
|
||||||
database.Model(any).
|
if whereQuery == nil {
|
||||||
Where(whereQuery, args).
|
database.Model(any).
|
||||||
Count(&totalPages)
|
Count(&totalPages)
|
||||||
|
} else {
|
||||||
|
database.Model(any).
|
||||||
|
Where(whereQuery, args).
|
||||||
|
Count(&totalPages)
|
||||||
|
}
|
||||||
|
|
||||||
return int(math.Ceil(float64(totalPages) / float64(paginationLimit)))
|
return int(math.Ceil(float64(totalPages) / float64(paginationLimit)))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue