From dd14647ee77aef511d76ade8e0993f67efc94844 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期二, 27 八月 2019 11:28:53 +0800
Subject: [PATCH] fix swagger

---
 controllers/capture.go       |   16 +++++---
 controllers/monitoring.go    |   16 ++++----
 controllers/initForData.go   |   16 +++++---
 controllers/dbtableperson.go |   67 ++++++++++++++++-----------------
 router/router.go             |    2 
 5 files changed, 62 insertions(+), 55 deletions(-)

diff --git a/controllers/capture.go b/controllers/capture.go
index 441588b..de43401 100644
--- a/controllers/capture.go
+++ b/controllers/capture.go
@@ -13,22 +13,26 @@
 
 type RealTimeController struct{}
 
+type RealTimeArg struct {
+	TreeNodes []string `json:"treeNodes"`
+}
+
 // @Summary 瀹炴椂鎶撴媿
 // @Description 瀹炴椂鎶撴媿鏁版嵁
 // @Accept  json
 // @Produce json
 // @Tags realTime
-// @Param obj body map true "搴曞簱鏁版嵁"
-// @Success 200 {string} json "{"code":200, msg:"", success:true}"
-// @Failure 500 {string} json "{"code":500, msg:"", success:false}"
+// @Param obj body controllers.RealTimeArg true "搴曞簱鏁版嵁"
+// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
+// @Failure 500 {string} json "{"code":500,  msg:"杩斿洖閿欒淇℃伅", success:false}"
 // @Router /data/api-v/realTime/capture [POST]
+//瀹炴椂鎶撴媿
 func (rc *RealTimeController) PostCapture(c *gin.Context) {
-	searchBody := make(map[string]interface{}, 0)
-
+	var searchBody RealTimeArg
 	c.BindJSON(&searchBody)
 	index := config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName
 	cameraIdStr := ""
-	cameraId := searchBody["treeNodes"].([]interface{})
+	cameraId := searchBody.TreeNodes
 	if cameraId != nil && len(cameraId) > 0 {
 		esCameraId := strings.Replace(strings.Trim(fmt.Sprint(cameraId), "[]"), " ", "\",\"", -1)
 		cameraIdStr = "{\"terms\":{\"cameraId\":[\"" + esCameraId + "\"]}},"
diff --git a/controllers/dbtableperson.go b/controllers/dbtableperson.go
index 6f4278d..0cc064d 100644
--- a/controllers/dbtableperson.go
+++ b/controllers/dbtableperson.go
@@ -24,9 +24,8 @@
 // @Produce json
 // @Tags dbperson 搴曞簱浜哄憳
 // @Param obj body models.Dbtablepersons true "搴曞簱浜哄憳鏁版嵁"
-// @Success 200 {object} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
-// @Failure 500 {string} json "{"code":500,  msg:"杩斿洖閿欒淇℃伅", success:false}"
-// @Failure 400 {object} json code.RequestParamError
+// @Success 200 {string} json "{"code":200, msg:"", success:true}"
+// @Failure 500 {string} json "{"code":500, msg:"", success:false}"
 // @Router /data/api-v/dbperson/addDbPerson [PUT]
 func (dbc DbPersonController) AddDbPerson(c *gin.Context) {
 	dbperson := new(models.Dbtablepersons)
@@ -196,45 +195,41 @@
 // @Accept  json
 // @Produce json
 // @Tags dbperson 搴曞簱浜哄憳
-// @Param reqMap body map false "{"tableId":"","orderName":"id","orderType":"desc","contentValue":"","page":1,"size":8}"
+// @Param reqMap body controllers.DbtSearch false "{"tableId":"","orderName":"id","orderType":"desc","contentValue":"","page":1,"size":8}"
 // @Success 200 {string} json "{"code":200, "msg":"鐩綍缁撴瀯鏁版嵁", "success":true,"data":{}}"
 // @Failure 500 {string} json "{code:500,  msg:"杩斿洖閿欒淇℃伅", success:false,data:{}}"
 // @Router /data/api-v/dbperson/queryDbPersonsByTbId [POST]
 func (dbc DbPersonController) QueryDbPersonsByTbId(c *gin.Context) {
-	reqBody := make(map[string]interface{}, 5)
-	c.BindJSON(&reqBody)
-	tableId := ""
-	if reqBody["tableId"] != nil {
-		tableId = reqBody["tableId"].(string)
+	//reqBody := make(map[string]interface{}, 5)
+	var reqBody DbtSearch
+	err := c.BindJSON(&reqBody)
+	if err !=nil || reqBody.Page <=0 || reqBody.Size <=0 {
+		util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎")
+		return
 	}
-	if tableId == "" {
+
+	if reqBody.TableId == "" {
 		util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎锛屽簳搴搃d涓嶈兘涓虹┖")
 		return
 	}
 	orderName := "id"
-	if reqBody["orderName"] != nil {
-		orderName = reqBody["orderName"].(string)
+	if reqBody.OrderName != "" {
+		orderName = reqBody.OrderName
 	} // 鍒楀悕
 	orderType := "desc"
-	if reqBody["orderType"] != nil {
-		orderType = reqBody["orderType"].(string)
+	if reqBody.OrderType != "" {
+		orderType = reqBody.OrderType
 	} // 鍒楃被鍨�
 	contentValue := ""
-	if reqBody["contentValue"] != nil {
-		contentValue = reqBody["contentValue"].(string)
-	} //杈撳叆妗嗗唴瀹�
+
 	page := 1
-	if reqBody["page"] != nil {
-		page = int(reqBody["page"].(float64))
+	if reqBody.Page >1 {
+		page = reqBody.Page
 	} // 椤电爜
 	size := 8
-	if reqBody["size"] != nil {
-		size = int(reqBody["size"].(float64))
+	if reqBody.Size >8 {
+		size = reqBody.Size
 	} // 鏉℃暟
-
-	if tableId == "all" || tableId == "" {
-		// / 鎵�鏈変汉鍛�
-	}
 
 	if orderType == "desc" {
 		orderType = "desc"
@@ -243,7 +238,7 @@
 	}
 	var pApi dbapi.DbPersonApi
 	paramBody := map[string]interface{}{
-		"tableId":tableId,
+		"tableId": reqBody.TableId,
 		"orderName":orderName,
 		"orderType":orderType,
 		"contentValue":contentValue,
@@ -258,6 +253,16 @@
 	}
 }
 
+type DbtSearch struct {
+	TableId string `json:"tableId"`
+	OrderName string `json:"orderName"`
+	OrderType string `json:"orderType"`
+	ContentValue string `json:"contentValue"`
+	Page int `json:"page"`
+	Size int `json:"size"`
+}
+
+/*
 // @Summary 鏌ヨ搴曞簱浜哄憳鍒楄〃
 // @Description 鏌ヨ搴撲汉鍛樺垪琛�
 // @Accept  json
@@ -324,14 +329,7 @@
 	data := esutil.GetEsDataReq(url, params, true)
 	featByte := make([]byte, 0, 1024)
 	if len(faceUrl) > 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
+
 	}
 	to := page * size
 	datalist := sourceCompare(data["datalist"].([]interface{}), false, featByte, threshold)
@@ -347,3 +345,4 @@
 	//c.JSON(200, data)
 	util.ResponseFormat(c, code.Success, data)
 }
+*/
diff --git a/controllers/initForData.go b/controllers/initForData.go
index af18dd4..fc0c9d4 100644
--- a/controllers/initForData.go
+++ b/controllers/initForData.go
@@ -52,30 +52,34 @@
 	util.ResponseFormat(c, code.Success, tokenRes)
 }
 
+type InitForMonitorArg struct {
+	TreeNodes []string `json:"treeNodes"`
+	Tasks []string `json:"tasks"`
+}
+
 // @Summary 瀹炴椂浠诲姟鐩戞帶鏁版嵁鍒濆鍖�
 // @Description 瀹炴椂鐩戞帶姣斿鏁版嵁
 // @Accept  json
 // @Produce json
 // @Tags realTime
-// @Param obj body map true "搴曞簱鏁版嵁"
+// @Param obj body controllers.InitForMonitorArg true "瀹炴椂浠诲姟鐩戞帶鍙傛暟"
 // @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
 // @Failure 500 {string} json "{"code":500,  msg:"杩斿洖閿欒淇℃伅", success:false}"
 // @Router /data/api-v/realTime/initForMonitoringData [POST]
-//瀹炴椂鐩戞帶鏁版嵁鍒濆鍖�
 func (rc *RealTimeController) InitForMonitoringData(c *gin.Context) {
-	searchBody := make(map[string]interface{}, 0)
-
+	//searchBody := make(map[string]interface{}, 0)
+	var searchBody InitForMonitorArg
 	c.BindJSON(&searchBody)
 	index := config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName
 	cameraIdStr := ""
-	cameraId := searchBody["treeNodes"].([]interface{})
+	cameraId := searchBody.TreeNodes
 	if cameraId != nil && len(cameraId) > 0 {
 		esCameraId := strings.Replace(strings.Trim(fmt.Sprint(cameraId), "[]"), " ", "\",\"", -1)
 		cameraIdStr = "{\"terms\":{\"cameraId\":[\"" + esCameraId + "\"]}},"
 	}
 	//鍒ゆ柇浠诲姟ID
 	taskIdStr := "{\"terms\":{\"taskId\":[]}},"
-	taskId := searchBody["tasks"].([]interface{})
+	taskId := searchBody.Tasks
 	if taskId != nil && len(taskId) > 0 {
 		esTaskId := strings.Replace(strings.Trim(fmt.Sprint(taskId), "[]"), " ", "\",\"", -1)
 		taskIdStr = "{\"terms\":{\"taskId\":[\"" + esTaskId + "\"]}},"
diff --git a/controllers/monitoring.go b/controllers/monitoring.go
index 209f66f..8cd1125 100644
--- a/controllers/monitoring.go
+++ b/controllers/monitoring.go
@@ -17,25 +17,25 @@
 // @Accept  json
 // @Produce json
 // @Tags realTime
-// @Param obj body map true "搴曞簱鏁版嵁"
-// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
-// @Failure 500 {string} json "{"code":500,  msg:"杩斿洖閿欒淇℃伅", success:false}"
+// @Param obj body controllers.InitForMonitorArg true "瀹炴椂鐩戞帶鍙傛暟"
+// @Success 200 {string} json "{"code":200, msg:"", success:true}"
+// @Failure 500 {string} json "{"code":500, msg:"", success:false}"
 // @Router /data/api-v/realTime/monitoring [POST]
-//瀹炴椂鐩戞帶
 func (rc *RealTimeController) PostMonitoring(c *gin.Context) {
-	searchBody := make(map[string]interface{}, 0)
+	//searchBody := make(map[string]interface{}, 0)
+	var searchBody InitForMonitorArg
 
 	c.BindJSON(&searchBody)
 	index := config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName
 	cameraIdStr := ""
-	cameraId := searchBody["treeNodes"].([]interface{})
+	cameraId := searchBody.TreeNodes
 	if cameraId != nil && len(cameraId) > 0 {
 		esCameraId := strings.Replace(strings.Trim(fmt.Sprint(cameraId), "[]"), " ", "\",\"", -1)
 		cameraIdStr = "{\"terms\":{\"cameraId\":[\"" + esCameraId + "\"]}},"
 	}
 	//鍒ゆ柇浠诲姟ID
 	taskIdStr := "{\"terms\":{\"taskId\":[]}},"
-	taskId := searchBody["tasks"].([]interface{})
+	taskId := searchBody.Tasks
 	if taskId != nil && len(taskId) > 0 {
 		esTaskId := strings.Replace(strings.Trim(fmt.Sprint(taskId), "[]"), " ", "\",\"", -1)
 		taskIdStr = "{\"terms\":{\"taskId\":[\"" + esTaskId + "\"]}},"
@@ -59,7 +59,7 @@
 	fmt.Println(prama)
 	fmt.Println(url)
 	tokenRes := esutil.GetEsDataReq(url, prama, true)
-	/*	for _, value := range tokenRes["datalist"].([]interface{}) {
+	/*    for _, value := range tokenRes["datalist"].([]interface{}) {
 		if value.(map[string]interface{})["personId"] != nil {
 			info := getDBPersonInfo(value.(map[string]interface{})["personId"].(string))
 			for key, val := range info {
diff --git a/router/router.go b/router/router.go
index 24651a5..2f08d50 100644
--- a/router/router.go
+++ b/router/router.go
@@ -158,7 +158,7 @@
 	vdbperson := r.Group(urlPrefix + "/dbperson")
 	{
 		vdbperson.POST("/queryDbPersonsByTbId", dbPersonCont.QueryDbPersonsByTbId)
-		vdbperson.POST("/queryDbPersonsByCampare", dbPersonCont.QueryDbPersonsByCampare)
+		//vdbperson.POST("/queryDbPersonsByCampare", dbPersonCont.QueryDbPersonsByCampare)
 		vdbperson.POST("/updateDbPerson", dbPersonCont.UpdateDbPerson)
 		vdbperson.POST("/deleteDbPersonById/:uuid", dbPersonCont.DeleteDbPerson)
 		vdbperson.POST("/deleteMoreDbPerson", dbPersonCont.DeleteMoreDbPerson)

--
Gitblit v1.8.0