From 200a6b284214ebd7762ac9557117b52c28c92616 Mon Sep 17 00:00:00 2001 From: satori Date: Sun, 17 Nov 2024 01:02:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/graphql.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/api/graphql.go b/api/graphql.go index 8906f32..5addb4e 100644 --- a/api/graphql.go +++ b/api/graphql.go @@ -508,6 +508,8 @@ func NewSchema(config Config) (graphql.Schema, error) { "era": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏年份筛选图像"}, "category_id": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏类型筛选图像(支持多选)"}, "tags": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏标签筛选图像(支持多选)"}, + "images_desc": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏归类筛选图像(支持多选)"}, + "article_tags": &graphql.ArgumentConfig{Type: graphql.String, Description: "按文章标签筛选图像(支持多选)"}, "color": &graphql.ArgumentConfig{Type: graphql.String, Description: "按主色调筛选图像, 使用十六进制颜色代码(#FF1414)"}, "explorer_id": &graphql.ArgumentConfig{Type: graphql.Int, Description: "筛选图像中指定收藏夹的"}, "collect_id": &graphql.ArgumentConfig{Type: graphql.Int, Description: "筛选图像中指定收藏夹的"}, @@ -666,7 +668,26 @@ func NewSchema(config Config) (graphql.Schema, error) { if p.Args["tags"] != nil { tags := strings.Split(strings.ReplaceAll(p.Args["tags"].(string), " ", ""), ",") for _, tag := range tags { - query = query.Where(goqu.L("MATCH(images_desc) AGAINST (? IN NATURAL LANGUAGE MODE)", tag)) + query = query.Where(goqu.L("MATCH(web_images.images_tags) AGAINST (? IN NATURAL LANGUAGE MODE)", tag)) + } + } + + // 数据库中筛选:按游戏分类 + if p.Args["images_desc"] != nil { + tags := strings.Split(strings.ReplaceAll(p.Args["images_desc"].(string), " ", ""), ",") + for _, tag := range tags { + query = query.Where(goqu.L("MATCH(web_images.images_desc) AGAINST (? IN NATURAL LANGUAGE MODE)", tag)) + } + } + + // 数据库中筛选:按文章标签 + if p.Args["article_tags"] != nil { + tags := strings.Split(strings.ReplaceAll(p.Args["article_tags"].(string), " ", ""), ", ") + for _, tag := range tags { + query = query.Join(goqu.T("web_article"), goqu.On( + goqu.I("web_images.article_id").Eq(goqu.I("web_article.id")), + goqu.L("MATCH(web_article.tags) AGAINST (? IN NATURAL LANGUAGE MODE)", tag), + )) } }