1234567891011121314151617181920 |
- package common
- import (
- "confrontation-training/global"
- "confrontation-training/models"
- )
- func RestPage(page models.Page, tableName string, query interface{}, orderBy string, dest interface{}, bind interface{}) int64 {
- if page.PageNum > 0 && page.PageSize > 0 {
- offset := (page.PageNum - 1) * page.PageSize
- global.Db.Debug().Offset(offset).Limit(page.PageSize).Table(tableName).Where(query).Order(orderBy).Find(dest)
- }
- return global.Db.Debug().Table(tableName).Where(query).Order(orderBy).Find(bind).RowsAffected
- }
|