From f79f18bf3e65ad0eaf8fd1feb788bf792e362520 Mon Sep 17 00:00:00 2001 From: sunty <suntianyu0923@163.com> Date: 星期四, 01 八月 2019 15:05:32 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- controllers/dbtableperson.go | 32 +++++++++++++++++--------------- 1 files changed, 17 insertions(+), 15 deletions(-) diff --git a/controllers/dbtableperson.go b/controllers/dbtableperson.go index 738128d..6d7d5c7 100644 --- a/controllers/dbtableperson.go +++ b/controllers/dbtableperson.go @@ -2,10 +2,10 @@ import ( "encoding/json" - "fmt" "log" "strconv" "time" + "webserver/extend/logger" "github.com/gin-gonic/gin" "github.com/satori/go.uuid" @@ -55,10 +55,10 @@ "/" + config.EsInfo.EsIndex.Dbtablepersons.IndexName + "/" + config.EsInfo.EsIndex.Dbtablepersons.IndexType + "/" + personId + "?refresh=wait_for" personbytes, e := json.Marshal(dbperson) if e != nil { - fmt.Print("Json marshaling failed锛�%s\n", e) + logger.Debug("Json marshaling failed锛�%s\n", e) } params := string(personbytes) - fmt.Print("璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params) + logger.Debug("璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params) data, _ := esutil.PutEsDataReq(url, params) //c.JSON(200, changeEsRespData(data, "娣诲姞浜哄憳鎴愬姛")) result = changeEsRespData(data, "娣诲姞鎴愬姛") @@ -89,9 +89,9 @@ if err != nil { log.Fatalf("Json marshaling failed锛�%s", err) } - //fmt.Printf("%s\n", dbTableByte) + //logger.Debugf("%s\n", dbTableByte) params := "{\"doc\":" + string(dbTableByte) + "}" - fmt.Print("璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params) + logger.Debug("璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params) data := esutil.GetEsDataReq(url, params, false) //c.JSON(200, changeEsRespData(data,"淇敼鎴愬姛")) result := changeEsRespData(data, "淇敼鎴愬姛") @@ -119,7 +119,7 @@ url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + "/" + config.EsInfo.EsIndex.Dbtablepersons.IndexName + "/" + config.EsInfo.EsIndex.Dbtablepersons.IndexType + "/" + uuid + "/_update?refresh=wait_for" params := "{\"doc\":{\"isDelete\":\"1\",\"updateTime\":\"" + time.Now().Format("2006-01-02 15:04:05") + "\"}}" - fmt.Print("鍒犻櫎璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params) + logger.Debug("鍒犻櫎璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params) data := esutil.GetEsDataReq(url, params, false) @@ -149,10 +149,10 @@ bytes, _ := json.Marshal(uuids) s := string(bytes) url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + - "/" + config.EsInfo.EsIndex.Dbtablepersons.IndexName + "/_update_by_query?refresh=wait_for" // + config.EsInfo.EsIndex.Dbtablepersons.IndexType + "/" + "/" + s + "/" + config.EsInfo.EsIndex.Dbtablepersons.IndexName + "/_update_by_query?refresh" // + config.EsInfo.EsIndex.Dbtablepersons.IndexType + "/" + "/" + s params := "{\"script\":{\"lang\":\"painless\",\"inline\":\"ctx._source.isDelete = \\\"1\\\";" + "ctx._source.updateTime = \\\"" + time.Now().Format("2006-01-02 15:04:05") + "\\\"\"},\"query\":{\"terms\":{\"_id\":" + s + "}}}" - fmt.Print("鍒犻櫎璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params) + logger.Debug("鍒犻櫎璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params) data := esutil.GetEsDataReq(url, params, false) //c.JSON(200, changeEsRespData(data,"鍒犻櫎鎴愬姛")) //result := changeEsRespData(data, "鍒犻櫎鎴愬姛") @@ -209,7 +209,7 @@ if tableId == "all" || tableId == "" { // / 鎵�鏈変汉鍛� } else { - syncTerm = ",{\"term\":{\"tableId\":\"" + tableId + "\"}}" // 搴曞簱浜哄憳 + syncTerm = "{\"term\":{\"tableId\":\"" + tableId + "\"}}" // 搴曞簱浜哄憳 } if contentValue != "" { contentParam = ",\"must\":[{\"multi_match\":{\"query\":\"" + contentValue + "\",\"type\":\"best_fields\"," + @@ -223,8 +223,8 @@ } params := "{\"query\":{\"bool\":{\"must_not\":[" + - "{\"term\":{\"isDelete\":\"1\"}}],\"must_not\":[" + syncTerm + "]" + contentParam + "}},\"from\":" + strconv.Itoa(from) + ",\"size\":" + strconv.Itoa(size) + ",\"sort\":{\"" + orderName + "\":{\"order\":\"" + orderType + "\"}}}" - fmt.Print("璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params) + "{\"term\":{\"isDelete\":\"1\"}}],\"filter\":[" + syncTerm + "]" + contentParam + "}},\"from\":" + strconv.Itoa(from) + ",\"size\":" + strconv.Itoa(size) + ",\"sort\":{\"" + orderName + "\":{\"order\":\"" + orderType + "\"}}}" + logger.Debug("璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params) data := esutil.GetEsDataReq(url, params, true) //c.JSON(200, data) util.ResponseFormat(c, code.Success, data) @@ -280,7 +280,7 @@ if tableId == "all" || tableId == "" { // / 鎵�鏈変汉鍛� } else { - syncTerm = ",{\"term\":{\"tableId\":\"" + tableId + "\"}}" // 搴曞簱浜哄憳 + syncTerm = "{\"term\":{\"tableId\":\"" + tableId + "\"}}" // 搴曞簱浜哄憳 } if orderType == "desc" { orderType = "desc" @@ -288,9 +288,11 @@ orderType = "asc" } - params := "{\"query\":{\"bool\":{\"filter\":[" + - "{\"term\":{\"isDelete\":\"0\"}}" + syncTerm + "]" + contentParam + "}},\"from\":" + strconv.Itoa(from) + ",\"size\":" + strconv.Itoa(size) + ",\"sort\":{\"" + orderName + "\":{\"order\":\"" + orderType + "\"}}}" - fmt.Print("璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params) + //params := "{\"query\":{\"bool\":{\"filter\":[" + + // "{\"term\":{\"isDelete\":\"0\"}}" + syncTerm + "]" + contentParam + "}},\"from\":" + strconv.Itoa(from) + ",\"size\":" + strconv.Itoa(size) + ",\"sort\":{\"" + orderName + "\":{\"order\":\"" + orderType + "\"}}}" + params := "{\"query\":{\"bool\":{\"must_not\":[" + + "{\"term\":{\"isDelete\":\"1\"}}],\"filter\":[" + syncTerm + "]" + contentParam + "}},\"from\":" + strconv.Itoa(from) + ",\"size\":" + strconv.Itoa(size) + ",\"sort\":{\"" + orderName + "\":{\"order\":\"" + orderType + "\"}}}" + logger.Debug("璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params) data := esutil.GetEsDataReq(url, params, true) featByte := make([]byte, 0, 1024) if len(faceUrl) > 3 { // linux -- Gitblit v1.8.0