liuxiaolong
2019-12-26 87051e0ff26fbb47b4aa828b22dcfd6a628a47d0
controllers/camera.go
@@ -1,10 +1,12 @@
package controllers
import (
   "basic.com/pubsub/protomsg.git"
   "encoding/json"
   "fmt"
   "strconv"
   "basic.com/valib/logger.git"
   "strings"
   "webserver/cache"
   "github.com/gin-gonic/gin"
@@ -333,13 +335,42 @@
func(cc CameraController) UpdateSnapshotUrl(c *gin.Context){
    cid := c.Param("cid")
    //filename, err := service.UpdateSnapshotUrl(cid)
    if cid == "" {
      util.ResponseFormat(c, code.RequestParamError, "参数有误")
      return
   }
    if strings.HasPrefix(cid, File_Video_Id_Pre) || strings.HasPrefix(cid, File_Img_Id_Pre) || strings.HasPrefix(cid, File_Audio_Id_Pre) {
      var fileApi dbapi.FileAnalysisApi
      b, d := fileApi.Show(cid)
      if b {
         var file protomsg.FileAnalysis
         bytes, _ := json.Marshal(d)
         err := json.Unmarshal(bytes, &file)
         if err == nil {
            util.ResponseFormat(c, code.Success, map[string]string{
               "cameraId": cid,
               "snapshotUrl": file.SnapshotUrl,
            })
            return
         } else {
            util.ResponseFormat(c, code.ComError, "更新失败")
            return
         }
      } else {
         util.ResponseFormat(c, code.ComError, "更新失败")
         return
      }
   }
   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)
    util.ResponseFormat(c, code.Success, map[string]string{
       "cameraId": cid,
       "snapshotUrl": filename,
   })
type CameraChangeRunVo struct {