Skip to content

Commit

Permalink
先取出数据会导致表被重置,所以需要先计算再取出数据才合理,上古BUG今天细看才发现
Browse files Browse the repository at this point in the history
  • Loading branch information
tobycroft committed Jun 16, 2022
1 parent 7a0894f commit 2f07b51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gorose.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
// VERSION_TEXT ...
VERSION_TEXT = "\ngolang orm of gorose's version : "
// VERSION_NO ...
VERSION_NO = "v2.2.0"
VERSION_NO = "v1.3.0"
// VERSION ...
VERSION = VERSION_TEXT + VERSION_NO + GOROSE_IMG
)
Expand Down
13 changes: 7 additions & 6 deletions orm_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,18 +413,19 @@ func (dba *Orm) Paginate(page ...int) (res Data, err error) {
}
var offset = dba.GetOffset()
var currentPage = int(math.Ceil(float64(offset+1) / float64(limit)))
//dba.ResetUnion()
// 获取结果
resData, err := dba.Get()
if err != nil {
return
}

// 统计总量
dba.offset = 0
count, err := dba.Count()
var lastPage = int(math.Ceil(float64(count) / float64(limit)))
var nextPage = currentPage + 1
var prevPage = currentPage - 1
//dba.ResetUnion()
// 获取结果
resData, err := dba.Get()
if err != nil {
return
}
res = Data{
"total": count,
"per_page": limit,
Expand Down

0 comments on commit 2f07b51

Please sign in to comment.