liuxiaolong
2019-09-18 711e90df27648aff82eda78d16dbbc159cceb625
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
package controllers
 
import (
    "basic.com/dbapi.git"
    "github.com/gin-gonic/gin"
    "webserver/extend/code"
    "webserver/extend/config"
    "webserver/extend/util"
)
 
type SysSetController struct {
 
}
 
type LocalConfigVo struct {
    Id string  `json:"id"`
    AlarmIp string `json:"alarm_ip,omitempty" example:"192.168.1.182"`
    AlarmPort int `json:"alarm_port,omitempty" example:"22122"`
    AlarmThresholdType int `json:"alarm_threshold_type"`//报警阈值类型设置:1:按最高分,2:按阈值以上
    AlarmThreshold int `json:"alarm_threshold"`//报警阈值
    WebPicIp string `json:"web_pic_ip,omitempty" example:""`
    WebPicPort int `json:"web_pic_port,omitempty" example:"22122"`
    EsPicIp string `json:"es_pic_ip,omitempty" example:""`
    EsPicPort  int `json:"es_pic_port,omitempty" example:"22122"`
    CutMaxDuration int `json:"cut_max_duration,omitempty" example:"20"`
    CutMinDuration int `json:"cut_min_duration,omitempty" example:"5"`
    ServerId string `json:"server_id,omitempty" example:"分析设备id"`
    ServerName string `json:"server_name,omitempty" example:"分析设备名称"`
    ServerType int `json:"server_type,omitempty" example:"1"`
    Reserved string `json:"reserved,omitempty" example:"1"`
    RealMax int `json:"real_max"`//实时处理的最大路数
}
 
type Gb28181ConfigVo struct {
    Id string `json:"Id"`
    ServerIp string `json:"ServerIp" example:"国标服务器IP"`
    ServerPort int `json:"ServerPort" example:"平台服务端口:7060"`
    PublicId string `json:"PublicId" example:"平台服务Id"`
    GbServerPort int `json:"GbServerPort" example:"国标服务端口:8060"`
    IsAuth bool `json:"IsAuth" example:"是否开启鉴权:true"`
    Password string `json:"Password" example:"密码"`
    UpdateTime string `json:"UpdateTime"`
}
 
// @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){
    var api dbapi.SysSetApi
    b, sysconf := api.GetServerInfo()
    if b{
        util.ResponseFormat(c,code.Success,sysconf)
    } else {
        util.ResponseFormat(c,code.ComError,"查询失败")
    }
}
 
// @Summary 存储信息修改
// @Description 存储信息修改
// @Accept  json
// @Produce json
// @Tags sysset
// @Param config body controllers.LocalConfigVo 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) {
    var args LocalConfigVo
    err := c.BindJSON(&args)
    if err !=nil {
        util.ResponseFormat(c,code.RequestParamError,"参数有误")
        return
    }
    var api dbapi.SysSetApi
    paramBody := util.Struct2Map(args)
    b,data := api.AlarmEdit(paramBody)
    if b {
        util.ResponseFormat(c,code.Success,data)
    }else {
        util.ResponseFormat(c,code.ComError,"保存失败")
    }
}
 
// @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){
    var api dbapi.SysSetApi
    b, sysconf := api.GetServerInfo()
    if b {
        resData := make(map[string]int32, 0)
        resData["max_video_len"] = sysconf.CutMaxDuration
        resData["min_video_len"] = sysconf.CutMinDuration
        // 存在则修改
        util.ResponseFormat(c, code.Success, resData)
    } else {
        util.ResponseFormat(c,code.ComError,"查询失败")
    }
}
 
// @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) {
    /*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")
    var api dbapi.SysSetApi
    b,data := api.VideoLenEdit(max_video_len,min_video_len)
    if b{
        util.ResponseFormat(c,code.UpdateSuccess,data)
    } else {
        util.ResponseFormat(c,code.ComError,"保存失败")
    }
}
 
// @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) {
    var api dbapi.SysSetApi
    b, sysconf := api.GetServerInfo()
    resData := make(map[string]string, 0)
    if !b { // 查询是否存在
        util.ResponseFormat(c, code.ServiceInsideError,"查询失败")
    }else {
        resData["server_id"] = sysconf.GetServerId()
        resData["server_name"] = sysconf.GetServerName()
        ipv4, mask, _ := util.GetLocalIP(config.Server.NetworkAdapter)
        gateway, _ := util.GetDefaultRoute(config.Server.NetworkAdapter)
        resData["ip"] = ipv4
        resData["subMask"] = mask
        resData["gateway"] = gateway
        // 存在
        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){
 
    dev_name := c.PostForm("server_name")
    var api dbapi.SysSetApi
    paramBody :=make(map[string]interface{},0)
    paramBody["serverName"] = dev_name
    b,data := api.SaveServerInfo(paramBody)
    if b { // 查询是否存在
        util.ResponseFormat(c,code.Success,data)
    } else {  // 存在及修改 不存在 即添加
        util.ResponseFormat(c,code.ComError,"保存失败")
    }
}
 
 
// @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/gb28181ConfigShow [GET]
func (sset SysSetController) Gb28181ConfigShow(c *gin.Context) {
    var api dbapi.SysSetApi
    b, data := api.Gb28181ConfigShow()
    if b {
        util.ResponseFormat(c,code.Success,data)
    } else {
        util.ResponseFormat(c,code.ComError,"查询失败")
    }
}
 
// @Summary GB28181设置信息修改
// @Description GB28181设置修改
// @Accept  json
// @Produce json
// @Tags sysset
// @Param config body controllers.Gb28181ConfigVo 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/gb28181ConfigEdit [POST]
func (sset SysSetController) Gb28181ConfigEdit(c *gin.Context) {
    var args Gb28181ConfigVo
    err := c.BindJSON(&args)
    if err !=nil {
        util.ResponseFormat(c,code.RequestParamError,"参数有误")
        return
    }
    var api dbapi.SysSetApi
    paramBody := util.Struct2Map(args)
    b, data := api.Gb28181ConfigEdit(paramBody)
    if b {
        util.ResponseFormat(c,code.UpdateSuccess,data)
    } else {
        util.ResponseFormat(c,code.ComError,"更新失败")
    }
}