From 28bf0226d1df3817bec0947d6d1ad11356dcd290 Mon Sep 17 00:00:00 2001
From: sunty <suntianyu0923@163.com>
Date: 星期三, 31 七月 2019 14:30:12 +0800
Subject: [PATCH] add endTime omitenpty add taglist serverId filter add baseInfo{persoNname phoneNum sex} to queryBody

---
 controllers/taglist.go |   61 +++++++++++++++---------------
 1 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/controllers/taglist.go b/controllers/taglist.go
index 6e24e2f..d4a2a08 100644
--- a/controllers/taglist.go
+++ b/controllers/taglist.go
@@ -1,6 +1,7 @@
 package controllers
 
 import (
+	"basic.com/dbapi.git"
 	"encoding/json"
 	"fmt"
 
@@ -25,12 +26,11 @@
 
 	url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport +
 		"/" + config.EsInfo.EsIndex.DbTables.IndexName + "/_search"
-
-	prama := "{\"query\":{\"bool\":{\"filter\":[]}},\"size\":10000,\"_source\":[\"tableName\",\"id\",\"isDelete\"]}"
-
+	var setApi dbapi.SysSetApi
+	_, sysconf := setApi.GetServerInfo()
+	prama := "{\"query\":{\"bool\":{\"filter\":[{\"terms\":{\"analyServerId\":[\"\",\"" + sysconf.ServerId + "\"]}}]}},\"size\":1000}"
 	tokenRes := esutil.GetEsDataReq(url, prama, true)
 	sources := make([]map[string]interface{}, 0)
-	fmt.Println(tokenRes["datalist"].([]interface{}))
 	for _, value := range tokenRes["datalist"].([]interface{}) {
 		tokenRes := make(map[string]interface{})
 		key := value.(map[string]interface{})["id"].(string)
@@ -39,43 +39,42 @@
 		tokenRes["value"] = value.(map[string]interface{})["id"].(string)
 		status := int(value.(map[string]interface{})["isDelete"].(float64))
 		tokenRes["status"] = status
-		if status == 1  {
-			if GetTotalFromDb(key) == false{
+		if status == 1 {
+			if GetTotalFromDb(key) == false {
 				continue
 			}
-
 		}
 		sources = append(sources, tokenRes)
 	}
 	util.ResponseFormat(c, code.Success, sources)
 }
+
 //鍒ゆ柇搴曞簱鏄惁鏈夋暟鎹�
 func GetTotalFromDb(id string) (flag bool) {
 	flag = false
 	url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport +
 		"/" + config.EsInfo.EsIndex.DbTables.IndexName + "/_search"
-	prama := "{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"baseInfo.tableId\":\""+id+"\"}}]}},\"size\":0}"
+	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))
-			fmt.Println(total)
-			if total > 0 {
-				flag=true
-			}
-            return flag
-}
\ No newline at end of file
+	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
+}

--
Gitblit v1.8.0