From 28b0ae24c980f9adff9c22318f962f7d1afae909 Mon Sep 17 00:00:00 2001 From: hulutech-web Date: Mon, 4 Nov 2024 17:28:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0wherein?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http_result.go | 1 + paginator.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/http_result.go b/http_result.go index f122926..ed233ce 100644 --- a/http_result.go +++ b/http_result.go @@ -31,6 +31,7 @@ type HttpResult struct { func NewResult(ctx http.Context) *HttpResult { return &HttpResult{ Context: ctx, + Query: facades.Orm().Query(), } } diff --git a/paginator.go b/paginator.go index 87d2d41..2bffb46 100644 --- a/paginator.go +++ b/paginator.go @@ -32,6 +32,18 @@ type PageResult struct { Meta Meta `json:"meta"` } +func (h *HttpResult) SearchByIncludes(column string, values []interface{}) *HttpResult { + // 再处理url查询 + query := facades.Orm().Query() + h.Query = func(q orm.Query) orm.Query { + //处理日期时间 + // 先处理过滤条件 + q = q.Where(column+" in ?", values).(orm.Query) + return q + }(query) + return h +} + // SearchByParams // ?name=xxx&pageSize=1¤tPage=1&sort=xxx&order=xxx func (h *HttpResult) SearchByParams(params map[string]string, conditionMap map[string]interface{}, excepts ...string) *HttpResult {