activity
This commit is contained in:
@@ -838,6 +838,7 @@ func NewSchema(config Config) (graphql.Schema, error) {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
Args: graphql.FieldConfigArgument{
|
Args: graphql.FieldConfigArgument{
|
||||||
|
"activity": &graphql.ArgumentConfig{Type: graphql.Boolean, Description: "按是否活动筛选图像"},
|
||||||
"style": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏风格筛选图像"},
|
"style": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏风格筛选图像"},
|
||||||
"device": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏平台筛选图像"},
|
"device": &graphql.ArgumentConfig{Type: graphql.String, Description: "按游戏平台筛选图像"},
|
||||||
"orientation": &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))
|
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 {
|
if p.Args["tags"] != nil {
|
||||||
tags := strings.Split(strings.ReplaceAll(p.Args["tags"].(string), " ", ""), ",")
|
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)
|
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) {
|
for _, item := range LoadItem(p.Info.FieldASTs[0].SelectionSet.Selections) {
|
||||||
find = find.Preload(item)
|
find = find.Preload(item)
|
||||||
}
|
}
|
||||||
|
@@ -74,6 +74,7 @@ type Image struct {
|
|||||||
Text TextList `json:"text" db:"text" gorm:"type:json"`
|
Text TextList `json:"text" db:"text" gorm:"type:json"`
|
||||||
User User `json:"user" gorm:"foreignKey:UserID"`
|
User User `json:"user" gorm:"foreignKey:UserID"`
|
||||||
Article Article `json:"article" gorm:"foreignKey:ArticleID"`
|
Article Article `json:"article" gorm:"foreignKey:ArticleID"`
|
||||||
|
Activity bool `json:"activity"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Image) TableName() string {
|
func (Image) TableName() string {
|
||||||
|
Reference in New Issue
Block a user