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 {