package controllers
|
|
import (
|
"github.com/gin-gonic/gin"
|
"webserver/extend/code"
|
"webserver/extend/util"
|
"webserver/models"
|
"github.com/satori/go.uuid"
|
"strconv"
|
)
|
|
type SysSetController struct {
|
|
}
|
|
// @Summary 存储信息查询
|
// @Description 存储信息查询
|
// @Accept json
|
// @Produce json
|
// @Tags sysset
|
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
|
// @Failure 500 {string} json "{"code":500, msg:"返回错误信息", success:false}"
|
// @Router /data/api-v/sysset/alarmServerShow [GET]
|
func (sset SysSetController) AlarmServerShow(c *gin.Context){
|
config := new(models.LocalConfig)
|
if err := config.Select(); err != nil {
|
util.ResponseFormat(c, code.ServiceInsideError, config)
|
} else {
|
util.ResponseFormat(c, code.Success, config)
|
}
|
}
|
|
// @Summary 存储信息修改
|
// @Description 存储信息修改
|
// @Accept json
|
// @Produce json
|
// @Tags sysset
|
// @Param config body models.LocalConfig true "报警和存储信息数据"
|
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
|
// @Failure 500 {string} json "{"code":500, msg:"返回错误信息", success:false}"
|
// @Router /data/api-v/sysset/alarmEdit [POST]
|
func (sset SysSetController) AlarmEdit(c *gin.Context) {
|
config := new(models.LocalConfig) // 查询绑定
|
reqCon := new(models.LocalConfig) // 前台数据绑定
|
c.BindJSON(reqCon)
|
if err := config.Select(); err != nil { // 查询是否存在
|
util.ResponseFormat(c, code.ServiceInsideError, config)
|
} else {
|
copyColumnValueForAlarm(reqCon ,config) // 不印象其他值
|
reqCon.ID = config.ID // 修改必须有 id
|
if e := reqCon.Update(); e != nil {
|
util.ResponseFormat(c, code.ServiceInsideError, e.Error())
|
} else {
|
util.ResponseFormat(c, code.Success,reqCon)
|
}
|
}
|
}
|
|
|
// 本地 配置信息 复制
|
func copyColumnValueForAlarm(reqCon *models.LocalConfig,config *models.LocalConfig) {
|
reqCon.Dev_id = config.Dev_id
|
reqCon.Dev_name = config.Dev_name
|
reqCon.Cut_min_duration = config.Cut_min_duration
|
reqCon.Cut_max_duration = config.Cut_max_duration
|
reqCon.Dev_type = config.Dev_type
|
reqCon.Reserved = config.Reserved
|
}
|
|
// @Summary 存储信息修改
|
// @Description 存储信息修改
|
// @Accept json
|
// @Produce json
|
// @Tags sysset
|
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
|
// @Failure 500 {string} json "{"code":500, msg:"返回错误信息", success:false}"
|
// @Router /data/api-v/sysset/videoLenShow [GET]
|
func (sset SysSetController) VideoLenShow(c *gin.Context){
|
config := new(models.LocalConfig) // 前台数据绑定
|
if err := config.Select(); err != nil { // 查询是否存在
|
util.ResponseFormat(c, code.ServiceInsideError, config)
|
} else {
|
resData := make(map[string]int, 0)
|
resData["max_video_len"] = config.Cut_max_duration
|
resData["min_video_len"] = config.Cut_min_duration
|
// 存在则修改
|
util.ResponseFormat(c, code.Success, resData)
|
}
|
}
|
|
// @Summary 视频截取时长修改
|
// @Description 视频截取时长信息
|
// @Accept x-www-form-urlencoded
|
// @Produce json
|
// @Tags sysset
|
// @Param min_video_len query string true "视频截取最短时长"
|
// @Param max_video_len query string true "视频截取最长时长"
|
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
|
// @Failure 500 {string} json "{"code":500, msg:"返回错误信息", success:false}"
|
// @Router /data/api-v/sysset/videoLenEdit [POST]
|
func (sset SysSetController) VideoLenEdit(c *gin.Context) {
|
config := new(models.LocalConfig) // 前台数据绑定
|
|
/*min_video_len := c.Query("min_video_len") //查询请求URL后面的参数
|
max_video_len := c.PostForm("max_video_len") //从表单中查询参数*/
|
//POST和PUT主体参数优先于URL查询字符串值。
|
max_video_len := c.Request.FormValue("max_video_len")
|
min_video_len := c.Request.FormValue("min_video_len")
|
if err := config.Select(); err != nil { // 查询是否存在
|
util.ResponseFormat(c, code.ServiceInsideError, config)
|
} else {
|
max, _ := strconv.Atoi(max_video_len) // 数据 string 转 int8
|
min, _ := strconv.Atoi(min_video_len)
|
config.Cut_max_duration = max
|
config.Cut_min_duration = min
|
if e := config.Update(); e != nil {
|
util.ResponseFormat(c, code.ServiceInsideError, e.Error())
|
} else {
|
util.ResponseFormat(c, code.Success, config)
|
}
|
}
|
}
|
|
// @Summary 获取分析设备信息
|
// @Description 分析设备信息
|
// @Accept json
|
// @Produce json
|
// @Tags sysset
|
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
|
// @Failure 500 {string} json "{"code":500, msg:"返回错误信息", success:false}"
|
// @Router /data/api-v/sysset/getDevInfo [GET]
|
func (sset SysSetController) GetDevInfo(c *gin.Context) {
|
config := new(models.LocalConfig) // 前台数据绑定
|
resData := make(map[string]string, 0)
|
if err := config.Select(); err != nil { // 查询是否存在
|
util.ResponseFormat(c, code.ServiceInsideError,err.Error())
|
}else {
|
resData["dev_id"] = config.Dev_id
|
resData["dev_name"] = config.Dev_name
|
// 存在
|
util.ResponseFormat(c, code.Success, resData)
|
}
|
}
|
|
// saveDevInfo dev_id dev_name
|
// @Summary 保存视频分析设备信息
|
// @Description 分析设备信息
|
// @Accept x-www-form-urlencoded
|
// @Produce json
|
// @Tags sysset
|
// @Param dev_name query string true "分析设备名称"
|
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
|
// @Failure 500 {string} json "{"code":500, msg:"返回错误信息", success:false}"
|
// @Router /data/api-v/sysset/saveDevInfo [POST]
|
func (sset SysSetController) SaveDevInfo(c *gin.Context){
|
config := new(models.LocalConfig) // 前台数据绑定
|
dev_name := c.Request.FormValue("dev_name")
|
if err := config.Select(); err != nil { // 查询是否存在
|
util.ResponseFormat(c, code.ServiceInsideError,err.Error())
|
} else { // 存在及修改 不存在 即添加
|
config.Dev_name = dev_name
|
if config.Dev_id == "" {
|
config.Dev_id = uuid.NewV4().String()
|
}
|
if e := config.Update(); e != nil {
|
util.ResponseFormat(c, code.ServiceInsideError, e.Error())
|
} else {
|
util.ResponseFormat(c, code.Success, config)
|
}
|
|
}
|
}
|
|
|
// @Summary GB28181设置查询
|
// @Description GB28181设置信息查询
|
// @Accept json
|
// @Produce json
|
// @Tags sysset
|
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
|
// @Failure 500 {string} json "{"code":500, msg:"返回错误信息", success:false}"
|
// @Router /data/api-v/sysset/vSSLocalSettingShow [GET]
|
func (sset SysSetController) VSSLocalSettingShow(c *gin.Context) {
|
config := new(models.VSSLocalSettingTbl)
|
if err := config.Select(); err != nil {
|
util.ResponseFormat(c, code.ServiceInsideError, config)
|
} else {
|
if config == nil {
|
util.ResponseFormat(c, code.DdSelectNotFindError, config)
|
} else {
|
util.ResponseFormat(c, code.Success, config)
|
}
|
}
|
}
|
|
// @Summary GB28181设置信息修改
|
// @Description GB28181设置修改
|
// @Accept json
|
// @Produce json
|
// @Tags sysset
|
// @Param config body models.VSSLocalSettingTbl true "GB28181设置数据"
|
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
|
// @Failure 500 {string} json "{"code":500, msg:"返回错误信息", success:false}"
|
// @Router /data/api-v/sysset/vSSLocalSettingEdit [POST]
|
func (sset SysSetController) VSSLocalSettingEdit(c *gin.Context) {
|
config := new(models.VSSLocalSettingTbl) // 查询绑定
|
reqCon := new(models.VSSLocalSettingTbl) // 前台数据绑定
|
c.BindJSON(reqCon)
|
if err := config.Select(); err != nil { // 查询是否存在
|
util.ResponseFormat(c, code.ServiceInsideError, config)
|
} else {
|
{ // 存在则修改
|
reqCon.ID = config.ID
|
if e := reqCon.Update(); e != nil {
|
util.ResponseFormat(c, code.ServiceInsideError, e.Error())
|
} else {
|
util.ResponseFormat(c, code.Success, reqCon)
|
}
|
}
|
}
|
}
|