From 7c811247ecf143e08c576986a884bedadc57dd66 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期五, 05 六月 2020 18:29:41 +0800 Subject: [PATCH] add refresh token to resp --- controllers/capture.go | 35 +++++++++++++++++++++++------------ 1 files changed, 23 insertions(+), 12 deletions(-) diff --git a/controllers/capture.go b/controllers/capture.go index 962a333..fd70180 100644 --- a/controllers/capture.go +++ b/controllers/capture.go @@ -1,7 +1,6 @@ package controllers import ( - "basic.com/dbapi.git" "basic.com/valib/logger.git" "fmt" "github.com/gin-gonic/gin" @@ -20,6 +19,7 @@ TreeNodes []string `json:"treeNodes"` } +// @Security ApiKeyAuth // @Summary 瀹炴椂鎶撴媿 // @Description 瀹炴椂鎶撴媿鏁版嵁 // @Accept json @@ -33,34 +33,45 @@ func (rc *RealTimeController) PostCapture(c *gin.Context) { var searchBody RealTimeArg c.BindJSON(&searchBody) - index := config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName + index := config.EsInfo.EsIndex.AiOcean.IndexName cameraIdStr := "" + linkTagInfoCameraIdStr := "" cameraId := searchBody.TreeNodes if cameraId != nil && len(cameraId) > 0 { esCameraId := strings.Replace(strings.Trim(fmt.Sprint(cameraId), "[]"), " ", "\",\"", -1) cameraIdStr = "{\"terms\":{\"cameraId\":[\"" + esCameraId + "\"]}}," + linkTagInfoCameraIdStr = "{\"terms\":{\"linkTagInfo.cameraId\":[\"" + esCameraId + "\"]}}," } //璇锋眰澶� localConf, err2 := cache.GetServerInfo() - if err2 !=nil || localConf.AlarmIp == "" { + if err2 != nil || localConf.AlarmIp == "" || localConf.ServerId == "" { logger.Debug("localConfig is wrong!!!") - util.ResponseFormat(c,code.ComError,"es config err") + util.ResponseFormat(c, code.ComError, "es config err") return } url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) + "/" + index + "/_search" - var setApi dbapi.SysSetApi - _, sysconf := setApi.GetServerInfo() - analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + sysconf.ServerId + "\"}}," - - prama := "{\"query\":{\"bool\":{\"filter\":[" + + analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + localConf.ServerId + "\"}}," + linkTagInfoAnalyServerFilterStr := "{\"term\":{\"linkTagInfo.analyServerId\":\"" + localConf.ServerId + "\"}}," + prama := "{\"query\":{\"bool\":{\"should\":[" + + "{\"bool\":{\"filter\":[" + + "{\"term\":{\"isAlarm\":true}}," + cameraIdStr + analyServerFilterStr + - "{\"range\":{\"picDate\":{\"gte\":\"now+8h-15s\",\"lt\":\"now+8h\"}}}]}}," + + "{\"range\":{\"picDate\":{\"gte\":\"now+8h-15s\",\"lt\":\"now+8h\"}}}" + + "]}}," + + "{\"bool\":{\"filter\":[" + + "{\"term\":{\"isAlarm\":true}}," + + linkTagInfoCameraIdStr + + linkTagInfoAnalyServerFilterStr + + "{\"range\":{\"linkTagInfo.picDate\":{\"gte\":\"now+8h-15s\",\"lt\":\"now+8h\"}}}" + + "]}}" + + "],\"minimum_should_match\":1}}," + "\"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\"]}" + "\"_source\":{\"includes\":[],\"excludes\":[\"*.feature\"]}}" tokenRes := esutil.GetEsDataReq(url, prama, true) - util.ResponseFormat(c, code.Success, tokenRes) + tmpAllDate := esutil.ResponseData(tokenRes) + util.ResponseFormat(c, code.Success, tmpAllDate) } -- Gitblit v1.8.0