From b1859409daf3bf401ad47baa172c83dfe20ea840 Mon Sep 17 00:00:00 2001 From: xing Date: Mon, 6 Feb 2023 18:42:36 +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 | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/model/querycondition.go b/model/querycondition.go index 3c46f11..1f611ea 100644 --- a/model/querycondition.go +++ b/model/querycondition.go @@ -171,21 +171,11 @@ func DBPagination[T Model](db dbQuery, ctx context.Context, q *QueryCondition) ( return pagination[T](db, ctx, q.where, q.fields, q.group, q.page, q.limit, q.order, q.join, q.having, q.in...) } -func Column[V Model, T any](ctx context.Context, fn func(V) (T, bool), q *QueryCondition) (r []T, err error) { - res, err := finds[V](globalBb, ctx, q) - if err != nil { - return nil, err - } - r = slice.FilterAndMap(res, fn) - return +func Column[V Model, T any](ctx context.Context, fn func(V) (T, bool), q *QueryCondition) ([]T, error) { + return column[V, T](globalBb, ctx, fn, q) } func DBColumn[V Model, T any](db dbQuery, ctx context.Context, fn func(V) (T, bool), q *QueryCondition) (r []T, err error) { - res, err := finds[V](db, ctx, q) - if err != nil { - return nil, err - } - r = slice.FilterAndMap(res, fn) - return + return column[V, T](db, ctx, fn, q) } func column[V Model, T any](db dbQuery, ctx context.Context, fn func(V) (T, bool), q *QueryCondition) (r []T, err error) {