API分页
This commit is contained in:
		
							
								
								
									
										61
									
								
								bin/main.go
									
									
									
									
									
								
							
							
						
						
									
										61
									
								
								bin/main.go
									
									
									
									
									
								
							@@ -19,6 +19,7 @@ import (
 | 
			
		||||
	"git.satori.love/gameui/webp/api"
 | 
			
		||||
	"git.satori.love/gameui/webp/models"
 | 
			
		||||
	_ "github.com/go-sql-driver/mysql"
 | 
			
		||||
	"github.com/graphql-go/graphql"
 | 
			
		||||
	"github.com/graphql-go/handler"
 | 
			
		||||
	"github.com/milvus-io/milvus-sdk-go/v2/entity"
 | 
			
		||||
	"github.com/spf13/viper"
 | 
			
		||||
@@ -229,6 +230,7 @@ func main() {
 | 
			
		||||
 | 
			
		||||
	models.InitConfig(config)
 | 
			
		||||
	models.ZincInit()
 | 
			
		||||
	api.InitDefault(config)
 | 
			
		||||
 | 
			
		||||
	mysqlConnection.Init()
 | 
			
		||||
	milvusConnection.Init()
 | 
			
		||||
@@ -238,33 +240,35 @@ func main() {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// graphql Schema
 | 
			
		||||
	schema, err := api.NewSchema(api.Config{
 | 
			
		||||
		Mysql: api.MysqlConfig{
 | 
			
		||||
			Host:     config.GetString("mysql.host"),
 | 
			
		||||
			Port:     config.GetInt("mysql.port"),
 | 
			
		||||
			Database: config.GetString("mysql.database"),
 | 
			
		||||
			UserName: config.GetString("mysql.user"),
 | 
			
		||||
			Password: config.GetString("mysql.password"),
 | 
			
		||||
		},
 | 
			
		||||
		Oss: api.Oss{
 | 
			
		||||
			Local: config.GetBool("oss.local"),
 | 
			
		||||
		},
 | 
			
		||||
		Gorse: api.GorseConfig{
 | 
			
		||||
			Host: config.GetString("gorse.host"),
 | 
			
		||||
			Port: config.GetInt("gorse.port"),
 | 
			
		||||
			Open: config.GetBool("gorse.open"),
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatalf("failed to create new schema, error: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		defer LogComponent(time.Now().UnixNano(), r) // 最后打印日志
 | 
			
		||||
		w.Write([]byte("Hello World!"))
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	if config.GetBool("oss.local") {
 | 
			
		||||
		fmt.Println("开启图像色调计算")
 | 
			
		||||
		go api.CheckColorNullRows(0)
 | 
			
		||||
	}
 | 
			
		||||
	if config.GetBool("gorse.open") {
 | 
			
		||||
		fmt.Println("开启用户偏好收集")
 | 
			
		||||
		api.GorseInit(config.GetString("gorse.host"), config.GetInt("gorse.port"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	schema, err := graphql.NewSchema(graphql.SchemaConfig{Query: graphql.NewObject(graphql.ObjectConfig{Name: "RootQuery", Fields: graphql.Fields{
 | 
			
		||||
		"users":    api.UserItems,
 | 
			
		||||
		"collects": api.CollectItems,
 | 
			
		||||
		"games":    api.GameItems,
 | 
			
		||||
		"works":    api.WorkItems,
 | 
			
		||||
		"articles": api.ArticleItems,
 | 
			
		||||
		"article":  api.ArticleItem,
 | 
			
		||||
		"images":   api.ImageItems,
 | 
			
		||||
		"image":    api.ImageItem,
 | 
			
		||||
	}})})
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatalf("failed to create new schema, error: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	http.Handle("/api", LogRequest(handler.New(&handler.Config{
 | 
			
		||||
		Schema:     &schema,
 | 
			
		||||
		Playground: true,
 | 
			
		||||
@@ -275,19 +279,6 @@ func main() {
 | 
			
		||||
	http.HandleFunc("/api/images", func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		defer LogComponent(time.Now().UnixNano(), r) // 最后打印日志
 | 
			
		||||
 | 
			
		||||
		// 私域: (自己的图片, 自己的文章, 自己的精选集, 点赞收藏精选集)
 | 
			
		||||
		// 条件查询(模糊搜索, 时间区间, 作者, 标签, 分类, 精选集, 状态, 置顶, 模糊权重)(权重规则:权重指数)
 | 
			
		||||
		// 条件筛选(交集, 并集, 差集, 子集)
 | 
			
		||||
		// 文字搜索支持翻页
 | 
			
		||||
		// 文字搜索支持与按颜色筛选混合
 | 
			
		||||
 | 
			
		||||
		// TODO 查找含有指定文字的图像
 | 
			
		||||
		// TODO 查找含有指定标签的图像
 | 
			
		||||
		// TODO 查找含有指定特征的图像
 | 
			
		||||
		// TODO 查找含有指定颜色的图像(倒排索引)
 | 
			
		||||
		// TODO 查找含有指定分类的图像
 | 
			
		||||
		// 1,000,000
 | 
			
		||||
 | 
			
		||||
		// 获取查询条件(忽略空值)
 | 
			
		||||
		QueryConditions := func(key string) (list []string) {
 | 
			
		||||
			for _, item := range strings.Split(r.URL.Query().Get(key), ",") {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user