You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
555 B

  1. package servers
  2. import (
  3. "github.com/jinzhu/gorm"
  4. "main/init/qmsql"
  5. "main/model/modelInterface"
  6. )
  7. //获取分页功能 接收实现了分页接口的结构体 返回搜索完成的结果 许需要自行scan 或者find
  8. func PagingServer(paging modelInterface.Paging, info modelInterface.PageInfo) (err error, db *gorm.DB, total int) {
  9. limit := info.PageSize
  10. offset := info.PageSize * (info.Page - 1)
  11. err = qmsql.DEFAULTDB.Model(paging).Count(&total).Error
  12. db = qmsql.DEFAULTDB.Limit(limit).Offset(offset).Order("id desc")
  13. return err, db, total
  14. }