| | |
| | | "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"` |
| | | } |
| | | |
| | |
| | | parentIdStr := c.Query("parentid") |
| | | searchTypeStr := c.Query("searchType") |
| | | cameraName := c.Query("cameraName") |
| | | treeType := c.Query("type") |
| | | |
| | | var api dbapi.AreaApi |
| | | arr := api.GetLocalCameraTree(parentIdStr, searchTypeStr, cameraName) |
| | | arr := api.GetLocalCameraTree(parentIdStr, searchTypeStr, cameraName, treeType) |
| | | util.ResponseFormat(c, code.Success, arr) |
| | | } |
| | | |
| | |
| | | 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, |
| | |
| | | // @Failure 200 {string} json "{"code":"错误码", data:"出错信息",msg:"请求失败", success:false}" |
| | | // @Router /data/api-v/area/update [post] |
| | | func (ac AreaController) AreaUpdate(c *gin.Context) { |
| | | id,err := strconv.Atoi(c.PostForm("id")) |
| | | if err !=nil{ |
| | | id := c.PostForm("id") |
| | | if id == ""{ |
| | | util.ResponseFormat(c, code.RequestParamError, "参数错误") |
| | | return |
| | | } |
| | | name := c.PostForm("name") |
| | | parentId, err := strconv.Atoi(c.PostForm("parentId")) |
| | | if err !=nil { |
| | | parentId := c.PostForm("parentId") |
| | | if parentId == "" { |
| | | util.ResponseFormat(c, code.RequestParamError, "parentId参数错误") |
| | | return |
| | | } |
| | |
| | | func (ac AreaController) AreaDelete(c *gin.Context) { |
| | | var api dbapi.AreaApi |
| | | id := c.PostForm("id") |
| | | areaId, err := strconv.Atoi(id) |
| | | if err != nil { |
| | | |
| | | if id == "" { |
| | | util.ResponseFormat(c, code.ComError, "参数有误") |
| | | return |
| | | } |
| | | |
| | | if api.AreaDelete(areaId) { |
| | | if api.AreaDelete(id) { |
| | | util.ResponseFormat(c, code.DelSuccess, "删除成功") |
| | | } else { |
| | | util.ResponseFormat(c, code.ComError,"删除失败") |