From f26a0cab5bca17b7eab57f6330e576271e17a17f Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期三, 13 十一月 2019 19:12:08 +0800 Subject: [PATCH] update ynSwagger,sync to master --- controllers/cameraPTZ.go | 73 ++++++++++++++++++++++++++++++++++++ 1 files changed, 73 insertions(+), 0 deletions(-) diff --git a/controllers/cameraPTZ.go b/controllers/cameraPTZ.go index 2d32936..a96f7b0 100644 --- a/controllers/cameraPTZ.go +++ b/controllers/cameraPTZ.go @@ -1 +1,74 @@ package controllers + +import ( + "basic.com/dbapi.git" + "basic.com/gb28181api.git" + + "webserver/extend/code" + "webserver/extend/config" + "webserver/extend/util" + + "github.com/gin-gonic/gin" +) + +type PanTiltZoomController struct { +} + +type PTZInstruct struct { + CameraId string `json:"cameraId"` //鎽勫儚鏈篿d + CameraType int `json:"cameraType"` //鎽勫儚鏈虹被鍨� + PTZType string `json:"ptzType"` //鎺у埗绫诲瀷 left right top ... stop +} + +/* +// @Summary 浜戝彴 +// @Description 鎽勫儚鏈轰簯鍙版帶鍒� +// @Security ApiKeyAuth +// @Accept json +// @Produce json +// @Tags camera +// @Param ptzBody body controllers.PTZInstruct true "鎺у埗绫诲瀷锛歶p,down,left,right,zoomin,zoomout,stop" +// @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/ptzControl [post] +*/ +func (ptz PanTiltZoomController) Move(c *gin.Context) { + var param PTZInstruct + if err := c.BindJSON(¶m); err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎") + return + } + + ptzSpeed := config.Server.PTZSpeed + if ptzSpeed == 0 { + ptzSpeed = 50 + } + + if param.CameraType == 1 { + var api dbapi.SysSetApi + r, gb28182Config := api.Gb28181ConfigShow() + + if r { + conf, ok := gb28182Config.(map[string]interface{}) + if ok { + gb28181api.Init(conf["ServerIp"].(string), int(conf["ServerPort"].(float64))) + } else { + util.ResponseFormat(c, code.ComError, "鍥芥爣閰嶇疆璇诲彇澶辫触") + return + } + + } else { + util.ResponseFormat(c, code.ComError, "鍥芥爣鎺ュ彛鏌ヨ澶辫触") + return + } + + var gbApi gb28181api.Gb28181Api + if r := gbApi.SetCameraPtz(param.CameraId, param.PTZType, ptzSpeed); r { + util.ResponseFormat(c, code.Success, "") + } else { + util.ResponseFormat(c, code.Success, "鍥芥爣鎺ュ彛鎿嶄綔澶辫触") + } + } else { + util.ResponseFormat(c, code.Success, "涓嶆敮鎸佺殑鎽勫儚鏈虹被鍨�") + } +} -- Gitblit v1.8.0