parent
930ef2120e
commit
39ef3fa9e5
|
@ -36,16 +36,16 @@ type PageQuery struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DbPageQuery(database *gorm.DB, query PageQuery, paginationLimit int, result any, orderBy string, whereQuery interface{}, args ...interface{}) *gorm.DB {
|
func DbPageQuery(database *gorm.DB, query PageQuery, paginationLimit int, result any, orderBy string, whereQuery interface{}, args ...interface{}) *gorm.DB {
|
||||||
|
if whereQuery == nil {
|
||||||
return database.Limit(paginationLimit).
|
return database.Limit(paginationLimit).
|
||||||
Offset(GetPageOffset(query.Page, paginationLimit)).
|
Offset(GetPageOffset(query.Page, paginationLimit)).
|
||||||
Where(whereQuery, args).
|
|
||||||
Order(orderBy).
|
Order(orderBy).
|
||||||
Find(result)
|
Find(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DbPageQueryWithoutWhere(database *gorm.DB, query PageQuery, paginationLimit int, result any, orderBy string) *gorm.DB {
|
|
||||||
return database.Limit(paginationLimit).
|
return database.Limit(paginationLimit).
|
||||||
Offset(GetPageOffset(query.Page, paginationLimit)).
|
Offset(GetPageOffset(query.Page, paginationLimit)).
|
||||||
|
Where(whereQuery, args).
|
||||||
Order(orderBy).
|
Order(orderBy).
|
||||||
Find(result)
|
Find(result)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue