liuxiaolong
2020-06-08 2a4041f16c6588921c87df93927e9076c2cc309d
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
package controllers
 
import (
    "basic.com/dbapi.git"
    "github.com/gin-gonic/gin"
    "webserver/extend/code"
    "webserver/extend/util"
)
 
type FileAnalysisSettingController struct {
 
}
 
// @Security ApiKeyAuth
// @Summary 获取本地文件开关设置
// @Description 获取本地文件开关设置
// @Produce json
// @Tags 本地文件
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
// @Router /data/api-v/fileSetting/show [get]
func (fsc FileAnalysisSettingController) Show(c *gin.Context) {
    var api dbapi.FileAnalysisApi
    setting, err := api.GetFileAnalysisSet()
    if err == nil {
        util.ResponseFormat(c,code.Success, map[string]interface{}{
            "videoEnable": setting.VideoEnable,
            "fileDirectory": setting.FileDirectory,
            "videoChannelCount": setting.VideoChannelCount,
            "imgChannelCount": setting.ImgChannelCount,
            "audioChannelCount": setting.AudioChannelCount,
        })
    } else {
        util.ResponseFormat(c,code.ComError, setting)
    }
}
 
type EnableSet struct {
    Enable bool     `json:"enable"`
}
 
// @Security ApiKeyAuth
// @Summary 切换本地文件分析开关
// @Description 切换本地文件分析开关
// @Accept json
// @Produce json
// @Tags 本地文件
// @Param reqBody body controllers.EnableSet 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/fileSetting/changeEnable [post]
func (fsc FileAnalysisSettingController) ChangeEnable(c *gin.Context) {
    var reqBody EnableSet
    c.BindJSON(&reqBody)
    var api dbapi.FileAnalysisApi
    if api.ChangeEnable(reqBody.Enable) {
        util.ResponseFormat(c,code.UpdateSuccess,"更新成功")
    } else {
        util.ResponseFormat(c,code.UpdateFail,"更新失败")
    }
}