From 29bbeef9dc7f06955e480c844ad8a475b7f1a733 Mon Sep 17 00:00:00 2001 From: xing Date: Fri, 3 Feb 2023 14:46:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/querycondition.go | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/model/querycondition.go b/model/querycondition.go index 33f0484..6b720a3 100644 --- a/model/querycondition.go +++ b/model/querycondition.go @@ -64,17 +64,9 @@ func ChunkFind[T Model](ctx context.Context, perLimit int, q *QueryCondition) (r 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...) } else { - rr, err = Finds[T](ctx, Conditions( - Where(q.where), - Fields(q.fields), - Group(q.group), - Having(q.having), - Join(q.join), - Order(q.order), - Offset(offset), - Limit(perLimit), - In(q.in...), - )) + q.offset = offset + q.limit = perLimit + rr, err = Finds[T](ctx, q) } offset += perLimit 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 { rr, total, err = SimplePagination[T](ctx, q.where, q.fields, q.group, i, perLimit, q.order, q.join, q.having, q.in...) } else { - rr, err = Finds[T](ctx, Conditions( - Where(q.where), - Fields(q.fields), - Group(q.group), - Having(q.having), - Join(q.join), - Order(q.order), - Offset(offset), - Limit(perLimit), - In(q.in...), - )) + q.offset = offset + q.limit = perLimit + rr, err = Finds[T](ctx, q) } offset += perLimit if (err != nil && err != sql.ErrNoRows) || len(rr) < 1 {