From ed8c09655a43d9ec44142fb968e5abfbb69416cb Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期三, 19 五月 2021 15:48:14 +0800 Subject: [PATCH] fix --- controllers/EsController.go | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/controllers/EsController.go b/controllers/EsController.go index dd3d370..b235344 100644 --- a/controllers/EsController.go +++ b/controllers/EsController.go @@ -3,6 +3,7 @@ import ( "andriodServer/esutil" "encoding/json" + "fmt" "github.com/gin-gonic/gin" "io" "strings" @@ -23,6 +24,9 @@ return } videoUrl := getVideoUrlById(id) + if videoUrl != "" { + videoUrl = "http://"+videoUrl + } c.JSON(200, map[string]interface{}{ "success": true, @@ -33,15 +37,15 @@ }) } +var EsUrl string func getVideoUrlById(_id string) string { - url := "" jsonDSL:= `{ "query": { "bool": { "filter": [ { "term": { - "_id": "5q5VxXIBpPOUuw7XfG_L" + "_id": `+_id+` } } ] @@ -51,8 +55,9 @@ "videoUrl" ] }` - body, err := esutil.EsReq("POST", url, []byte(jsonDSL)) + body, err := esutil.EsReq("POST", EsUrl+"ai_ocean/_search", []byte(jsonDSL)) if err != nil { + fmt.Println("err:", err) return "" } jsonStr := string(body) -- Gitblit v1.8.0