From cfeba2dea02c1de54cde6c95f2a3f46c121d34aa Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期五, 16 八月 2019 15:16:14 +0800
Subject: [PATCH] dev add publicDomain

---
 controllers/dbtableperson.go |   42 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/controllers/dbtableperson.go b/controllers/dbtableperson.go
index bad1888..205d473 100644
--- a/controllers/dbtableperson.go
+++ b/controllers/dbtableperson.go
@@ -58,7 +58,6 @@
 		logger.Debug("Json marshaling failed锛�%s\n", e)
 	}
 	params := string(personbytes)
-	logger.Debug("璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params)
 	data, _ := esutil.PutEsDataReq(url, params)
 	//if data["_id"] !=""{
 	//	//閫氱煡姣斿杩涚▼缂撳瓨鏇存柊
@@ -130,6 +129,46 @@
 		//code.ServiceInsideError.Message += result["msg"].(string)
 		util.ResponseFormat(c, code.ServiceInsideError, result["data"])
 	}
+}
+
+func UpdateDbPersonsOfDbTable(id string) (message string) {
+	url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport +
+		"/" + config.EsInfo.EsIndex.Dbtablepersons.IndexName + "/_update_by_query?refresh"
+	jsonDSL := `
+			{
+	"script": {
+		"lang": "painless",
+		"inline": "ctx._source.enable = 0"
+	},
+	"query": {
+		"term": {
+			"tableId": "` + id + `"
+		}
+	}
+}
+`
+	buf, err := esutil.EsReq("POST", url, []byte(jsonDSL))
+	if err != nil {
+		logger.Debug("http request info is err!")
+		message = "淇敼澶辫触"
+	}
+	var info interface{}
+	json.Unmarshal(buf, &info)
+	out, ok := info.(map[string]interface{})
+	if !ok {
+		logger.Debug("http response interface can not change map[string]interface{}")
+		message = "淇敼澶辫触"
+	}
+	middle, ok := out["updated"].(float64)
+	if !ok {
+		logger.Debug("first result change error!")
+		message = "淇敼澶辫触"
+	}
+	if middle >= 0 {
+		logger.Debug("淇敼鎴愬姛")
+		message = "淇敼鎴愬姛,鏇存柊鐘舵�佹潯鏁颁负" + strconv.Itoa(int(middle))
+	}
+	return message
 }
 
 // @Summary 鍒犻櫎搴曞簱浜哄憳
@@ -280,7 +319,6 @@
 
 	params := "{\"query\":{\"bool\":{\"must_not\":[" +
 		"{\"term\":{\"isDelete\":\"1\"}}],\"filter\":[" + syncTerm + "]" + contentParam + "}},\"from\":" + strconv.Itoa(from) + ",\"size\":" + strconv.Itoa(size) + ",\"sort\":{\"" + orderName + "\":{\"order\":\"" + orderType + "\"}}}"
-	logger.Debug("璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params)
 	data := esutil.GetEsDataReq(url, params, true)
 	//c.JSON(200, data)
 	util.ResponseFormat(c, code.Success, data)

--
Gitblit v1.8.0