From 5569c9b0c2315f1115110a58ae6c3bbd1ddc483d Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期六, 06 七月 2019 18:08:15 +0800
Subject: [PATCH] fix bug
---
controllers/area.go | 42 +++++++++++++-----------------------------
1 files changed, 13 insertions(+), 29 deletions(-)
diff --git a/controllers/area.go b/controllers/area.go
index ae7cdbc..9825af2 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"`
}
@@ -42,9 +28,10 @@
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)
}
@@ -61,11 +48,8 @@
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,
@@ -90,14 +74,14 @@
// @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
}
@@ -126,13 +110,13 @@
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,"鍒犻櫎澶辫触")
--
Gitblit v1.8.0