liuxiaolong
2019-12-04 898d51114380447254334700969bf8c07c620120
fix UpdateSnapshotUrl when cid is file
4个文件已修改
39 ■■■■■ 已修改文件
controllers/camera.go 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/fileAnalysis.go 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
go.mod 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
go.sum 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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,6 +335,31 @@
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_Video_Id_Pre) || strings.HasPrefix(cid, File_Video_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,
                })
            } 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)
controllers/fileAnalysis.go
@@ -46,6 +46,12 @@
    Status int `json:"status" binding:"required"`
}
const (
    File_Img_Id_Pre = "img_"
    File_Video_Id_Pre = "video_"
    File_Audio_Id_Pre = "audio_"
)
// @Security ApiKeyAuth
// @Summary 开启或暂停文件分析
// @Description 开启或暂停文件分析
go.mod
@@ -3,7 +3,7 @@
go 1.12
require (
    basic.com/dbapi.git v0.0.0-20191204083757-c9635ae13e45 // indirect
    basic.com/dbapi.git v0.0.0-20191204094909-66f2832e579e // indirect
    basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb // indirect
    basic.com/gb28181api.git v0.0.0-20191028082253-472438a8407b // indirect
    basic.com/pubsub/cache.git v0.0.0-20190718093725-6a413e1d7d48 // indirect
go.sum
@@ -1,5 +1,5 @@
basic.com/dbapi.git v0.0.0-20191204083757-c9635ae13e45 h1:BCB7ieRjfAiSyfLImqo37FvJ9iV11gFuz6qAHUw2JfM=
basic.com/dbapi.git v0.0.0-20191204083757-c9635ae13e45/go.mod h1:eDXPnxaz6jZPDvBSk7ya7oSASWPCuUEgRTJCjsfKt/Q=
basic.com/dbapi.git v0.0.0-20191204094909-66f2832e579e h1:z4Q3H6oQVfme7w4IEuhaYeO3R5CcY9UR4bQiJmCqJqY=
basic.com/dbapi.git v0.0.0-20191204094909-66f2832e579e/go.mod h1:eDXPnxaz6jZPDvBSk7ya7oSASWPCuUEgRTJCjsfKt/Q=
basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb h1:fM6DojeInFSCFO+wkba1jtyPiSDqw0jYKi4Tk+e+ka4=
basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb/go.mod h1:FTryK8BsVLfUplx8a3+l8hJWub6VbAWZCUH7sPRZaso=
basic.com/gb28181api.git v0.0.0-20191028082253-472438a8407b h1:Qh7x2PY3HA9B404Llq+olY5/YlGYrM58bpOHa2CGcro=