From 342d25811dbfa2809322f95f9647fe2fa19a9384 Mon Sep 17 00:00:00 2001 From: satori Date: Sat, 31 Aug 2024 15:28:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/graphql.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/graphql.go b/api/graphql.go index 27c8314..7c697bc 100644 --- a/api/graphql.go +++ b/api/graphql.go @@ -193,7 +193,7 @@ func NewSchema(config Config) (graphql.Schema, error) { }, }), Args: graphql.FieldConfigArgument{ - "preference": &graphql.ArgumentConfig{Type: graphql.Int, Description: "按照指定用户ID的偏好推荐图像"}, + "preference": &graphql.ArgumentConfig{Type: graphql.String, Description: "使用浏览记录获取的偏好推荐图像"}, "similar": &graphql.ArgumentConfig{Type: graphql.Int, Description: "获取与指定ID图像相似的图像"}, "id": &graphql.ArgumentConfig{Type: graphql.Int, Description: "获取指定ID的图像"}, "width": &graphql.ArgumentConfig{Type: graphql.Int, Description: "筛选图像中指定宽度的"}, @@ -224,8 +224,8 @@ func NewSchema(config Config) (graphql.Schema, error) { After string Before string Text string + Preference string Similar int - Preference int } mapstructure.Decode(p.Args, &args) @@ -259,7 +259,10 @@ func NewSchema(config Config) (graphql.Schema, error) { var id_list []string // 特殊处理 preference 参数 - if args.Preference != 0 { + if args.Preference != "" { + // 去除空格并拆分以逗号分割的ID + id_list = strings.Split(strings.ReplaceAll(args.Preference, " ", ""), ",") + // 使用这一组 id 推荐 fmt.Println("preference:", args.Preference) }