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,"更新失败") } }