使用 LIKE 查询游戏分类
This commit is contained in:
		
							
								
								
									
										13
									
								
								api/image.go
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								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"]))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user