| | |
| | | "encoding/json" |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/satori/go.uuid" |
| | | "log" |
| | | "webserver/extend/code" |
| | | "webserver/extend/config" |
| | | "webserver/extend/esutil" |
| | | "webserver/extend/util" |
| | | "webserver/models" |
| | | "github.com/satori/go.uuid" |
| | | "log" |
| | | ) |
| | | |
| | | type DbTableController struct { |
| | |
| | | isSync := c.Params.ByName("isSync") |
| | | syncTerm := "" |
| | | if isSync == "1" { |
| | | syncTerm = ",{\"term\":{\"syncType\":\"1\"}}" // 同步库 |
| | | syncTerm = ",{\"term\":{\"isSync\":\"1\"}}" // 同步库 |
| | | } else if isSync == "2" { |
| | | syncTerm = ",{\"term\":{\"syncType\":\"2\"}}" // / 本地库 |
| | | syncTerm = ",{\"term\":{\"isSync\":\"2\"}}" // / 本地库 |
| | | } |
| | | params := "{\"query\":{\"bool\":{\"must\":[" + |
| | | "{\"term\":{\"del_flag\":\"0\"}}" + syncTerm + "]}}," + |
| | | "\"from\":0,\"size\":100,\"sort\":{\"uuid\":{\"order\":\"asc\"}}}" |
| | | "{\"term\":{\"isDelete\":\"0\"}}" + syncTerm + "]}}," + |
| | | "\"from\":0,\"size\":100,\"sort\":{\"id\":{\"order\":\"asc\"}}}" |
| | | fmt.Print("请求url:%s;\n 请求参数params:%s", url, params) |
| | | |
| | | data := esutil.GetEsDataReq(url, params, true) |
| | |
| | | } |
| | | |
| | | // 依据底库id 查询数据 |
| | | func QueryDbTableInfo(tableId string) map[string]interface{} { |
| | | func QueryDbTableInfo(tableId string) map[string]interface{} { |
| | | url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + |
| | | "/" + config.EsInfo.EsIndex.DbTables.IndexName +"/" + config.EsInfo.EsIndex.DbTables.IndexName + "/"+tableId |
| | | "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/" + tableId |
| | | fmt.Print("请求url:%s;", url) |
| | | data := esutil.GetEsDataInfo(url, true) |
| | | return data |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | // @Summary 修改底库 |
| | | // @Description 修改同步或本地库 |
| | |
| | | //fmt.Printf("%s\n", dbTableByte) |
| | | params := string(dbTableByte) |
| | | fmt.Print("请求url:%s;\n 请求参数params:%s", url, params) |
| | | data,_ := esutil.PutEsDataReq(url, params) |
| | | data, _ := esutil.PutEsDataReq(url, params) |
| | | //c.JSON(200, changeEsRespData(data, "添加成功")) |
| | | result := changeEsRespData(data, "添加成功") |
| | | if result["success"].(bool) { |
| | |
| | | uuid := c.Params.ByName("uuid") |
| | | url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + |
| | | "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/" + config.EsInfo.EsIndex.DbTables.IndexType + "/" + uuid + "/_update" |
| | | params := "{\"doc\":{\"del_flag\":\"1\"}}" |
| | | params := "{\"doc\":{\"isDelete\":\"1\"}}" |
| | | fmt.Print("删除请求url:%s;\n 请求参数params:%s", url, params) |
| | | data := esutil.GetEsDataReq(url, params, false) |
| | | //c.JSON(200, changeEsRespData(data, "删除成功")) |