liuxiaolong
2020-06-05 7c811247ecf143e08c576986a884bedadc57dd66
controllers/taglist.go
@@ -2,8 +2,11 @@
import (
   "basic.com/dbapi.git"
   "basic.com/valib/logger.git"
   "encoding/json"
   "fmt"
   "strconv"
   "webserver/cache"
   "webserver/extend/code"
   "webserver/extend/config"
   "webserver/extend/esutil"
@@ -12,6 +15,7 @@
   "github.com/gin-gonic/gin"
)
// @Security ApiKeyAuth
// @Summary 标签列表
// @Description 返回底库标签
// @Accept  json
@@ -19,11 +23,11 @@
// @Tags es
// @Success 200 {string} json "{"code":200, msg:"", success:true}"
// @Failure 500 {string} json "{"code":500, msg:"", success:false}"
// @Router /data/api-v/es/taskList [POST]
// @Router /data/api-v/es/tagList [POST]
func (sc *EsSearchController) PostEsTagList(c *gin.Context) {
   var dtApi dbapi.DbTableApi
   dts, err := dtApi.FindAllDbTablesByCurServer()
   dts, err := dtApi.FindAllDbTablesByCurServer("-1")
   if err == nil {
      if dts !=nil {
         sources := make([]map[string]interface{}, 0)
@@ -33,6 +37,8 @@
            tokenRes["title"] = dt.TableName
            tokenRes["value"] = dt.Id
            tokenRes["status"] = dt.IsDelete
            tokenRes["bwType"] = dt.BwType //0:白名单,1:黑名单
            tokenRes["analyServerId"] = dt.AnalyServerId //为空是同步库,不为空是本地库
            if dt.IsDelete == 1 {
               if GetTotalFromDb(dt.Id) == false {
                  continue
@@ -50,8 +56,13 @@
//判断底库是否有数据
func GetTotalFromDb(id string) (flag bool) {
   flag = false
   url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport +
      "/" + config.EsInfo.EsIndex.VideoPersons.IndexName + "/_search"
   localConf, err2 := cache.GetServerInfo()
   if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
      logger.Debug("localConfig is wrong!!!")
      return false
   }
   url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) +
      "/" + config.EsInfo.EsIndex.AiOcean.IndexName + "/_search"
   prama := "{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"baseInfo.tableId\":\"" + id + "\"}}]}},\"size\":0}"
   buf, err := esutil.EsReq("POST", url, []byte(prama))
   if err != nil {