From bfb981044cf52ca4420167b168a314689b72b999 Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期六, 24 八月 2019 17:52:11 +0800 Subject: [PATCH] fix swagger --- controllers/dbtableperson.go | 95 ++++++++++++++++++++++++----------------------- 1 files changed, 48 insertions(+), 47 deletions(-) diff --git a/controllers/dbtableperson.go b/controllers/dbtableperson.go index 9afabe9..63e1d8d 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) @@ -164,22 +163,25 @@ } } +type DelMultiPerson []string + // @Summary 鍒犻櫎搴曞簱浜哄憳 // @Description 鍒犻櫎搴撲汉鍛� // @Accept json // @Produce json // @Tags dbperson 搴曞簱浜哄憳 -// @Param uuids body []string true "搴曞簱浜哄憳ids " +// @Param uuids body controllers.DelMultiPerson true "搴曞簱浜哄憳ids " // @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}" // @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}" // @Router /data/api-v/dbperson/deleteMoreDbPerson [POST] func (dbc DbPersonController) DeleteMoreDbPerson(c *gin.Context) { - uuids := make([]string, 0, 5) + var uuids DelMultiPerson err := c.BindJSON(&uuids) if err !=nil || len(uuids)==0{ util.ResponseFormat(c,code.RequestParamError,"鍙傛暟鏈夎") return } + logger.Debug("DeleteMoreDbPerson len(uuids):",len(uuids)) var pApi dbapi.DbPersonApi paramBody := util.Struct2Map(uuids) b, _ := pApi.DeleteMoreDbPerson(paramBody) @@ -195,45 +197,41 @@ // @Accept json // @Produce json // @Tags dbperson 搴曞簱浜哄憳 -// @Param reqMap body map false "{"tableId":"","orderName":"uuid","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" @@ -242,7 +240,7 @@ } var pApi dbapi.DbPersonApi paramBody := map[string]interface{}{ - "tableId":tableId, + "tableId": reqBody.TableId, "orderName":orderName, "orderType":orderType, "contentValue":contentValue, @@ -257,31 +255,41 @@ } } +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 // @Produce json // @Tags dbperson 搴曞簱浜哄憳 -// @Param reqMap body map false "{"tableId":"","orderName":"uuid","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:{}}" +// @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/queryDbPersonsByCampare [POST] func (dbc DbPersonController) QueryDbPersonsByCampare(c *gin.Context) { url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + "/" + config.EsInfo.EsIndex.Dbtablepersons.IndexName + "/_search" // ?refresh=wait_for - reqBody := make(map[string]interface{}, 5) + var reqBody DbtSearch c.BindJSON(&reqBody) tableId := "" - if reqBody["tableId"] != nil { - tableId = reqBody["tableId"].(string) + if reqBody.TableId != "" { + tableId = reqBody.TableId } 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 } // 鍒楃被鍨� faceUrl := "" var threshold float32 @@ -323,14 +331,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) @@ -345,4 +346,4 @@ data["total"] = len(datalist) //c.JSON(200, data) util.ResponseFormat(c, code.Success, data) -} +}*/ -- Gitblit v1.8.0