Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
admpub committed Aug 23, 2023
1 parent 66ae145 commit 57a3154
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/factory/pagination/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,20 @@ func PagingWithPosition(ctx echo.Context, delKeys ...string) (offset int, size i
return
}

func DisabledExecCount(ctx echo.Context, disabled ...bool) {
func DisableCount(ctx echo.Context, disabled ...bool) {
if len(disabled) > 0 && !disabled[0] {
ctx.Internal().Set(`paging.disabledExecCount`, false)
ctx.Internal().Set(`paging.disableCount`, false)
return
}
ctx.Internal().Set(`paging.disabledExecCount`, true)
ctx.Internal().Set(`paging.disableCount`, true)
}

// PagingWithLister 通过分页查询接口获取分页信息
func PagingWithLister(ctx echo.Context, m Lister, varSuffix ...string) (*pagination.Pagination, error) {
page, size, totalRows, p := PagingWithPagination(ctx)
cnt, err := m.List(nil, nil, page, size)
disabledExecCount := ctx.Internal().Bool(`paging.disabledExecCount`)
if !disabledExecCount && totalRows <= 0 {
disableCount := ctx.Internal().Bool(`paging.disableCount`)
if !disableCount && totalRows <= 0 {
totalRows = int(cnt())
p.SetRows(totalRows)
}
Expand All @@ -136,7 +136,7 @@ func PagingWithLister(ctx echo.Context, m Lister, varSuffix ...string) (*paginat
} else {
ctx.Set(`pagination`, p)
}
if !disabledExecCount {
if !disableCount {
return p, err
}
var hasMore bool
Expand Down

0 comments on commit 57a3154

Please sign in to comment.