移除参数转换
This commit is contained in:
		
							
								
								
									
										25
									
								
								api/image.go
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								api/image.go
									
									
									
									
									
								
							@@ -14,7 +14,6 @@ import (
 | 
				
			|||||||
	"git.satori.love/gameui/webp/models"
 | 
						"git.satori.love/gameui/webp/models"
 | 
				
			||||||
	"github.com/doug-martin/goqu/v9"
 | 
						"github.com/doug-martin/goqu/v9"
 | 
				
			||||||
	"github.com/graphql-go/graphql"
 | 
						"github.com/graphql-go/graphql"
 | 
				
			||||||
	"github.com/mitchellh/mapstructure"
 | 
					 | 
				
			||||||
	"github.com/zhenghaoz/gorse/client"
 | 
						"github.com/zhenghaoz/gorse/client"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -231,20 +230,6 @@ var ImageItems = &graphql.Field{
 | 
				
			|||||||
		"order":         &graphql.ArgumentConfig{Type: orderType, Description: "排序方向", DefaultValue: "ASC"},
 | 
							"order":         &graphql.ArgumentConfig{Type: orderType, Description: "排序方向", DefaultValue: "ASC"},
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	Resolve: func(p graphql.ResolveParams) (interface{}, error) {
 | 
						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 total int
 | 
				
			||||||
		var images []Image
 | 
							var images []Image
 | 
				
			||||||
		var query = goqu.Dialect("mysql").From("web_images")
 | 
							var query = goqu.Dialect("mysql").From("web_images")
 | 
				
			||||||
@@ -267,7 +252,7 @@ var ImageItems = &graphql.Field{
 | 
				
			|||||||
					"bool": map[string]interface{}{
 | 
										"bool": map[string]interface{}{
 | 
				
			||||||
						"must": []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
 | 
							var limit int = 10
 | 
				
			||||||
		if args.First != 0 {
 | 
							if p.Args["first"] != nil {
 | 
				
			||||||
			limit = args.First
 | 
								limit = p.Args["first"].(int)
 | 
				
			||||||
		} else if args.Last != 0 {
 | 
							} else if p.Args["last"] != nil {
 | 
				
			||||||
			limit = args.Last
 | 
								limit = p.Args["last"].(int)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		sql = fmt.Sprintf(`
 | 
							sql = fmt.Sprintf(`
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user