--
liuxiaolong
2019-11-20 b9b81448965cd49d6e67b26506af561b88d75b5b
--
1个文件已修改
55 ■■■■■ 已修改文件
controllers/dbtablesCon.go 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/dbtablesCon.go
@@ -2,17 +2,11 @@
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"
)
@@ -63,20 +57,6 @@
    } 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
@@ -181,39 +161,6 @@
    } 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