| | |
| | | |
| | | 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" |
| | |
| | | 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 { |
| | |
| | | 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 |
| | | } |
| | | } |
| | |
| | | } |
| | | 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 |
| | | } |