From 9519ca7e65a292ea60aa988027edb25770a976ca Mon Sep 17 00:00:00 2001 From: satori Date: Mon, 2 Dec 2024 07:11:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=8F=82=E6=95=B0=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/image.go | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/api/image.go b/api/image.go index e8a1816..32745d5 100644 --- a/api/image.go +++ b/api/image.go @@ -14,7 +14,6 @@ import ( "git.satori.love/gameui/webp/models" "github.com/doug-martin/goqu/v9" "github.com/graphql-go/graphql" - "github.com/mitchellh/mapstructure" "github.com/zhenghaoz/gorse/client" ) @@ -231,20 +230,6 @@ var ImageItems = &graphql.Field{ "order": &graphql.ArgumentConfig{Type: orderType, Description: "排序方向", DefaultValue: "ASC"}, }, Resolve: func(p graphql.ResolveParams) (interface{}, error) { - // 定义参数结构体 - var args struct { - First int - Last int - After int - Before int - Text string - Interest int - Similar int - Sort string - Order string - } - mapstructure.Decode(p.Args, &args) - var total int var images []Image var query = goqu.Dialect("mysql").From("web_images") @@ -267,7 +252,7 @@ var ImageItems = &graphql.Field{ "bool": map[string]interface{}{ "must": []map[string]interface{}{ { - "match_phrase": map[string]string{"text": args.Text}, + "match_phrase": map[string]string{"text": p.Args["text"].(string)}, }, }, }, @@ -578,10 +563,10 @@ var ImageItems = &graphql.Field{ } var limit int = 10 - if args.First != 0 { - limit = args.First - } else if args.Last != 0 { - limit = args.Last + if p.Args["first"] != nil { + limit = p.Args["first"].(int) + } else if p.Args["last"] != nil { + limit = p.Args["last"].(int) } sql = fmt.Sprintf(`