From 01dfd9dc8de7b19f9dfa4284722e01bbd5837801 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期五, 19 一月 2024 09:10:30 +0800
Subject: [PATCH] replace json to json-iterator

---
 areaApi.go |   26 ++++++++------------------
 1 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/areaApi.go b/areaApi.go
index b61b18d..9c7c043 100644
--- a/areaApi.go
+++ b/areaApi.go
@@ -1,11 +1,10 @@
 package bhomedbapi
 
 import (
-	"encoding/json"
+	jsoniter "github.com/json-iterator/go"
 )
 
 type AreaApi struct {
-
 }
 
 //parentId 瑕佹煡瀵荤殑鐩綍鏍戠殑鏍硅妭鐐筰d
@@ -14,9 +13,6 @@
 func (api AreaApi) GetLocalCameraTree(parentId string, searchType string, cameraName string) []TreeMenu {
 	url := DATA_URL_PREFIX + "/area/localmenu"
 	netNode := getNetNode(url2Topic(Topic_Camera_Service, url))
-	if netNode == nil {
-		return nil
-	}
 	var result []TreeMenu
 
 	client := NewClient(WithNodes(netNode))
@@ -32,25 +28,22 @@
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(respBody, &res); err != nil {
 		return nil
 	}
 
 	bytes, _ := json.Marshal(res.Data)
-	if err = json.Unmarshal(bytes, &result);err !=nil{
+	if err = json.Unmarshal(bytes, &result); err != nil {
 		return nil
 	}
 	return result
 }
 
-
 //娣诲姞鐩綍鑺傜偣
 func (api AreaApi) AreaAdd(paramBody map[string]interface{}) bool {
 	url := DATA_URL_PREFIX + "/area/add"
 	netNode := getNetNode(url2Topic(Topic_Camera_Service, url))
-	if netNode == nil {
-		return false
-	}
 	flag := false
 	client := NewClient(WithNodes(netNode))
 	respBody, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, paramBody, nil, nil)
@@ -58,6 +51,7 @@
 		return flag
 	}
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(respBody, &res); err != nil {
 		return flag
 	}
@@ -69,17 +63,15 @@
 func (api AreaApi) AreaUpdate(paramBody map[string]interface{}) bool {
 	url := DATA_URL_PREFIX + "/area/update"
 	netNode := getNetNode(url2Topic(Topic_Camera_Service, url))
-	if netNode == nil {
-		return false
-	}
 	flag := false
 	client := NewClient(WithNodes(netNode))
 
-	respBody, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, paramBody,nil, nil)
+	respBody, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, paramBody, nil, nil)
 	if err != nil {
 		return flag
 	}
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(respBody, &res); err != nil {
 		logPrint(err)
 		return flag
@@ -92,9 +84,6 @@
 func (api AreaApi) AreaDelete(id string) bool {
 	url := DATA_URL_PREFIX + "/area/del"
 	netNode := getNetNode(url2Topic(Topic_Camera_Service, url))
-	if netNode == nil {
-		return false
-	}
 	flag := false
 	if id == "" {
 		return flag
@@ -102,11 +91,12 @@
 	client := NewClient(WithNodes(netNode))
 	paramBody := make(map[string]interface{}, 0)
 	paramBody["id"] = id
-	respBody, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, paramBody,nil, nil)
+	respBody, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, paramBody, nil, nil)
 	if err != nil {
 		return flag
 	}
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(respBody, &res); err != nil {
 		return flag
 	}

--
Gitblit v1.8.0