From f4e8f206a6760bdc31734dfcb1c65916b5b76311 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期四, 22 八月 2019 12:05:58 +0800
Subject: [PATCH] add cluster

---
 controllers/taglist.go |   53 +++++++++++++++++++++++++++++------------------------
 1 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/controllers/taglist.go b/controllers/taglist.go
index 7e57a03..107532e 100644
--- a/controllers/taglist.go
+++ b/controllers/taglist.go
@@ -1,41 +1,46 @@
 package controllers
 
 import (
-	"fmt"
+	"basic.com/dbapi.git"
+	"webserver/extend/code"
+	"webserver/extend/util"
 
 	"github.com/gin-gonic/gin"
-	"webserver/extend/code"
-	"webserver/extend/config"
-	"webserver/extend/esutil"
-	"webserver/extend/util"
 )
 
-//鏍囩鍒楄〃
-//浠诲姟鍒楄〃
 // @Summary 鏍囩鍒楄〃
 // @Description 杩斿洖搴曞簱鏍囩
 // @Accept  json
 // @Produce json
 // @Tags es
-// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
-// @Failure 500 {string} json "{"code":500,  msg:"杩斿洖閿欒淇℃伅", success:false}"
+// @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]
 func (sc *EsSearchController) PostEsTagList(c *gin.Context) {
 
-	url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport +
-		"/" + config.EsInfo.EsIndex.DbTables.IndexName + "/_search"
-
-	prama := "{\"query\":{\"match_all\":{}},\"_source\":[\"tableName\",\"uuid\"]}"
-
-	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{})
-		tokenRes["key"] = value.(map[string]interface{})["id"].(string)
-		tokenRes["title"] = value.(map[string]interface{})["tableName"].(string)
-		tokenRes["value"] = value.(map[string]interface{})["id"].(string)
-		sources = append(sources, tokenRes)
+	var dtApi dbapi.DbTableApi
+	var dbpApi dbapi.DbPersonApi
+	dts, err := dtApi.FindAllDbTablesByCurServer()
+	if err == nil {
+		if dts !=nil {
+			sources := make([]map[string]interface{}, 0)
+			for _, dt := range dts {
+				tokenRes := make(map[string]interface{})
+				tokenRes["key"] = dt.Id
+				tokenRes["title"] = dt.TableName
+				tokenRes["value"] = dt.Id
+				tokenRes["status"] = dt.IsDelete
+				if dt.IsDelete == 1 {
+					personTotal,_ := dbpApi.GetPersonTotal(dt.Id)
+					if personTotal == 0 {
+						continue
+					}
+				}
+				sources = append(sources, tokenRes)
+			}
+			util.ResponseFormat(c, code.Success, sources)
+			return
+		}
 	}
-	util.ResponseFormat(c, code.Success, sources)
+	util.ResponseFormat(c,code.ComError,"鏌ヨ搴曞簱鏍囩澶辫触")
 }

--
Gitblit v1.8.0