From b823f4e3e3e81666ef7400c87c21684dd6f6de2a Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期四, 05 三月 2020 16:46:20 +0800
Subject: [PATCH] dbperson add car

---
 controllers/camera.go |   40 ++++++++++++++++++++++++++++++++--------
 1 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/controllers/camera.go b/controllers/camera.go
index 73e1e88..bea1cc0 100644
--- a/controllers/camera.go
+++ b/controllers/camera.go
@@ -40,6 +40,20 @@
 	RunEnable   bool   `json:"run_enable"`    //鎺у埗瀹炴椂澶勭悊鎴栬疆璇㈠鐞嗙殑寮�鍏�
 	RunType     int    `json:"run_type"`      //澶勭悊绫诲瀷锛�0锛氳疆璇紝1锛氬疄鏃�
 	RunServerId string `json:"run_server_id"` //褰撳墠姝e湪澶勭悊鐨勫垎鏋愭湇鍔″櫒id
+
+	Sensors []SensorVo `json:"sensors"` //浼犳劅鍣ㄥ垪琛�
+}
+
+type SensorVo struct {
+	Id        string       `json:"id"`
+	Type 	  int 		   `json:"type"`
+	Ip 		  string       `json:"ip"`
+	Port 	  int 		   `json:"port"`
+	Username  string       `json:"username"`
+	Password  string 	   `json:"password"`
+	Threshold int 		   `json:"threshold"`
+	Enable 	  bool 		   `json:"enable"`
+	DevId  	  string       `json:"devId"`
 }
 
 // @Summary 娣诲姞鎽勫儚鏈�
@@ -203,18 +217,27 @@
 // @Security ApiKeyAuth
 // @Summary 灏嗘憚鍍忔満鎸傚埌鎸囧畾鐨勭洰褰曟爲涓�
 // @Description 灏嗘憚鍍忔満鎸傚埌鎸囧畾鐨勭洰褰曟爲涓�
+// @Accept x-www-form-urlencoded
 // @Produce json
 // @Tags camera
-// @Param cameraId path string true "鎽勫儚鏈篿d"
-// @Param areaId path string true "鐩綍鍖哄煙id"
+// @Param cameraId formData string true "鎽勫儚鏈篿d"
+// @Param areaId formData string true "鐩綍鍖哄煙id"
 // @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/cameraAreaAdd [get]
-func (ac CameraController) CameraAreaAdd(c *gin.Context) {
-	cameraId := c.Param("cameraId")
-	areaId := c.Param("areaId")
-	fmt.Println(cameraId)
-	fmt.Println(areaId)
+// @Router /data/api-v/camera/updateCameraArea [post]
+func (ac CameraController) UpdateCameraArea(c *gin.Context) {
+	cameraId := c.PostForm("cameraId")
+	areaId := c.PostForm("areaId")
+    if cameraId == "" || areaId == "" {
+        util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎")
+        return
+    }
+    var api dbapi.CameraApi
+    if api.UpdateCameraArea(cameraId, areaId) {
+        util.ResponseFormat(c,code.Success,"鏇存柊鎴愬姛")
+    } else {
+        util.ResponseFormat(c,code.ComError,"")
+    }
 }
 
 // @Security ApiKeyAuth
@@ -351,6 +374,7 @@
 					"cameraId": cid,
 					"snapshotUrl": file.SnapshotUrl,
 				})
+				return
 			} else {
 				util.ResponseFormat(c, code.ComError, "鏇存柊澶辫触")
 				return

--
Gitblit v1.8.0