分页参数
This commit is contained in:
		@@ -2,6 +2,7 @@ package api
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
	"log"
 | 
			
		||||
	"net/http"
 | 
			
		||||
@@ -33,13 +34,14 @@ var SearchItems = &graphql.Field{
 | 
			
		||||
		},
 | 
			
		||||
	}),
 | 
			
		||||
	Args: graphql.FieldConfigArgument{
 | 
			
		||||
		"name": &graphql.ArgumentConfig{Type: graphql.String, Description: "按指定字符筛选"},
 | 
			
		||||
		"name":  &graphql.ArgumentConfig{Type: graphql.String, Description: "按指定字符筛选"},
 | 
			
		||||
		"first": &graphql.ArgumentConfig{Type: graphql.Int, Description: "翻页参数(傳回清單中的前n個元素)", DefaultValue: 10},
 | 
			
		||||
	},
 | 
			
		||||
	Resolve: func(p graphql.ResolveParams) (interface{}, error) {
 | 
			
		||||
		var searchs []Search
 | 
			
		||||
 | 
			
		||||
		// 发送 GET 请求
 | 
			
		||||
		resp, err := http.Get("http://localhost:6005/api/get_search/hot")
 | 
			
		||||
		resp, err := http.Get(fmt.Sprintf("http://localhost:6005/api/get_search/hot?page=%d", p.Args["first"]))
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatalf("Failed to fetch data: %v", err)
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user