mirror of
https://github.com/go-home-admin/toolset.git
synced 2025-12-24 13:37:52 +08:00
添加分页
This commit is contained in:
@@ -176,6 +176,11 @@ func (orm *OrmMysqlTableName) Paginate(page int, limit int) (MysqlTableNameList,
|
||||
list := make([]*MysqlTableName, 0)
|
||||
orm.db.Count(&total)
|
||||
if total > 0 {
|
||||
if page == 0 {
|
||||
page = 1
|
||||
}
|
||||
|
||||
offset := (page - 1) * limit
|
||||
tx := orm.db.Offset(page).Limit(limit).Find(&list)
|
||||
if tx.Error != nil {
|
||||
logrus.Error(tx.Error)
|
||||
|
||||
@@ -176,7 +176,12 @@ func (orm *Orm{orm_table_name}) Paginate(page int, limit int) ({orm_table_name}L
|
||||
list := make([]*{orm_table_name}, 0)
|
||||
orm.db.Count(&total)
|
||||
if total > 0 {
|
||||
tx := orm.db.Offset(page).Limit(limit).Find(&list)
|
||||
if page == 0 {
|
||||
page = 1
|
||||
}
|
||||
|
||||
offset := (page - 1) * limit
|
||||
tx := orm.db.Offset(offset).Limit(limit).Find(&list)
|
||||
if tx.Error != nil {
|
||||
logrus.Error(tx.Error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user