先取出数据会导致表被重置,所以需要先计算再取出数据才合理,上古BUG今天细看才发现

This commit is contained in:
火线兔
2022-06-16 17:21:53 +08:00
parent 7a0894fd37
commit 2f07b51e60
2 changed files with 8 additions and 7 deletions

View File

@@ -16,7 +16,7 @@ const (
// VERSION_TEXT ... // VERSION_TEXT ...
VERSION_TEXT = "\ngolang orm of gorose's version : " VERSION_TEXT = "\ngolang orm of gorose's version : "
// VERSION_NO ... // VERSION_NO ...
VERSION_NO = "v2.2.0" VERSION_NO = "v1.3.0"
// VERSION ... // VERSION ...
VERSION = VERSION_TEXT + VERSION_NO + GOROSE_IMG VERSION = VERSION_TEXT + VERSION_NO + GOROSE_IMG
) )

View File

@@ -413,18 +413,19 @@ func (dba *Orm) Paginate(page ...int) (res Data, err error) {
} }
var offset = dba.GetOffset() var offset = dba.GetOffset()
var currentPage = int(math.Ceil(float64(offset+1) / float64(limit))) var currentPage = int(math.Ceil(float64(offset+1) / float64(limit)))
//dba.ResetUnion()
// 获取结果
resData, err := dba.Get()
if err != nil {
return
}
// 统计总量 // 统计总量
dba.offset = 0 dba.offset = 0
count, err := dba.Count() count, err := dba.Count()
var lastPage = int(math.Ceil(float64(count) / float64(limit))) var lastPage = int(math.Ceil(float64(count) / float64(limit)))
var nextPage = currentPage + 1 var nextPage = currentPage + 1
var prevPage = currentPage - 1 var prevPage = currentPage - 1
//dba.ResetUnion()
// 获取结果
resData, err := dba.Get()
if err != nil {
return
}
res = Data{ res = Data{
"total": count, "total": count,
"per_page": limit, "per_page": limit,