liuxiaolong
2019-12-03 3704b2de230fd00ad6a71ffbbfadf0229194ec3c
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
package controllers
 
import (
    "basic.com/dbapi.git"
    "github.com/gin-gonic/gin"
    "webserver/extend/code"
    "webserver/extend/util"
)
 
type FileAnalysisSettingController struct {
 
}
 
 
func (fsc FileAnalysisSettingController) Show(c *gin.Context) {
    var api dbapi.FileAnalysisApi
    setting, err := api.GetFileAnalysisSet()
    if err == nil {
        util.ResponseFormat(c,code.Success, setting)
    } else {
        util.ResponseFormat(c,code.ComError, setting)
    }
}
 
type EnableSet struct {
    Enable bool     `json:"enable"`
}
 
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,"更新失败")
    }
}