From 2dd1fa03c93b400ff1e8e4f44e27387965e4daa7 Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期四, 19 九月 2019 17:23:59 +0800 Subject: [PATCH] get ip,port config from db,update realtime --- controllers/capture.go | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/controllers/capture.go b/controllers/capture.go index de43401..962a333 100644 --- a/controllers/capture.go +++ b/controllers/capture.go @@ -2,9 +2,12 @@ import ( "basic.com/dbapi.git" + "basic.com/valib/logger.git" "fmt" "github.com/gin-gonic/gin" + "strconv" "strings" + "webserver/cache" "webserver/extend/code" "webserver/extend/config" "webserver/extend/esutil" @@ -38,7 +41,13 @@ cameraIdStr = "{\"terms\":{\"cameraId\":[\"" + esCameraId + "\"]}}," } //璇锋眰澶� - url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + + localConf, err2 := cache.GetServerInfo() + if err2 !=nil || localConf.AlarmIp == "" { + logger.Debug("localConfig is wrong!!!") + util.ResponseFormat(c,code.ComError,"es config err") + return + } + url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) + "/" + index + "/_search" var setApi dbapi.SysSetApi @@ -52,7 +61,6 @@ "\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," + "\"size\":\"1000\"," + "\"_source\":[\"baseInfo\",\"alarmRules\",\"sex\",\"analyServerName\",\"sdkName\",\"ageDescription\",\"content\",\"id\",\"cameraAddr\",\"picMaxUrl\",\"picDate\",\"race\",\"videoUrl\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"isAlarm\",\"analyServerIp\",\"cameraId\"]}" - fmt.Println(prama) tokenRes := esutil.GetEsDataReq(url, prama, true) util.ResponseFormat(c, code.Success, tokenRes) } -- Gitblit v1.8.0