sunty
2020-08-20 9303b69ea569bcb5e581147543a3fd58e90d0d25
controllers/cameraTaskArgs.go
@@ -2,10 +2,11 @@
import (
   "basic.com/dbapi.git"
   "basic.com/valib/logger.git"
   "github.com/gin-gonic/gin"
   "strconv"
   "strings"
   "webserver/extend/code"
   "basic.com/valib/logger.git"
   "webserver/extend/util"
)
@@ -171,4 +172,37 @@
   } else {
      util.ResponseFormat(c,code.ComError,data)
   }
}
type RuleApply2AllVo struct {
   CameraId   string             `json:"camera_id" binding:"required"`//规则拥有者id
}
// @Summary 将本条规则应用到所有本地视频
// @Description 将本条规则应用到所有本地视频
// @Produce json
// @Tags CameraTaskArgs
// @Param args body controllers.RuleApply2AllVo true "规则应用到所有本地视频请求参数"
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
// @Router /data/api-v/cameraTaskArgs/ruleApply2All [post]
func (controller CameraTaskArgsController) RuleApply2All(c *gin.Context) {
   var saveBody RuleApply2AllVo
   err := c.BindJSON(&saveBody)
   if err !=nil {
      util.ResponseFormat(c, code.RequestParamError, "参数有误")
      return
   }
   if !strings.HasPrefix(saveBody.CameraId, File_Video_Id_Pre) && !strings.HasPrefix(saveBody.CameraId, File_Img_Id_Pre) && !!strings.HasPrefix(saveBody.CameraId, File_Audio_Id_Pre) {
      util.ResponseFormat(c, code.RequestParamError, "参数有误")
      return
   }
   var api dbapi.CameraTaskApi
   paramBody := util.Struct2Map(saveBody)
   flag, data := api.RuleApply2All(paramBody)
   if flag {
      util.ResponseFormat(c,code.Success,data)
   } else {
      util.ResponseFormat(c, code.ComError, data)
   }
}