| | |
| | | |
| | | import ( |
| | | "basic.com/dbapi.git" |
| | | "encoding/json" |
| | | "fmt" |
| | | "basic.com/valib/logger.git" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/satori/go.uuid" |
| | | "strconv" |
| | | "time" |
| | | "webserver/cache" |
| | | "webserver/extend/code" |
| | | "webserver/extend/config" |
| | | "webserver/extend/esutil" |
| | | "basic.com/valib/logger.git" |
| | | "webserver/extend/util" |
| | | "webserver/models" |
| | | ) |
| | |
| | | } else { |
| | | util.ResponseFormat(c,code.ComError,[]interface{}{}) |
| | | } |
| | | } |
| | | |
| | | // 依据底库id 查询数据 |
| | | func QueryDbTableInfo(tableId string) map[string]interface{} { |
| | | localConf, err2 := cache.GetServerInfo() |
| | | if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" { |
| | | logger.Debug("localConfig is wrong!!!") |
| | | return nil |
| | | } |
| | | url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) + |
| | | "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/" + tableId |
| | | logger.Debug("请求url:%s;", url) |
| | | data := esutil.GetEsDataInfo(url, true) |
| | | return data |
| | | } |
| | | |
| | | // @Security ApiKeyAuth |
| | |
| | | } else { |
| | | util.ResponseFormat(c,code.ComError,"更新失败") |
| | | } |
| | | } |
| | | |
| | | func UpdateEndTime(id string) (flag bool) { |
| | | flag = false |
| | | localConf, err2 := cache.GetServerInfo() |
| | | if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" { |
| | | logger.Debug("localConfig is wrong!!!") |
| | | return false |
| | | } |
| | | url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) + |
| | | "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/" + config.EsInfo.EsIndex.DbTables.IndexType + "/" + id + "/_update?refresh=wait_for" |
| | | prama := "{\"script\":\"ctx._source.remove(\\\"endTime\\\")\"}" |
| | | buf, err := esutil.EsReq("POST", url, []byte(prama)) |
| | | if err != nil { |
| | | fmt.Println("http request info is err!") |
| | | return |
| | | } |
| | | var info interface{} |
| | | json.Unmarshal(buf, &info) |
| | | out, ok := info.(map[string]interface{}) |
| | | if !ok { |
| | | fmt.Println("http response interface can not change map[string]interface{}") |
| | | return |
| | | } |
| | | middle, ok := out["result"].(string) |
| | | if !ok { |
| | | fmt.Println("first result change error!") |
| | | return |
| | | } |
| | | if middle == "updated" { |
| | | flag = true |
| | | } |
| | | return flag |
| | | } |
| | | |
| | | // @Security ApiKeyAuth |