From 82e97bd7595ede5f59befe3dd977c8ae11ec848c Mon Sep 17 00:00:00 2001 From: sunty <suntianyu0923@163.com> Date: 星期一, 05 八月 2019 14:39:58 +0800 Subject: [PATCH] add Cascade modification dbtablepersons enable status --- controllers/dbtableperson.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-) diff --git a/controllers/dbtableperson.go b/controllers/dbtableperson.go index bad1888..9c362a7 100644 --- a/controllers/dbtableperson.go +++ b/controllers/dbtableperson.go @@ -132,6 +132,46 @@ } } +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 鍒犻櫎搴曞簱浜哄憳 // @Description 鍒犻櫎搴撲汉鍛� // @Accept x-www-form-urlencoded -- Gitblit v1.8.0