qixiaoning
2025-07-08 fe724b50b3f1b3dfe2219eb9af4bcca96c89a158
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
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:"更新失败"}
}