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

---
 cameraPolygonRelationApi.go |   35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/cameraPolygonRelationApi.go b/cameraPolygonRelationApi.go
index 63e8a65..1879cfc 100644
--- a/cameraPolygonRelationApi.go
+++ b/cameraPolygonRelationApi.go
@@ -2,14 +2,13 @@
 
 import (
 	"basic.com/pubsub/protomsg.git"
-	json "github.com/json-iterator/go"
+	jsoniter "github.com/json-iterator/go"
 )
 
 type CameraPolygonRelationApi struct {
-
 }
 
-func (api CameraPolygonRelationApi) FindAll() (flag bool,list []protomsg.CameraPolygonRelation) {
+func (api CameraPolygonRelationApi) FindAll() (flag bool, list []protomsg.CameraPolygonRelation) {
 	url := DATA_URL_PREFIX + "/polygon/relation/findAll"
 	netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
 	client := NewClient(WithNodes(netNode))
@@ -20,9 +19,10 @@
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
 		logPrint("relations unmarshal err:", err)
-		return false,nil
+		return false, nil
 	}
 
 	bts, _ := json.Marshal(res.Data)
@@ -34,52 +34,55 @@
 	return true, list
 }
 
-func (api CameraPolygonRelationApi) Relations(paramBody map[string]interface{}) (bool,interface{}) {
+func (api CameraPolygonRelationApi) Relations(paramBody map[string]interface{}) (bool, interface{}) {
 	url := DATA_URL_PREFIX + "/polygon/relations"
 	netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
 	client := NewClient(WithNodes(netNode))
-	body, err := client.DoPostRequest(url,CONTENT_TYPE_JSON,paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
 	if err != nil {
-		return false,nil
+		return false, nil
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return false,nil
+		return false, nil
 	}
 	return res.Success, res.Data
 }
 
-func (api CameraPolygonRelationApi) SaveRelation(paramBody map[string]interface{}) (bool,interface{}) {
+func (api CameraPolygonRelationApi) SaveRelation(paramBody map[string]interface{}) (bool, interface{}) {
 	url := DATA_URL_PREFIX + "/polygon/relation/save"
 	netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
 	client := NewClient(WithNodes(netNode))
-	body, err := client.DoPostRequest(url,CONTENT_TYPE_JSON,paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
 	if err != nil {
-		return false,nil
+		return false, nil
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return false,nil
+		return false, nil
 	}
-	return res.Success,res.Data
+	return res.Success, res.Data
 }
 
 func (api CameraPolygonRelationApi) DelRelation(id string) bool {
 	url := DATA_URL_PREFIX + "/polygon/relation/del"
 	netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
 	client := NewClient(WithNodes(netNode))
-	paramMap := make(map[string]string,0)
+	paramMap := make(map[string]string, 0)
 	paramMap["id"] = id
-	body, err := client.DoDeleteRequest(url,CONTENT_TYPE_FORM,nil,paramMap)
+	body, err := client.DoDeleteRequest(url, CONTENT_TYPE_FORM, nil, paramMap)
 	if err != nil {
 		return false
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
 		return false
 	}
 	return res.Success
-}
\ No newline at end of file
+}

--
Gitblit v1.8.0