From 76b0c68ed3abe1c8ba242ea9cf96a30f30a85b03 Mon Sep 17 00:00:00 2001 From: Last <253458536@qq.com> Date: Wed, 26 Mar 2025 10:48:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20LIKE=20=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/image.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/api/image.go b/api/image.go index 73498de..19d6a56 100644 --- a/api/image.go +++ b/api/image.go @@ -404,7 +404,8 @@ var ImageItems = &graphql.Field{ 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)) + //query = query.Where(goqu.L("MATCH(web_images.images_desc) AGAINST (? IN NATURAL LANGUAGE MODE)", tag)) + query = query.Where(goqu.L(fmt.Sprintf("web_images.images_desc LIKE '%%%s%%'", tag))) } } @@ -459,6 +460,16 @@ var ImageItems = &graphql.Field{ conditions = append(conditions, goqu.I("web_article.orientation").Eq(p.Args["orientation"])) } + //// 数据库中筛选:按游戏分类 + //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)) + // //query = query.Where(goqu.L(fmt.Sprintf("web_images.images_desc LIKE '%%%s%%'", tag))) + // conditions = append(conditions, goqu.L(fmt.Sprintf("web_article.images_desc LIKE '%%%s%%'", tag))) + // } + //} + // 按游戏年份筛选图像 if p.Args["era"] != nil { conditions = append(conditions, goqu.I("web_article.era").Eq(p.Args["era"]))