From 63e024e77d8e0fefd8818f1b744cbfc5e36b50fe Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期六, 14 十二月 2019 14:56:32 +0800 Subject: [PATCH] fix localconfig --- controllers/pollConfig.go | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-) diff --git a/controllers/pollConfig.go b/controllers/pollConfig.go index 8b4c52d..fd27211 100644 --- a/controllers/pollConfig.go +++ b/controllers/pollConfig.go @@ -78,16 +78,22 @@ // @Router /data/api-v/pollConfig/getPollConfig [get] func (controller PollConfigController) GetPollConfig(c *gin.Context) { var api dbapi.SysSetApi - b, data := api.GetPollConfig() + b, d := api.GetPollConfig() if b { - util.ResponseFormat(c, code.Success, data) + util.ResponseFormat(c, code.Success, map[string]interface{}{ + "server_id": d.ServerId, + "poll_period": d.PollPeriod, + "delay": d.Delay, + "enable": d.Enable, + "pollChannelCount": d.PollChannelCount, + }) } else { util.ResponseFormat(c, code.ComError, "鏌ヨ澶辫触") } } type PollEnableVo struct { - Enable bool `json:"enable"` + Enable bool `json:"enable" binding:"required"` } // @Security ApiKeyAuth @@ -116,9 +122,10 @@ type ChannelCountSet struct { PollChannelCount int `json:"pollChannelCount"` - FileChannelCount int `json:"fileChannelCount"` + VideoChannelCount int `json:"videoChannelCount"` } +// @Security ApiKeyAuth // @Summary 璁剧疆杞绠楀姏鍜屾湰鍦扮畻鍔涚殑鏁伴噺 // @Description 璁剧疆杞绠楀姏鍜屾湰鍦扮畻鍔涚殑鏁伴噺 // @Accept json @@ -130,9 +137,13 @@ // @Router /data/api-v/pollConfig/updateChannelCount [post] func (controller PollConfigController) UpdateChannelCount(c *gin.Context) { var argBody ChannelCountSet - c.BindJSON(&argBody) + err := c.BindJSON(&argBody) + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟鏈夎") + return + } var api dbapi.SysSetApi - if api.UpdateChannelCount(argBody.PollChannelCount, argBody.FileChannelCount) { + if api.UpdateChannelCount(argBody.PollChannelCount, argBody.VideoChannelCount) { util.ResponseFormat(c,code.UpdateSuccess,"鏇存柊鎴愬姛") } else { util.ResponseFormat(c,code.UpdateFail,"鏇存柊澶辫触") -- Gitblit v1.8.0