From f86d25d5143847692779dd4e81b7e47d9b25376e Mon Sep 17 00:00:00 2001 From: sunty <suntianyu0923@163.com> Date: 星期二, 30 七月 2019 11:16:15 +0800 Subject: [PATCH] fix delete dbtable add GetTotalFromDb and EsReq --- controllers/dbtablesCon.go | 24 ++++++++++++++---------- 1 files changed, 14 insertions(+), 10 deletions(-) diff --git a/controllers/dbtablesCon.go b/controllers/dbtablesCon.go index e2a12e1..a0dd2eb 100644 --- a/controllers/dbtablesCon.go +++ b/controllers/dbtablesCon.go @@ -1,6 +1,7 @@ package controllers import ( + "basic.com/dbapi.git" "encoding/json" "github.com/gin-gonic/gin" "github.com/satori/go.uuid" @@ -33,9 +34,12 @@ _, sysconf := setApi.GetServerInfo() analyServerFilterStr := "" if isSync == "1" { - analyServerFilterStr = "{\"term\":{\"analyServerId\":\"" + sysconf.ServerId + "\"}}" // 鍚屾搴� + analyServerFilterStr = "{\"term\":{\"analyServerId\":\"\"}}" // / 鍚屾搴� } else if isSync == "2" { - analyServerFilterStr = "{\"term\":{\"analyServerId\":\"\"}}" // / 鏈湴搴� + analyServerFilterStr = "{\"term\":{\"analyServerId\":\"" + sysconf.ServerId + "\"}}" // 鏈湴搴� + } + if analyServerFilterStr !="" { + analyServerFilterStr = ","+ analyServerFilterStr } params := "{\"query\":{\"bool\":{\"must\":[" + "{\"term\":{\"isDelete\":\"0\"}}" + analyServerFilterStr + "]}}," + @@ -46,9 +50,9 @@ //c.JSON(200, data) util.ResponseFormat(c, code.Success, data) } - +锟� // 渚濇嵁搴曞簱id 鏌ヨ鏁版嵁 -func QueryDbTableInfo(tableId string) map[string]interface{} { +func QueryDbTableInfo(tableId string) map[string]interface{} {锟� url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/" + tableId logger.Debug("璇锋眰url:%s;", url) @@ -109,13 +113,13 @@ c.BindJSON(&dbtable) tableId := uuid.NewV4().String() dbtable.Id = tableId - if dbtable.analyServerId == "sync" { + if dbtable.AnalyServerId == "sync" { + dbtable.AnalyServerId = "" + } + if dbtable.AnalyServerId == "local" { var setApi dbapi.SysSetApi _, sysconf := setApi.GetServerInfo() - dbtable.analyServerId = sysconf.ServerId - } - if dbtable.analyServerId == "local" { - dbtable.analyServerId = "" + dbtable.AnalyServerId = sysconf.ServerId } url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/" + config.EsInfo.EsIndex.DbTables.IndexType + "/" + tableId + "?refresh=wait_for" @@ -152,7 +156,7 @@ uuid := c.Params.ByName("id") url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/" + config.EsInfo.EsIndex.DbTables.IndexType + "/" + uuid + "/_update?refresh=wait_for" - params := "{\"doc\":{\"isDelete\":\"1\"}}" + params := "{\"doc\":{\"isDelete\":1}}" logger.Debug("鍒犻櫎璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params) data := esutil.GetEsDataReq(url, params, false) //c.JSON(200, changeEsRespData(data, "鍒犻櫎鎴愬姛")) -- Gitblit v1.8.0