This commit is contained in:
2024-11-29 04:15:26 +08:00
parent 679f36f109
commit a12cad63e3
2 changed files with 8 additions and 1 deletions

View File

@@ -838,6 +838,7 @@ func NewSchema(config Config) (graphql.Schema, error) {
},
}),
Args: graphql.FieldConfigArgument{
"activity": &graphql.ArgumentConfig{Type: graphql.Boolean, Description: "按是否活动筛选图像"},
"style": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏风格筛选图像"},
"device": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏平台筛选图像"},
"orientation": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏版式筛选图像"},
@@ -1020,6 +1021,11 @@ func NewSchema(config Config) (graphql.Schema, error) {
applyTimeCondition("update_time", p.Args["update_time"].(string))
}
// 数据库中筛选:按是否活动
if activity, ok := p.Args["activity"].(bool); ok {
query = query.Where(goqu.Ex{"web_images.activity": map[bool]string{true: "1", false: "0"}[activity]})
}
// 数据库中筛选:按游戏标签
if p.Args["tags"] != nil {
tags := strings.Split(strings.ReplaceAll(p.Args["tags"].(string), " ", ""), ",")
@@ -1245,7 +1251,7 @@ func NewSchema(config Config) (graphql.Schema, error) {
ids = append(ids, item.ID)
}
var find = db.Where("web_images.id IN ?", ids)
var find = db.Where("web_images.id IN ?", ids).Select("*", "CASE WHEN activity = '1' THEN TRUE ELSE FALSE END AS is_active")
for _, item := range LoadItem(p.Info.FieldASTs[0].SelectionSet.Selections) {
find = find.Preload(item)
}