sunty
2019-08-05 82e97bd7595ede5f59befe3dd977c8ae11ec848c
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