From 3566c2630dc2ac33e03fb6df5ec2cd19e1625a68 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期五, 27 九月 2019 15:49:55 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.14:10010/r/webserver
---
controllers/area.go | 135 +++++++++++++++++++++++++++++++-------------
1 files changed, 94 insertions(+), 41 deletions(-)
diff --git a/controllers/area.go b/controllers/area.go
index 0b5ff28..c566987 100644
--- a/controllers/area.go
+++ b/controllers/area.go
@@ -5,28 +5,14 @@
"webserver/extend/code"
"webserver/extend/util"
"github.com/gin-gonic/gin"
- "strconv"
)
type AreaController struct {
}
-//type TreeMenu struct {
-// Id string `json:"id" `
-// Type string `json:"type"` // 濡傛灉涓嶆槸MENU锛屽尯鍒嗘湰鍦版憚鍍忔満锛堝垎鏋愬拰鐩戞帶锛変互鍙婂浗鏍囨憚鍍忔満
-// Name string `json:"name"`
-// Areanodes []TreeMenu `json:"children"`
-//}
-//
-//type TreeNode struct {
-// Id int
-// Name string
-// Parentid int
-//}
-
type AreaVo struct {
- Id int `json:"id"`
- ParentId int `json:"parentId"`
+ Id string `json:"id"`
+ ParentId string `json:"parentId"`
Name string `json:"name"`
}
@@ -34,7 +20,9 @@
// @Description 鏄剧ず宸︿晶鎵�鏈夊尯鍩熷拰鎽勫儚鏈�
// @Produce json
// @Tags menu
-// @Param parentid query int true "鍖哄煙鐨刬d"
+// @Param parentid query string true "鍖哄煙鐨刬d"
+// @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]
@@ -46,6 +34,64 @@
var api dbapi.AreaApi
arr := api.GetLocalCameraTree(parentIdStr, searchTypeStr, cameraName)
util.ResponseFormat(c, code.Success, arr)
+}
+
+// @Summary 鏄剧ずGb28181鏍戝舰缁撴瀯
+// @Description 鏄剧ずGb28181鏍戝舰缁撴瀯
+// @Produce json
+// @Tags menu
+// @Param parentid query string true "鍖哄煙鐨刬d"
+// @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)
+}
+
+// @Summary 鍒锋柊Gb28181骞冲彴鏍�
+// @Description 鍒锋柊Gb28181骞冲彴鏍�
+// @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":500, data:"",msg:"璇锋眰澶辫触", success:false}"
+// @Router /data/api-v/area/gb28181TreeRefresh [post]
+func (ac AreaController) Gb28181TreeRefresh(c *gin.Context) {
+ id := c.PostForm("id")
+ if id =="" {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟閿欒")
+ return
+ }
+ var api dbapi.AreaApi
+ if api.Gb28181TreeRefresh(id) {
+ util.ResponseFormat(c,code.UpdateSuccess,"鏇存柊鎴愬姛")
+ } else {
+ util.ResponseFormat(c,code.UpdateFail, "鏇存柊澶辫触")
+ }
+}
+
+// @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, "鍒犻櫎澶辫触")
+ }
}
// @Summary 娣诲姞menu鐨勫尯鍩�
@@ -61,20 +107,17 @@
var api dbapi.AreaApi
name := c.PostForm("name")
- parentId, err := strconv.Atoi(c.PostForm("parentId"))
- if err !=nil {
- util.ResponseFormat(c, code.RequestParamError, "parentId鍙傛暟閿欒")
- return
- }
+ parentId := c.PostForm("parentId")
+
var model = AreaVo{
Name:name,
ParentId:parentId,
}
paramBody := util.Struct2Map(model)
if api.AreaAdd(paramBody) {
- util.ResponseFormat(c,code.Success,"淇濆瓨鎴愬姛")
+ util.ResponseFormat(c,code.AddSuccess,"娣诲姞鎴愬姛")
} else {
- util.ResponseFormat(c,code.ComError,"淇濆瓨澶辫触")
+ util.ResponseFormat(c,code.ComError,"娣诲姞澶辫触")
}
}
@@ -83,23 +126,33 @@
// @Accept json
// @Produce json
// @Tags menu
-// @Param id path int true "鍖哄煙id"
-// @Param area body controllers.AreaVo true "鍖哄煙缁撴瀯"
+// @Param id query int true "鍖哄煙id"
+// @Param name query string true "鍖哄煙鍚嶅瓧"
+// @Param parentId query int 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/update/{id} [put]
+// @Router /data/api-v/area/update [post]
func (ac AreaController) AreaUpdate(c *gin.Context) {
- var api dbapi.AreaApi
- var model AreaVo
-
- if err := c.BindJSON(&model);err !=nil {
- util.ResponseFormat(c, code.ComError, "鍙傛暟鏈夎")
+ 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
+ }
+ var model = AreaVo{
+ Id:id,
+ ParentId:parentId,
+ Name:name,
+ }
paramBody := util.Struct2Map(model)
+ var api dbapi.AreaApi
if api.AreaUpdate(paramBody) {
- util.ResponseFormat(c,code.Success,"鏇存柊鎴愬姛")
+ util.ResponseFormat(c,code.UpdateSuccess,"鏇存柊鎴愬姛")
}else {
util.ResponseFormat(c,code.ComError,"鏇存柊澶辫触")
}
@@ -112,18 +165,18 @@
// @Param id query int 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 [get]
+// @Router /data/api-v/area/del [post]
func (ac AreaController) AreaDelete(c *gin.Context) {
var api dbapi.AreaApi
- id := c.Query("id")
- areaId, err := strconv.Atoi(id)
- if err != nil {
- util.ResponseFormat(c, code.ComError, "浼犲叆闈炴暣褰㈡棤娉曡В鏋�")
+ id := c.PostForm("id")
+
+ if id == "" {
+ util.ResponseFormat(c, code.ComError, "鍙傛暟鏈夎")
return
}
- if api.AreaDelete(areaId) {
- util.ResponseFormat(c, code.Success, "鍒犻櫎鎴愬姛")
+ if api.AreaDelete(id) {
+ util.ResponseFormat(c, code.DelSuccess, "鍒犻櫎鎴愬姛")
} else {
util.ResponseFormat(c, code.ComError,"鍒犻櫎澶辫触")
}
--
Gitblit v1.8.0