package controllers import ( "basic.com/valib/bhomeclient.git" "strconv" "vamicro/stack-service/models" "vamicro/stack-service/service" ) type FileAnalysisSettingController struct { } // @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(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply { var model models.FileAnalysisSetting rows := model.Select() if rows >0 { return &bhomeclient.Reply{Success:true, Data:model} } else { return &bhomeclient.Reply{Msg:"查询失败"} } } type EnableSet struct { Enable bool `json:"enable"` } // @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(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply { var reqBody EnableSet c.BindJSON(&reqBody) sv := service.FileStackService{Bk: h.Bk} if sv.UpdateVideoEnable(reqBody.Enable) { return &bhomeclient.Reply{Success:true, Msg:"更新成功"} } else { return &bhomeclient.Reply{Msg:"更新失败"} } } // @Summary 切换本地文件分析开关 // @Description 切换本地文件分析开关 // @Accept json // @Produce json // @Tags 本地文件 // @Param channelCount query int 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/updateChannelCount [post] func (fsc FileAnalysisSettingController) UpdateChannelCount(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply { channelCountStr := c.PostForm("channelCount") channelCount, err := strconv.Atoi(channelCountStr) if err != nil || channelCount<0 { return &bhomeclient.Reply{Msg:"参数有误"} } sv := service.FileStackService{Bk: h.Bk} if sv.UpdateChannelCount(channelCount){ return &bhomeclient.Reply{Success:true, Msg:"更新成功"} } return &bhomeclient.Reply{Msg:"更新失败"} }