输出text
This commit is contained in:
@@ -52,8 +52,17 @@ func NewSchema(config Config) (graphql.Schema, error) {
|
||||
},
|
||||
})
|
||||
|
||||
// 图像中的文字提取
|
||||
// text := graphql.NewObject(graphql.ObjectConfig{})
|
||||
// 图像中的文字提取 [{"text": "角色选择", "confidence": 0.8484202027320862, "coordinate": [[666.0, 66.0], [908.0, 81.0], [903.0, 174.0], [661.0, 160.0]]}
|
||||
text := graphql.NewObject(graphql.ObjectConfig{
|
||||
Name: "Text",
|
||||
Fields: graphql.Fields{
|
||||
"text": &graphql.Field{Type: graphql.String},
|
||||
"confidence": &graphql.Field{Type: graphql.Float},
|
||||
"coordinate": &graphql.Field{Type: &graphql.List{
|
||||
OfType: graphql.NewList(graphql.Float),
|
||||
}},
|
||||
},
|
||||
})
|
||||
|
||||
// 图像的可选字段
|
||||
image := graphql.NewObject(graphql.ObjectConfig{
|
||||
@@ -67,7 +76,7 @@ func NewSchema(config Config) (graphql.Schema, error) {
|
||||
"description": &graphql.Field{Type: graphql.String},
|
||||
"tags": &graphql.Field{Type: graphql.String},
|
||||
"rank": &graphql.Field{Type: graphql.String},
|
||||
"text": &graphql.Field{Type: graphql.String},
|
||||
"text": &graphql.Field{Type: graphql.NewList(text)},
|
||||
"comment_num": &graphql.Field{Type: graphql.Int},
|
||||
"article_category_top_id": &graphql.Field{Type: graphql.Int},
|
||||
"praise_count": &graphql.Field{Type: graphql.Int},
|
||||
@@ -302,6 +311,10 @@ func NewSchema(config Config) (graphql.Schema, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 打印带缩进格式化的JSON
|
||||
// str, _ := json.MarshalIndent(images, "", " ")
|
||||
// fmt.Println("获取图像列表成功", string(str))
|
||||
|
||||
// 获取用户信息(如果图像列表不为空且请求字段中包含user)
|
||||
if len(images) > 0 && strings.Contains(fields_str, "user_id") {
|
||||
// 取到所有的用户ID, 去除重复
|
||||
|
Reference in New Issue
Block a user