554325746@qq.com
2020-06-02 abf8ec9aabce434794c9b001e37c3e1966f8e889
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
package controllers
 
import (
    "basic.com/dbapi.git"
    "webserver/extend/code"
    "webserver/extend/util"
    "github.com/gin-gonic/gin"
)
 
type AreaController struct {
}
 
type AreaVo struct {
    Id string `json:"id"`
    ParentId string `json:"parentId"`
    Name string `json:"name"`
    Alias string `json:"alias"`
}
 
// @Summary 显示树形结构
// @Description 显示左侧所有区域和摄像机
// @Security ApiKeyAuth
// @Produce json
// @Tags menu
// @Param parentid query string true "区域的id"
// @Param searchType query int true "查询类型(0:全部,1:分析摄像机,2:监控摄像机)"
// @Param cameraName query string false "摄像机名称"
// @Success 200 {string} json "{"code":200, msg:"目录结构数据"}"
// @Failure 500 {string} json "{"code":500,  msg:"返回错误信息"}"
// @Router /data/api-v/area/localmenu [get]
func (ac AreaController) CameraTree(c *gin.Context) {
    parentIdStr := c.Query("parentid")
    searchTypeStr := c.Query("searchType")
    cameraName := c.Query("cameraName")
 
    var api dbapi.AreaApi
    arr := api.GetLocalCameraTree(parentIdStr, searchTypeStr, cameraName)
    util.ResponseFormat(c, code.Success, arr)
}
 
// @Summary 显示Gb28181树形结构
// @Description 显示Gb28181树形结构
// @Security ApiKeyAuth
// @Produce json
// @Tags menu
// @Param parentid query string true "区域的id"
// @Param searchType query int true "查询类型(0:全部,1:分析摄像机,2:监控摄像机)"
// @Param cameraName query string false "摄像机名称"
// @Success 200 {string} json "{"code":200, msg:"目录结构数据"}"
// @Failure 500 {string} json "{"code":500,  msg:"返回错误信息"}"
// @Router /data/api-v/area/gb28181Tree [get]
func (ac AreaController) CameraGb28181Tree(c *gin.Context) {
    parentIdStr := c.Query("parentid")
    searchTypeStr := c.Query("searchType")
    cameraName := c.Query("cameraName")
 
    var api dbapi.AreaApi
    arr := api.GetGb28181CameraTree(parentIdStr, searchTypeStr, cameraName)
    util.ResponseFormat(c, code.Success, arr)
}
 
// @Security ApiKeyAuth
// @Accept x-www-form-urlencoded
// @Summary 刷新Gb28181平台树
// @Description 刷新Gb28181平台树
// @Produce json
// @Tags menu
// @Param id formData string false "国标平台id"
// @Success 200 {string} json "{"code":200, data:"",msg:"请求成功", success:true}"
// @Failure 200 {string} json "{"code":500, data:"",msg:"请求失败", success:false}"
// @Router /data/api-v/area/gb28181TreeRefresh [post]
func (ac AreaController) Gb28181TreeRefresh(c *gin.Context) {
    id := c.PostForm("id")
 
    var api dbapi.AreaApi
    if api.Gb28181TreeRefresh(id) {
        util.ResponseFormat(c,code.UpdateSuccess,"更新成功")
    } else {
        util.ResponseFormat(c,code.UpdateFail, "更新失败")
    }
}
 
// @Security ApiKeyAuth
// @Summary 删除Gb28181平台
// @Description 删除Gb28181平台
// @Produce json
// @Tags menu
// @Success 200 {string} json "{"code":200, data:"",msg:"请求成功", success:true}"
// @Failure 200 {string} json "{"code":500, data:"",msg:"请求失败", success:false}"
// @Router /data/api-v/area/gb28181TreeDelete [post]
func (ac AreaController) Gb28181TreeDelete(c *gin.Context) {
    var api dbapi.AreaApi
    if api.Gb28181TreeDelete() {
        util.ResponseFormat(c,code.DelSuccess,"删除成功")
    } else {
        util.ResponseFormat(c,code.ComError, "删除失败")
    }
}
 
// @Security ApiKeyAuth
// @Summary 添加menu的区域
// @Description 添加目录上区域
// @Accept x-www-form-urlencoded
// @Produce json
// @Tags menu
// @Param name formData string true "区域名字"
// @Param parentId formData string true "上一级父id"
// @Success 200 {string} json "{"code":200, data:"添加的区域信息",msg:"请求成功", success:true}"
// @Failure 200 {string} json "{"code":"错误码", data:"出错信息",msg:"请求失败", success:false}"
// @Router /data/api-v/area/add [post]
func (ac AreaController) AreaAdd(c *gin.Context) {
    var api dbapi.AreaApi
 
    name := c.PostForm("name")
    parentId := c.PostForm("parentId")
 
    var model = AreaVo{
        Name:name,
        ParentId:parentId,
    }
    paramBody := util.Struct2Map(model)
    if api.AreaAdd(paramBody) {
        util.ResponseFormat(c,code.AddSuccess,"添加成功")
    } else {
        util.ResponseFormat(c,code.ComError,"添加失败")
    }
}
 
// @Security ApiKeyAuth
// @Summary 修改名字
// @Description 修改区域名字
// @Accept x-www-form-urlencoded
// @Produce json
// @Tags menu
// @Param id formData string true "区域id"
// @Param name formData string true "区域名字"
// @Param parentId formData string true "上一级父id"
// @Param alias formData string false "备注名称"
// @Success 200 {string} json "{"code":200, data:"",msg:"请求成功", success:true}"
// @Failure 200 {string} json "{"code":"错误码", data:"出错信息",msg:"请求失败", success:false}"
// @Router /data/api-v/area/update [post]
func (ac AreaController) AreaUpdate(c *gin.Context) {
    id := c.PostForm("id")
    if id == ""{
        util.ResponseFormat(c, code.RequestParamError, "参数错误")
        return
    }
    name := c.PostForm("name")
    parentId := c.PostForm("parentId")
    if parentId == "" {
        util.ResponseFormat(c, code.RequestParamError, "parentId参数错误")
        return
    }
    alias := c.PostForm("alias")
    var model = AreaVo{
        Id:id,
        ParentId:parentId,
        Name:name,
        Alias: alias,
    }
    paramBody := util.Struct2Map(model)
    var api dbapi.AreaApi
    if api.AreaUpdate(paramBody) {
        util.ResponseFormat(c,code.UpdateSuccess,"更新成功")
    }else {
        util.ResponseFormat(c,code.ComError,"更新失败")
    }
}
 
// @Security ApiKeyAuth
// @Summary 删除一个区域
// @Description 点击删除按钮时删除一个区域
// @Accept x-www-form-urlencoded
// @Produce json
// @Tags menu
// @Param id formData string true "当前id"
// @Success 200 {string} json "{"code":200, data:"删除的区域信息",msg:"请求成功", success:true}"
// @Failure 200 {string} json "{"code":"错误码", data:"出错信息",msg:"请求失败", success:false}"
// @Router /data/api-v/area/del [post]
func (ac AreaController) AreaDelete(c *gin.Context) {
    var api dbapi.AreaApi
    id := c.PostForm("id")
 
    if id == "" {
        util.ResponseFormat(c, code.ComError, "参数有误")
        return
    }
 
    if api.AreaDelete(id) {
        util.ResponseFormat(c, code.DelSuccess, "删除成功")
    } else {
        util.ResponseFormat(c, code.ComError,"删除失败")
    }
 
}