liuxiaolong
2019-09-28 4c7890a506f95bfc8d06a75dbf6150bb8fcad1bb
controllers/camera.go
@@ -4,12 +4,14 @@
   "encoding/json"
   "fmt"
   "strconv"
   "basic.com/valib/logger.git"
   "github.com/gin-gonic/gin"
   "basic.com/dbapi.git"
   "webserver/extend/code"
   "webserver/extend/util"
    "webserver/service"
)
type CameraController struct{}
@@ -17,11 +19,12 @@
type CameraVo struct {
   Id        string  `json:"id"`
   Name      string  `json:"name"`
   Alias     string  `json:"alias"` //摄像机的别名
   Type      int     `json:"type" `
   Addr      string  `json:"addr"`
   Areaid    uint    `json:"areaid"`
   Longitude float64 `json:"longitude"`
   Latitude  float64 `json:"latitude"`
   Areaid    string  `json:"areaid"`
   Longitude float32 `json:"longitude"`
   Latitude  float32 `json:"latitude"`
   Rtsp      string  `json:"rtsp"`
   Ip        string  `json:"ip"`
   Port      int     `json:"port"`
@@ -54,10 +57,10 @@
      util.ResponseFormat(c, code.RequestParamError, "参数错误")
      return
   }
   cam.Id = util.PseudoUuid()
   paramBody := util.Struct2Map(cam)
   if api.CameraAdd(paramBody) {
      util.ResponseFormat(c, code.Success, cam)
   b, data := api.CameraAdd(paramBody)
   if b {
      util.ResponseFormat(c, code.Success, data)
      return
   }
   util.ResponseFormat(c, code.ComError, err)
@@ -83,7 +86,7 @@
      return
   }
   paramBody := util.Struct2Map(cam)
   if api.CameraAdd(paramBody) {
   if api.CameraUpdate(paramBody) {
      util.ResponseFormat(c, code.Success, cam)
      return
   }
@@ -102,7 +105,7 @@
func (ac CameraController) CameraDel(c *gin.Context) {
   var api dbapi.CameraApi
   cid := c.Param("cid")
   logger.Debug("CameraDel.cid:",cid)
   if api.CameraDelete(cid) {
      util.ResponseFormat(c, code.Success, "删除成功")
      return
@@ -254,6 +257,26 @@
   }
}
// @Summary  更新底图
// @Description 刷新底图
// @Produce json
// @Tags camera
// @Param cid path 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/updateSnapshotUrl/{cid} [get]
func(cc CameraController) UpdateSnapshotUrl(c *gin.Context){
    cid := c.Param("cid")
    //filename, err := service.UpdateSnapshotUrl(cid)
   filename, err := service.UpdateCapture(cid)
    if err != nil {
       logger.Debug("UpdateSnapshotUrl.err:",err)
      util.ResponseFormat(c, code.ComError, "更新失败")
        return
    }
    util.ResponseFormat(c, code.Success, filename)
}
type CameraChangeRunVo struct {
   CameraIds []string `json:"camera_ids"`
   RunType   int      `json:"run_type"`
@@ -282,3 +305,5 @@
      util.ResponseFormat(c, code.ComError, "更新失败")
   }
}