From 79622c34beb9a98e8b42cf45790242dc5a56742d Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期六, 31 八月 2019 16:43:50 +0800
Subject: [PATCH] fix tagList,show dt deleted but videopersons has data
---
controllers/taglist.go | 39 ++++++++++++++++++++++++++++++++++++---
1 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/controllers/taglist.go b/controllers/taglist.go
index 107532e..d897d74 100644
--- a/controllers/taglist.go
+++ b/controllers/taglist.go
@@ -2,7 +2,11 @@
import (
"basic.com/dbapi.git"
+ "encoding/json"
+ "fmt"
"webserver/extend/code"
+ "webserver/extend/config"
+ "webserver/extend/esutil"
"webserver/extend/util"
"github.com/gin-gonic/gin"
@@ -19,7 +23,6 @@
func (sc *EsSearchController) PostEsTagList(c *gin.Context) {
var dtApi dbapi.DbTableApi
- var dbpApi dbapi.DbPersonApi
dts, err := dtApi.FindAllDbTablesByCurServer()
if err == nil {
if dts !=nil {
@@ -31,8 +34,7 @@
tokenRes["value"] = dt.Id
tokenRes["status"] = dt.IsDelete
if dt.IsDelete == 1 {
- personTotal,_ := dbpApi.GetPersonTotal(dt.Id)
- if personTotal == 0 {
+ if GetTotalFromDb(dt.Id) == false {
continue
}
}
@@ -44,3 +46,34 @@
}
util.ResponseFormat(c,code.ComError,"鏌ヨ搴曞簱鏍囩澶辫触")
}
+
+//鍒ゆ柇搴曞簱鏄惁鏈夋暟鎹�
+func GetTotalFromDb(id string) (flag bool) {
+ flag = false
+ url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport +
+ "/" + config.EsInfo.EsIndex.VideoPersons.IndexName + "/_search"
+ prama := "{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"baseInfo.tableId\":\"" + id + "\"}}]}},\"size\":0}"
+ 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["hits"].(map[string]interface{})
+ if !ok {
+ fmt.Println("first hits change error!")
+ return
+ }
+
+ total := int(middle["total"].(float64))
+ if total > 0 {
+ flag = true
+ }
+ return flag
+}
\ No newline at end of file
--
Gitblit v1.8.0