|
|
@@ -2,6 +2,7 @@ package utils
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
+
|
|
|
"git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
|
|
|
"github.com/xormplus/xorm"
|
|
|
)
|
|
|
@@ -40,7 +41,10 @@ func PageSearch(engine *xorm.Engine, controllername string, apiname string, tabl
|
|
|
return &presult, nil
|
|
|
}
|
|
|
|
|
|
- records := cresult[0]["records"].(int64)
|
|
|
+ records := 0
|
|
|
+ if cresult != nil && len(cresult) > 0 {
|
|
|
+ records = cresult[0]["records"].(int64)
|
|
|
+ }
|
|
|
|
|
|
var totalPageSize int64 = 0
|
|
|
if records < int64(rows) {
|
|
|
@@ -48,7 +52,7 @@ func PageSearch(engine *xorm.Engine, controllername string, apiname string, tabl
|
|
|
} else if records%int64(rows) == 0 {
|
|
|
totalPageSize = records / int64(rows)
|
|
|
} else {
|
|
|
- totalPageSize = records / int64(rows) + 1
|
|
|
+ totalPageSize = records/int64(rows) + 1
|
|
|
}
|
|
|
|
|
|
presult := models.PageResult{}
|