This commit is contained in:
xing 2023-02-03 14:46:25 +08:00
parent f831499341
commit 29bbeef9dc

View File

@ -64,17 +64,9 @@ func ChunkFind[T Model](ctx context.Context, perLimit int, q *QueryCondition) (r
if 1 == i { if 1 == i {
rr, total, err = SimplePagination[T](ctx, q.where, q.fields, q.group, i, perLimit, q.order, q.join, q.having, q.in...) rr, total, err = SimplePagination[T](ctx, q.where, q.fields, q.group, i, perLimit, q.order, q.join, q.having, q.in...)
} else { } else {
rr, err = Finds[T](ctx, Conditions( q.offset = offset
Where(q.where), q.limit = perLimit
Fields(q.fields), rr, err = Finds[T](ctx, q)
Group(q.group),
Having(q.having),
Join(q.join),
Order(q.order),
Offset(offset),
Limit(perLimit),
In(q.in...),
))
} }
offset += perLimit offset += perLimit
if (err != nil && err != sql.ErrNoRows) || len(rr) < 1 { if (err != nil && err != sql.ErrNoRows) || len(rr) < 1 {
@ -102,17 +94,9 @@ func Chunk[T Model, R any](ctx context.Context, perLimit int, fn func(rows T) (R
if 1 == i { if 1 == i {
rr, total, err = SimplePagination[T](ctx, q.where, q.fields, q.group, i, perLimit, q.order, q.join, q.having, q.in...) rr, total, err = SimplePagination[T](ctx, q.where, q.fields, q.group, i, perLimit, q.order, q.join, q.having, q.in...)
} else { } else {
rr, err = Finds[T](ctx, Conditions( q.offset = offset
Where(q.where), q.limit = perLimit
Fields(q.fields), rr, err = Finds[T](ctx, q)
Group(q.group),
Having(q.having),
Join(q.join),
Order(q.order),
Offset(offset),
Limit(perLimit),
In(q.in...),
))
} }
offset += perLimit offset += perLimit
if (err != nil && err != sql.ErrNoRows) || len(rr) < 1 { if (err != nil && err != sql.ErrNoRows) || len(rr) < 1 {