数据库中筛选:游戏上线年份
This commit is contained in:
		@@ -127,6 +127,7 @@ func NewSchema(config Config) (graphql.Schema, error) {
 | 
			
		||||
			"title":       &graphql.Field{Type: graphql.String, Description: "标题"},
 | 
			
		||||
			"orientation": &graphql.Field{Type: graphql.String, Description: "方向"},
 | 
			
		||||
			"device":      &graphql.Field{Type: graphql.String, Description: "设备"},
 | 
			
		||||
			"era":         &graphql.Field{Type: graphql.String, Description: "游戏上线年份"},
 | 
			
		||||
			"tags":        &graphql.Field{Type: graphql.String, Description: "标签"},
 | 
			
		||||
			"user":        &graphql.Field{Type: user, Description: "所属用户"},
 | 
			
		||||
			"create_time": &graphql.Field{Type: graphql.DateTime, Description: "创建时间"},
 | 
			
		||||
@@ -395,6 +396,7 @@ func NewSchema(config Config) (graphql.Schema, error) {
 | 
			
		||||
				},
 | 
			
		||||
			}),
 | 
			
		||||
			Args: graphql.FieldConfigArgument{
 | 
			
		||||
				"era":           &graphql.ArgumentConfig{Type: graphql.String, Description: "筛选图像中指定上线年份的"},
 | 
			
		||||
				"device":        &graphql.ArgumentConfig{Type: graphql.String, Description: "游戏设备"},
 | 
			
		||||
				"sort":          &graphql.ArgumentConfig{Type: graphql.String, Description: "排序方法"},
 | 
			
		||||
				"order":         &graphql.ArgumentConfig{Type: orderType, Description: "排序方向", DefaultValue: "ASC"},
 | 
			
		||||
@@ -575,6 +577,11 @@ func NewSchema(config Config) (graphql.Schema, error) {
 | 
			
		||||
					query = query.Joins("JOIN web_article ON web_images.article_id = web_article.id AND web_article.device = ?", p.Args["device"])
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				// 数据库中筛选:游戏上线年份
 | 
			
		||||
				if p.Args["era"] != nil {
 | 
			
		||||
					query = query.Joins("JOIN web_article ON web_images.article_id = web_article.id AND web_article.era = ?", p.Args["era"])
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				// 排序
 | 
			
		||||
 | 
			
		||||
				// 截取:取交集
 | 
			
		||||
 
 | 
			
		||||
@@ -114,6 +114,7 @@ type Article struct {
 | 
			
		||||
	Title       string    `json:"title"       db:"title"`
 | 
			
		||||
	Orientation string    `json:"orientation" db:"orientation"`
 | 
			
		||||
	Device      string    `json:"device"      db:"device"`
 | 
			
		||||
	Era         string    `json:"era"         db:"era"`
 | 
			
		||||
	Tags        string    `json:"tags"        db:"tags"`
 | 
			
		||||
	UserId      int       `json:"user_id"     db:"user_id"`
 | 
			
		||||
	User        User      `json:"user"        gorm:"foreignKey:UserId"`
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user