标签全文索引搜索
This commit is contained in:
@@ -502,16 +502,12 @@ func NewSchema(config Config) (graphql.Schema, error) {
|
||||
},
|
||||
}),
|
||||
Args: graphql.FieldConfigArgument{
|
||||
"style": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏风格筛选图像"},
|
||||
"device": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏平台筛选图像"},
|
||||
"orientation": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏版式筛选图像"},
|
||||
"era": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏年份筛选图像"},
|
||||
"category_id": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏类型筛选图像(支持多选)"},
|
||||
|
||||
"tags": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏标签筛选图像(支持多选)(主题)"},
|
||||
"paramImagesDescFunc": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏功能筛选图像(支持多选)"},
|
||||
"paramImagesDescMaterial": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏材质筛选图像(支持多选)"},
|
||||
|
||||
"style": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏风格筛选图像"},
|
||||
"device": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏平台筛选图像"},
|
||||
"orientation": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏版式筛选图像"},
|
||||
"era": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏年份筛选图像"},
|
||||
"category_id": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏类型筛选图像(支持多选)"},
|
||||
"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: "筛选图像中指定收藏夹的"},
|
||||
@@ -562,7 +558,7 @@ func NewSchema(config Config) (graphql.Schema, error) {
|
||||
var query = goqu.Dialect("mysql").From("web_images")
|
||||
|
||||
// 参数映射
|
||||
var argFormat = []string{"id", "width", "height", "content", "remark", "description", "tags", "rank", "comment_num", "praise_count", "collect_count", "article_id", "user_id"}
|
||||
var argFormat = []string{"id", "width", "height", "content", "remark", "description", "rank", "comment_num", "praise_count", "collect_count", "article_id", "user_id"}
|
||||
|
||||
// 筛选条件
|
||||
for _, format := range argFormat {
|
||||
@@ -666,6 +662,14 @@ func NewSchema(config Config) (graphql.Schema, error) {
|
||||
applyTimeCondition("update_time", p.Args["update_time"].(string))
|
||||
}
|
||||
|
||||
// 数据库中筛选:按游戏标签
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
// 数据库中筛选:喜欢的截图
|
||||
if p.Args["praise"] != nil {
|
||||
query = query.Join(goqu.T("web_praise"), goqu.On(
|
||||
@@ -733,7 +737,7 @@ func NewSchema(config Config) (graphql.Schema, error) {
|
||||
|
||||
// 按游戏类型筛选图像(逗号分割且去除空格)
|
||||
if p.Args["category_id"] != nil {
|
||||
category_ids := strings.Split(strings.ReplaceAll(p.Args["category_id"].(string), " ", ""), ", ")
|
||||
category_ids := strings.Split(strings.ReplaceAll(p.Args["category_id"].(string), " ", ""), ",")
|
||||
query = query.Join(goqu.T("web_article_category"), goqu.On(
|
||||
goqu.I("web_images.article_id").Eq(goqu.I("web_article_category.article_id")),
|
||||
goqu.I("web_article_category.category_id").In(category_ids),
|
||||
|
Reference in New Issue
Block a user