From 41ac67f13587ff76631167d6050c3f27f7b97c2a Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期二, 15 十月 2019 18:55:21 +0800
Subject: [PATCH] rm no use config
---
controllers/taglist.go | 51 ++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/controllers/taglist.go b/controllers/taglist.go
index 107532e..485bfb4 100644
--- a/controllers/taglist.go
+++ b/controllers/taglist.go
@@ -2,7 +2,14 @@
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"
"webserver/extend/util"
"github.com/gin-gonic/gin"
@@ -15,12 +22,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
- var dbpApi dbapi.DbPersonApi
- dts, err := dtApi.FindAllDbTablesByCurServer()
+ dts, err := dtApi.FindAllDbTablesByCurServer("-1")
if err == nil {
if dts !=nil {
sources := make([]map[string]interface{}, 0)
@@ -31,8 +37,7 @@
tokenRes["value"] = dt.Id
tokenRes["status"] = dt.IsDelete
if dt.IsDelete == 1 {
- personTotal,_ := dbpApi.GetPersonTotal(dt.Id)
- if personTotal == 0 {
+ if GetTotalFromDb(dt.Id) == false {
continue
}
}
@@ -44,3 +49,39 @@
}
util.ResponseFormat(c,code.ComError,"鏌ヨ搴曞簱鏍囩澶辫触")
}
+
+//鍒ゆ柇搴曞簱鏄惁鏈夋暟鎹�
+func GetTotalFromDb(id string) (flag bool) {
+ flag = false
+ 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.VideoPersons.IndexName + "/_search"
+ prama := "{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"baseInfo.tableId\":\"" + id + "\"}}]}},\"size\":0}"
+ buf, err := esutil.EsReq("POST", url, []byte(prama))
+ if err != nil {
+ fmt.Println("http request info is err!")
+ return
+ }
+ var info interface{}
+ json.Unmarshal(buf, &info)
+ out, ok := info.(map[string]interface{})
+ if !ok {
+ fmt.Println("http response interface can not change map[string]interface{}")
+ return
+ }
+ middle, ok := out["hits"].(map[string]interface{})
+ if !ok {
+ fmt.Println("first hits change error!")
+ return
+ }
+
+ total := int(middle["total"].(float64))
+ if total > 0 {
+ flag = true
+ }
+ return flag
+}
\ No newline at end of file
--
Gitblit v1.8.0