From 2a9ea1c76b4f493fb974154a130ce682616c5a49 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期五, 26 七月 2019 13:48:11 +0800
Subject: [PATCH] logger

---
 controllers/es.go |  130 ++++---------------------------------------
 1 files changed, 13 insertions(+), 117 deletions(-)

diff --git a/controllers/es.go b/controllers/es.go
index 0753d32..fe2afbc 100644
--- a/controllers/es.go
+++ b/controllers/es.go
@@ -2,7 +2,6 @@
 
 import (
 	"basic.com/dbapi.git"
-	"encoding/json"
 	"fmt"
 	"github.com/gin-gonic/gin"
 	"math/rand"
@@ -24,57 +23,33 @@
 // @Produce json
 // @Tags es
 // @Param reqMap body models.EsSearch true "collection 涓虹┖"
-// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
-// @Failure 500 {string} json "{"code":500,  msg:"杩斿洖閿欒淇℃伅", success:false}"
+// @Success 200 {string} json "{"code":200, msg:"", success:true}"
+// @Failure 500 {string} json "{"code":500, msg:"", success:false}"
 // @Router /data/api-v/es/queryEsCompareData [POST]
 func PostEsCompareData(c *gin.Context) {
 	searchBody := new(models.EsSearch)
-	c.BindJSON(&searchBody)
-	isEsSource := true
+	err := c.BindJSON(&searchBody)
+	if err != nil || searchBody.PicUrl == "" || len(searchBody.DataBases) == 0 {
+		util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
+		return
+	}
 	databases := searchBody.DataBases
-	page := searchBody.Page
-	if page <= 0 {
-		page = 1
-	}
-	size := searchBody.Size
-	if size <= 0 {
-		size = 8
-	}
-	from := (page - 1) * size
-	to := page * size
-	threshold := searchBody.Threshold
-	if threshold < 0 || threshold > 100 {
-		threshold = 60
-	}
-	picUrl := searchBody.PicUrl
-	/*feature := searchBody.Feature*/
-	var featByte []byte
-	if len(picUrl) > 3 { //   linux
-		/*fileName := picUrl   // picIp 瀹氫箟鍦� fileController weedfs 鏂囦欢鏈嶅姟鍣� 璁块棶 璺緞 鍓嶇紑
-		detect := gorun.GetSimpleFaceDetect(fileName)
-		if len(detect) != 1 {
-			util.ResponseFormat(c,code.TooManyFeatureFindError,"鍥剧墖鐗瑰緛鍊艰繃澶�")
-			return
-		}else {
-			featByte = detect[0]["feature"].([]byte)
-		}*/ //   linux
-	}
+	from := 0
+	to := 0
+
 	data := make(map[string]interface{})
 	searchBody.Page = 1
 	searchBody.Size = 15000
-	//searchMap := Struct2Map(*searchBody)
+
 	if len(databases) == 1 && databases[0] == "esData" {
 		searchBody.IsAggs = false
-		data = searchEsData(*searchBody)
 	} else {
-		isEsSource = false
 		data = service.QueryDbPersonsForCompare(*searchBody)
 	}
 	sources := data["datalist"].([]interface{})
 
 	if len(sources) > 0 {
 		//杩涜姣斿
-		sources = sourceCompare(sources, isEsSource, featByte, threshold)
 	} else {
 		fmt.Println("鏌ヨ鏉′欢涓嬫棤鏁版嵁 source 鏁版嵁涓虹┖锛�" + string(len(sources)))
 	}
@@ -86,79 +61,13 @@
 	if to > dataLen {
 		to = dataLen
 	}
-	sources = sources[from:to] // 鏁版嵁 閮ㄥ垎鑾峰彇
-	if !isEsSource {           //  浜哄憳鏁版嵁瑕佸姞搴曞簱鍚嶇О
-		for _, sou := range sources {
-			tableId := sou.(map[string]interface{})["tableId"]
-			if tableId != nil {
-				info := QueryDbTableInfo(tableId.(string))
-				if info["tableName"] != nil {
-					sou.(map[string]interface{})["tableName"] = info["tableName"]
-				} else {
-					sou.(map[string]interface{})["tableName"] = "鍏朵粬"
-				}
-				if info["bwType"] != nil {
-					sou.(map[string]interface{})["bwType"] = info["bwType"]
-				} else {
-					sou.(map[string]interface{})["bwType"] = "4"
-				}
-			}
-		}
-	}
+
 	dmap := make(map[string]interface{}, 2)
 	dmap["datalist"] = sources
 	dmap["total"] = dataLen
 	util.ResponseFormat(c, code.Success, dmap)
-}
 
-// @Summary 鏌ヨ鎽勫儚鏈轰互鍙婂惎绠楁硶
-// @Description 鍏宠仈鏌ヨ鎽勫儚鏈轰互鍙婂惎绠楁硶
-// @Produce json
-// @Tags camera
-// @Success 200 {string} json "{"code":200, success:true,  msg:"璇锋眰澶勭悊鎴愬姛", data:"鎽勫儚鏈轰俊鎭�"}"
-// @Failure 500 {string} json "{"code":500, success:false   msg:"",data:"閿欒淇℃伅鍐呭"}"
-// @Router /data/api-v/camera/queryCameraAndTaskInfo [get]
-//func (ac *CameraController) QueryCameraAndTaskInfo(c *gin.Context) {
-//	var cam models.Camera
-//	rows := cam.FindAllCamTask()
-//
-//	if len(rows) == 0 {
-//		util.ResponseFormat(c, code.ComError, "娌℃湁璁板綍")
-//		return
-//	}
-//	camList := make([]map[string]interface{}, 0, 5)
-//	for _, cam := range rows {
-//		newCam := make(map[string]interface{})
-//		newCam["cameraid"] = cam.Id
-//		newCam["rtspUrl"] = cam.Rtsp
-//		tasks := cam.CamTask
-//		taskList := make([]map[string]interface{}, 0)
-//		if tasks != nil {
-//			taskmap := make(map[string]interface{})
-//			for _, task := range tasks {
-//				taskId := taskmap[task.Taskid]
-//				if taskId != nil {
-//					cameraTasks := taskmap[task.Taskid].([]models.CameraTask)
-//					cameraTasks = append(cameraTasks, task)
-//					taskmap[task.Taskid] = cameraTasks
-//				} else {
-//					cameraTasks := make([]models.CameraTask, 0)
-//					taskmap[task.Taskid] = append(cameraTasks, task)
-//				}
-//			}
-//			for key, value := range taskmap {
-//				i := make(map[string]interface{})
-//				i["taskid"] = key
-//				i["sdklist"] = value
-//				taskList = append(taskList, i)
-//			}
-//		}
-//		newCam["tasklist"] = taskList
-//		camList = append(camList, newCam)
-//	}
-//	c.JSON(200, camList)
-//
-//}
+}
 
 func searchEsData(searchBody models.EsSearch) map[string]interface{} {
 	//璇锋眰绱㈠紩
@@ -251,17 +160,4 @@
 		}
 	}
 	return dataSource
-}
-
-// type  杞� map
-func Struct2Map(obj interface{}) map[string]interface{} {
-	var data = make(map[string]interface{})
-	bytes, _ := json.Marshal(obj)
-	json.Unmarshal(bytes, &data)
-	/*t := reflect.TypeOf(obj)
-	v := reflect.ValueOf(obj)
-	for i := 0; i < t.NumField(); i++ {
-		data[t.Field(i).Name] = v.Field(i).Interface()
-	}*/
-	return data
 }

--
Gitblit v1.8.0