From fd951b7ab8f2df1d37b5d57abd7a3951763ffcb2 Mon Sep 17 00:00:00 2001 From: xing Date: Tue, 7 Feb 2023 23:05:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E6=9F=A5=E8=AF=A2=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E9=87=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/actions/detail.go | 4 ---- model/querycondition.go | 18 +++++++++--------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/internal/actions/detail.go b/internal/actions/detail.go index 1270b5d..f8ff6bf 100644 --- a/internal/actions/detail.go +++ b/internal/actions/detail.go @@ -14,10 +14,6 @@ import ( "net/http" ) -type detailHandler struct { - *gin.Context -} - func Detail(c *gin.Context) { var err error var post models.Posts diff --git a/model/querycondition.go b/model/querycondition.go index 1f611ea..6b02382 100644 --- a/model/querycondition.go +++ b/model/querycondition.go @@ -16,10 +16,10 @@ func Finds[T Model](ctx context.Context, q *QueryCondition) (r []T, err error) { return } -// DBFind 同 Finds 使用指定 db 查询 +// FindFromDB 同 Finds 使用指定 db 查询 // // Conditions 中可用 Where Fields Group Having Join Order Offset Limit In 函数 -func DBFind[T Model](db dbQuery, ctx context.Context, q *QueryCondition) (r []T, err error) { +func FindFromDB[T Model](db dbQuery, ctx context.Context, q *QueryCondition) (r []T, err error) { r, err = finds[T](db, ctx, q) return } @@ -100,10 +100,10 @@ func ChunkFind[T Model](ctx context.Context, perLimit int, q *QueryCondition) (r return } -// DBChunkFind 同 ChunkFind +// ChunkFindFromDB 同 ChunkFind // // Conditions 中可用 Where Fields Group Having Join Order Limit In 函数 -func DBChunkFind[T Model](db dbQuery, ctx context.Context, perLimit int, q *QueryCondition) (r []T, err error) { +func ChunkFindFromDB[T Model](db dbQuery, ctx context.Context, perLimit int, q *QueryCondition) (r []T, err error) { r, err = chunkFind[T](db, ctx, perLimit, q) return } @@ -116,10 +116,10 @@ func Chunk[T Model, R any](ctx context.Context, perLimit int, fn func(rows T) (R return } -// DBChunk 同 Chunk +// ChunkFromDB 同 Chunk // // Conditions 中可用 Where Fields Group Having Join Order Limit In 函数 -func DBChunk[T Model, R any](db dbQuery, ctx context.Context, perLimit int, fn func(rows T) (R, bool), q *QueryCondition) (r []R, err error) { +func ChunkFromDB[T Model, R any](db dbQuery, ctx context.Context, perLimit int, fn func(rows T) (R, bool), q *QueryCondition) (r []R, err error) { r, err = chunk(db, ctx, perLimit, fn, q) return } @@ -164,17 +164,17 @@ func Pagination[T Model](ctx context.Context, q *QueryCondition) ([]T, int, erro return SimplePagination[T](ctx, q.where, q.fields, q.group, q.page, q.limit, q.order, q.join, q.having, q.in...) } -// DBPagination 同 Pagination 方便多个db使用 +// PaginationFromDB 同 Pagination 方便多个db使用 // // Condition 中可使用 Where Fields Group Having Join Order Page Limit In 函数 -func DBPagination[T Model](db dbQuery, ctx context.Context, q *QueryCondition) ([]T, int, error) { +func PaginationFromDB[T Model](db dbQuery, ctx context.Context, q *QueryCondition) ([]T, int, error) { 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) ([]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) { +func ColumnFromDB[V Model, T any](db dbQuery, ctx context.Context, fn func(V) (T, bool), q *QueryCondition) (r []T, err error) { return column[V, T](db, ctx, fn, q) }