collect_id
This commit is contained in:
		
							
								
								
									
										28
									
								
								api/game.go
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								api/game.go
									
									
									
									
									
								
							@@ -41,8 +41,32 @@ var gameType = graphql.NewObject(graphql.ObjectConfig{
 | 
				
			|||||||
		"update_time":   &graphql.Field{Type: graphql.DateTime, Description: "游戏更新时间"},
 | 
							"update_time":   &graphql.Field{Type: graphql.DateTime, Description: "游戏更新时间"},
 | 
				
			||||||
		"praise_count":  &graphql.Field{Type: graphql.Int, Description: "点赞数"},
 | 
							"praise_count":  &graphql.Field{Type: graphql.Int, Description: "点赞数"},
 | 
				
			||||||
		"collect_count": &graphql.Field{Type: graphql.Int, Description: "收藏数"},
 | 
							"collect_count": &graphql.Field{Type: graphql.Int, Description: "收藏数"},
 | 
				
			||||||
		"praise":        &graphql.Field{Type: graphql.Boolean, Description: "当前用户是否点赞"},
 | 
							"praise": &graphql.Field{Type: graphql.Boolean, Description: "当前用户是否点赞", Resolve: func(p graphql.ResolveParams) (interface{}, error) {
 | 
				
			||||||
		"collect":       &graphql.Field{Type: graphql.Boolean, Description: "当前用户是否收藏"},
 | 
								var user_id = p.Context.Value("user_id").(int)
 | 
				
			||||||
 | 
								if user_id != 0 {
 | 
				
			||||||
 | 
									var praise int64
 | 
				
			||||||
 | 
									if err := db.Table("web_praise").Where("user_id = ?", user_id).Where("praise_id = ?", p.Source.(Game).ID).Where("type = ?", 0).Count(&praise); err != nil {
 | 
				
			||||||
 | 
										return false, nil
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									if praise > 0 {
 | 
				
			||||||
 | 
										return true, nil
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								return false, nil
 | 
				
			||||||
 | 
							}},
 | 
				
			||||||
 | 
							"collect": &graphql.Field{Type: graphql.Boolean, Description: "当前用户是否收藏", Resolve: func(p graphql.ResolveParams) (interface{}, error) {
 | 
				
			||||||
 | 
								var user_id = p.Context.Value("user_id").(int)
 | 
				
			||||||
 | 
								if user_id != 0 {
 | 
				
			||||||
 | 
									var collect int64
 | 
				
			||||||
 | 
									if err := db.Table("web_collect").Where("user_id = ?", user_id).Where("collect_id = ?", p.Source.(Game).ID).Where("type = ?", 0).Count(&collect); err != nil {
 | 
				
			||||||
 | 
										return false, nil
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									if collect > 0 {
 | 
				
			||||||
 | 
										return true, nil
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								return false, nil
 | 
				
			||||||
 | 
							}},
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -100,7 +100,7 @@ var imageType = graphql.NewObject(graphql.ObjectConfig{
 | 
				
			|||||||
			var user_id = p.Context.Value("user_id").(int)
 | 
								var user_id = p.Context.Value("user_id").(int)
 | 
				
			||||||
			if user_id != 0 {
 | 
								if user_id != 0 {
 | 
				
			||||||
				var collect int64
 | 
									var collect int64
 | 
				
			||||||
				if err := db.Table("web_collect").Where("user_id = ?", user_id).Where("image_id = ?", p.Source.(Image).ID).Count(&collect); err != nil {
 | 
									if err := db.Table("web_collect").Where("user_id = ?", user_id).Where("collect_id = ?", p.Source.(Image).ID).Where("type = ?", 1).Count(&collect); err != nil {
 | 
				
			||||||
					return false, nil
 | 
										return false, nil
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				if collect > 0 {
 | 
									if collect > 0 {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user