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

---
 gb28181Api.go |  388 ++++++++++++++++++++++++++-----------------------------
 1 files changed, 183 insertions(+), 205 deletions(-)

diff --git a/gb28181Api.go b/gb28181Api.go
index 5e5e469..c43052f 100644
--- a/gb28181Api.go
+++ b/gb28181Api.go
@@ -2,34 +2,31 @@
 
 import (
 	"basic.com/pubsub/protomsg.git"
-	"encoding/json"
-	"errors"
+	jsoniter "github.com/json-iterator/go"
 	"strconv"
 )
 
-type Gb28181Api struct{
-
+type Gb28181Api struct {
 }
 
 //鍥芥爣閰嶇疆鏄剧ず
-func (api Gb28181Api) Show() (flag bool,gbConfig protomsg.Gb28181Config) {
+func (api Gb28181Api) Show() (flag bool, gbConfig protomsg.Gb28181Config) {
 	netNode := getNetNode(Topic_Gb28181_Service)
-	if netNode == nil {
-		return false, gbConfig
-	}
 	url := DATA_URL_PREFIX + "/gb28181/configShow"
 	client := NewClient(WithNodes(netNode))
 	respBody, err := client.DoGetRequest(url, nil, nil)
-	if err !=nil {
-		return false,gbConfig
+	if err != nil {
+		return false, gbConfig
 	}
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(respBody, &res); err != nil {
-		return false,gbConfig
+		return false, gbConfig
 	}
 	if res.Success {
-		if bts,err := json.Marshal(res.Data);err ==nil {
-			if err = json.Unmarshal(bts, &gbConfig);err ==nil {
+		if bts, err := json.Marshal(res.Data); err == nil {
+			var json = jsoniter.ConfigCompatibleWithStandardLibrary
+			if err = json.Unmarshal(bts, &gbConfig); err == nil {
 				return true, gbConfig
 			}
 		}
@@ -38,60 +35,54 @@
 }
 
 func (api Gb28181Api) Edit(paramBody map[string]interface{}) bool {
-	netNode := getNetNode(Topic_Gb28181_Service)
-	if netNode == nil {
-		return false
-	}
-	flag := false
 	url := DATA_URL_PREFIX + "/gb28181/configEdit"
+	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
+	flag := false
 	client := NewClient(WithNodes(netNode))
 	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
 	}
 	return res.Success
 }
 
-func (api Gb28181Api) FindAreaByParentId(parentId string) (bool,interface{}) {
-	netNode := getNetNode(Topic_Gb28181_Service)
-	if netNode == nil {
-		return false, nil
-	}
+func (api Gb28181Api) FindAreaByParentId(parentId string) (bool, interface{}) {
 	url := DATA_URL_PREFIX + "/gb28181/findAreaByParentId"
+	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
 	client := NewClient(WithNodes(netNode))
 	paramMap := make(map[string]string, 0)
 	paramMap["parentId"] = parentId
 	respBody, err := client.DoGetRequest(url, paramMap, nil)
-	if err !=nil {
-		return false,nil
+	if err != nil {
+		return false, nil
 	}
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(respBody, &res); err != nil {
-		return false,nil
+		return false, nil
 	}
 	return res.Success, res.Data
 }
 
-func (api Gb28181Api) NewGbId(code string) (bool,interface{}) {
-	netNode := getNetNode(Topic_Gb28181_Service)
-	if netNode == nil {
-		return false, nil
-	}
+func (api Gb28181Api) NewGbId(code string) (bool, interface{}) {
 	url := DATA_URL_PREFIX + "/gb28181/newGbId"
+	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
 	client := NewClient(WithNodes(netNode))
 	paramMap := make(map[string]string, 0)
 	paramMap["code"] = code
 	respBody, err := client.DoGetRequest(url, paramMap, nil)
-	if err !=nil {
-		return false,nil
+	if err != nil {
+		return false, nil
 	}
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(respBody, &res); err != nil {
-		return false,nil
+		return false, nil
 	}
 	return res.Success, res.Data
 }
@@ -100,15 +91,12 @@
 //searchType(0:鍏ㄩ儴锛�1:鍒嗘瀽鎽勫儚鏈�,2:鐩戞帶鎽勫儚鏈�)
 //cameraName锛堟憚鍍忔満鍚嶇О锛�
 func (api Gb28181Api) GetGb28181CameraTree(parentId string, searchType string, cameraName string) []TreeMenu {
-	netNode := getNetNode(Topic_Gb28181_Service)
-	if netNode == nil {
-		return nil
-	}
+	url := DATA_URL_PREFIX + "/gb28181/tree"
+	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
 	var result []TreeMenu
 
 	client := NewClient(WithNodes(netNode))
 
-	url := DATA_URL_PREFIX + "/gb28181/gb28181Tree"
 	params := make(map[string]string, 0)
 	params["parentId"] = parentId
 	params["searchType"] = searchType
@@ -120,12 +108,13 @@
 	}
 
 	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
@@ -133,21 +122,19 @@
 
 //鍥芥爣鏍戝埛鏂�
 func (api Gb28181Api) Gb28181TreeRefresh(id string) bool {
-	netNode := getNetNode(Topic_Gb28181_Service)
-	if netNode == nil {
-		return false
-	}
+	url := DATA_URL_PREFIX + "/gb28181/treeRefresh"
+	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
 	flag := false
-	url := DATA_URL_PREFIX + "/gb28181/gb28181TreeRefresh"
 	client := NewClient(WithNodes(netNode))
 	paramBody := map[string]interface{}{
-		"id":id,
+		"id": id,
 	}
 	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
 	}
@@ -157,18 +144,16 @@
 
 //鍥芥爣鏍戝垹闄�
 func (api Gb28181Api) Gb28181TreeDelete() bool {
-	netNode := getNetNode(Topic_Gb28181_Service)
-	if netNode == nil {
-		return false
-	}
+	url := DATA_URL_PREFIX + "/gb28181/treeDelete"
+	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
 	flag := false
-	url := DATA_URL_PREFIX + "/gb28181/gb28181TreeDelete"
 	client := NewClient(WithNodes(netNode))
 	respBody, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, nil, nil, nil)
 	if err != nil {
 		return flag
 	}
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(respBody, &res); err != nil {
 		return flag
 	}
@@ -177,85 +162,79 @@
 }
 
 //鑾峰彇鏈妭鐐圭殑鎵�鏈夊浗鏍囨憚鍍忔満
-func (api Gb28181Api) GetAllCamerasByServer(serverId string,cameraName string) (b bool,cams []protomsg.Camera) {
-	netNode := getNetNode(Topic_Gb28181_Service)
-	if netNode == nil {
-		return false,nil
-	}
+func (api Gb28181Api) GetAllCamerasByServer(serverId string, cameraName string) (b bool, cams []protomsg.Camera) {
 	url := DATA_URL_PREFIX + "/gb28181/getAllCamerasByServer"
+	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
 	client := NewClient(WithNodes(netNode))
-	paramQuery := make(map[string]string,0)
+	paramQuery := make(map[string]string, 0)
 	paramQuery["serverId"] = serverId
 	paramQuery["cameraName"] = cameraName
 	body, err := client.DoGetRequest(url, paramQuery, 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
 	}
 	dataBytes, _ := json.Marshal(res.Data)
-	if err := json.Unmarshal(dataBytes, &cams);err !=nil {
-		return false,nil
+	if err := json.Unmarshal(dataBytes, &cams); err != nil {
+		return false, nil
 	}
-	return res.Success,cams
+	return res.Success, cams
 }
 
 //鏌ユ壘鍦板浘涓婄殑鍥芥爣鎽勫儚鏈�
 func (api Gb28181Api) FindOnMap(isOnMap bool, floor int, cameraName string) (b bool, cams []protomsg.Camera) {
-	netNode := getNetNode(Topic_Gb28181_Service)
-	if netNode == nil {
-		return false,nil
-	}
-	url := DATA_URL_PREFIX + "/camera/findOnMap"
+	url := DATA_URL_PREFIX + "/gb28181/camera/findOnMap"
+	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
 	client := NewClient(WithNodes(netNode))
-	paramBody:= map[string]interface{}{
+	paramBody := map[string]interface{}{
 		"isOnMap":    isOnMap,
 		"floor":      floor,
 		"cameraName": cameraName,
 	}
-	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 {
 		logPrint(err)
-		return false,nil
+		return false, nil
 	}
 	if res.Success {
-		if bts, e := json.Marshal(res.Data);e == nil {
-			if e = json.Unmarshal(bts, &cams);e ==nil {
+		if bts, e := json.Marshal(res.Data); e == nil {
+			if e = json.Unmarshal(bts, &cams); e == nil {
 				return true, cams
 			}
 		}
 	}
-	return false,nil
+	return false, nil
 }
 
 //鏇存柊鎽勫儚鏈虹粡绾害浠ュ強妤煎眰
 func (api Gb28181Api) UpdatePos(id string, floor int, longitude float32, latitude float32) bool {
-	netNode := getNetNode(Topic_Gb28181_Service)
-	if netNode == nil {
-		return false
-	}
-	url := DATA_URL_PREFIX + "/camera/updatePos"
+	url := DATA_URL_PREFIX + "/gb28181/camera/updatePos"
+	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
 	client := NewClient(WithNodes(netNode))
-	paramBody:= map[string]interface{}{
-		"id":    id,
-		"floor":      floor,
+	paramBody := map[string]interface{}{
+		"id":        id,
+		"floor":     floor,
 		"longitude": longitude,
-		"latitude": latitude,
+		"latitude":  latitude,
 	}
-	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
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
 		logPrint(err)
 		return false
@@ -266,61 +245,55 @@
 
 //鏌ラ泦缇ゅ唴鎵�鏈夊浗鏍囨憚鍍忔満
 func (api Gb28181Api) NodeCamera() (bool, interface{}) {
-	netNode := getNetNode(Topic_Gb28181_Service)
-	if netNode == nil {
-		return false,nil
-	}
-	url := DATA_URL_PREFIX + "/camera/nodeCamera"
+	url := DATA_URL_PREFIX + "/gb28181/camera/nodeCamera"
+	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
 	client := NewClient(WithNodes(netNode))
 	body, err := client.DoGetRequest(url, 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
 }
 
 //閫氳繃id鑾峰彇鍥芥爣杩涚▼涓殑鎽勫儚鏈哄潗鏍囪缃�
 func (api Gb28181Api) Coord(cameraId string) (bool, interface{}) {
-	netNode := getNetNode(Topic_Gb28181_Service)
-	if netNode == nil {
-		return false,nil
-	}
-	url := DATA_URL_PREFIX + "/camera/coord"
+	url := DATA_URL_PREFIX + "/gb28181/camera/coord"
+	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
 	client := NewClient(WithNodes(netNode))
-	paramQuery := map[string]string {
+	paramQuery := map[string]string{
 		"cameraId": cameraId,
 	}
 	body, err := client.DoGetRequest(url, paramQuery, 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 Gb28181Api) UpdateCoord(paramBody map[string]interface{}) bool {
-	netNode := getNetNode(Topic_Gb28181_Service)
-	if netNode == nil {
-		return false
-	}
-	url := DATA_URL_PREFIX + "/camera/updateCoord"
+	url := DATA_URL_PREFIX + "/gb28181/camera/updateCoord"
+	netNode := getNetNode(url2Topic(Topic_Gb28181_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
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
 		logPrint(err)
 		return false
@@ -329,21 +302,17 @@
 	return res.Success
 }
 
-
-
 func (api Gb28181Api) CameraUpdate(paramBody map[string]interface{}) bool {
-	url := DATA_URL_PREFIX + "/camera/update"
+	url := DATA_URL_PREFIX + "/gb28181/camera/update"
 	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
-	if netNode == nil {
-		return false
-	}
 	client := NewClient(WithNodes(netNode))
-	body, err := client.DoPutRequest(url,CONTENT_TYPE_JSON,paramBody,nil)
+	body, err := client.DoPutRequest(url, CONTENT_TYPE_JSON, paramBody, nil)
 	if err != nil {
 		return false
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
 		return false
 	}
@@ -351,21 +320,19 @@
 }
 
 func (api Gb28181Api) UpdateSnapshotUrl(cameraId string, snapshot string) bool {
-	url := DATA_URL_PREFIX + "/camera/updateSnapshot"
+	url := DATA_URL_PREFIX + "/gb28181/camera/updateSnapshot"
 	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
-	if netNode == nil {
-		return false
-	}
 	client := NewClient(WithNodes(netNode))
-	paramBody :=make(map[string]interface{},0)
+	paramBody := make(map[string]interface{}, 0)
 	paramBody["snapshot"] = snapshot
 	paramBody["cameraId"] = cameraId
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_FORM, paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, paramBody, nil, nil)
 	if err != nil {
 		return false
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
 		logPrint(err)
 		return false
@@ -376,21 +343,21 @@
 
 //閫氳繃cameraId鑾峰彇鎽勫儚鏈轰俊鎭�
 func (api Gb28181Api) GetCameraById(cameraId string) (camera protomsg.Camera, err error) {
-	url := DATA_URL_PREFIX + "/camera/show"
+	url := DATA_URL_PREFIX + "/gb28181/camera/show"
 	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
-	if netNode == nil {
-		return camera,errors.New("gb28181-service not found")
-	}
 	client := NewClient(WithNodes(netNode))
-
-	body, err := client.DoGetRequest(url, nil, nil)
+	paramQuery := map[string]string{
+		"cid": cameraId,
+	}
+	body, err := client.DoGetRequest(url, paramQuery, nil)
 	if err != nil {
 		return camera, err
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
-		return camera,err
+		return camera, err
 	}
 
 	bytes, _ := json.Marshal(res.Data)
@@ -400,43 +367,45 @@
 }
 
 func (api Gb28181Api) UpdateCameraArea(cameraId string, areaId string) bool {
-	url := DATA_URL_PREFIX + "/camera/updateCameraArea"
+	url := DATA_URL_PREFIX + "/gb28181/camera/updateCameraArea"
 	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
-	if netNode == nil {
-		return false
-	}
 	client := NewClient(WithNodes(netNode))
-	paramBody := map[string]interface{} {
+	paramBody := map[string]interface{}{
 		"cameraId": cameraId,
-		"areaId": areaId,
+		"areaId":   areaId,
 	}
-	body, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, paramBody, nil,nil)
-	if err !=nil {
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, paramBody, nil, nil)
+	if err != nil {
 		return false
 	}
 
 	var res Result
-	if err = json.Unmarshal(body, &res);err != nil {
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
+	if err = json.Unmarshal(body, &res); err != nil {
 		return false
 	}
 
 	return res.Success
 }
 
-func (api Gb28181Api) FindAll() (cameras []protomsg.Camera) {
-	url := DATA_URL_PREFIX + "/camera/showAll"
+func (api Gb28181Api) FindAll(cameraName string, runType string, cameraId string, areaId string) (cameras []protomsg.Camera) {
+	url := DATA_URL_PREFIX + "/gb28181/camera/showAll"
 	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
-	if netNode == nil {
-		return nil
-	}
 	client := NewClient(WithNodes(netNode))
+	paramQuery := map[string]string{
+		"cameraName": cameraName,
+		"runType":    runType,
+		"cameraId":   cameraId,
+		"areaId":     areaId,
+	}
 
-	body, err := client.DoGetRequest(url, nil, nil)
+	body, err := client.DoGetRequest(url, paramQuery, nil)
 	if err != nil {
 		return nil
 	}
 
 	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
 	if err = json.Unmarshal(body, &res); err != nil {
 		logPrint(err)
 		return nil
@@ -450,126 +419,135 @@
 
 //鏍规嵁杩愯绫诲瀷鑾峰彇鎽勫儚鏈哄垪琛�
 //runType(0:鑾峰彇杞鍒楄〃锛�1锛氳幏鍙栧疄鏃跺垪琛�)
-func (api Gb28181Api) GetCamerasByRunType(runType int,cameraName string)(flag bool,cameras []protomsg.Camera){
-	url := DATA_URL_PREFIX + "/camera/getCamerasByRunType"
+func (api Gb28181Api) GetCamerasByRunType(runType int, cameraName string) (flag bool, cameras []protomsg.Camera) {
+	url := DATA_URL_PREFIX + "/gb28181/camera/getCamerasByRunType"
 	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
-	if netNode == nil {
-		return false,nil
-	}
 	client := NewClient(WithNodes(netNode))
-	paramQuery := make(map[string]string,2)
-	paramQuery["runType"]=strconv.Itoa(runType)
+	paramQuery := make(map[string]string, 2)
+	paramQuery["runType"] = strconv.Itoa(runType)
 	paramQuery["cameraName"] = cameraName
 	body, err := client.DoGetRequest(url, paramQuery, nil)
 	if err != nil {
-		return false,nil
-	}
-
-	var res Result
-	if err = json.Unmarshal(body, &res); err != nil {
-		return false,nil
-	}
-	b, err := json.Marshal(res.Data)
-	if err !=nil {
-		logPrint("unmarshal GetCamerasByRunType.result err")
-		return false,nil
-	}
-	if err = json.Unmarshal(b, &cameras);err !=nil {
-		return false,nil
-	} else {
-		return true,cameras
-	}
-}
-
-func (api Gb28181Api) UpdateRunEnable(cameraId string,runEnable bool) (bool,interface{}){
-	url := DATA_URL_PREFIX + "/camera/updateRunEnable"
-	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
-	if netNode == nil {
 		return false, nil
 	}
+
+	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
+	if err = json.Unmarshal(body, &res); err != nil {
+		return false, nil
+	}
+	b, err := json.Marshal(res.Data)
+	if err != nil {
+		logPrint("unmarshal GetCamerasByRunType.result err")
+		return false, nil
+	}
+	if err = json.Unmarshal(b, &cameras); err != nil {
+		return false, nil
+	} else {
+		return true, cameras
+	}
+}
+
+func (api Gb28181Api) UpdateRunEnable(cameraId string, runEnable bool) (bool, interface{}) {
+	url := DATA_URL_PREFIX + "/gb28181/camera/updateRunEnable"
+	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
 	client := NewClient(WithNodes(netNode))
-	paramBody :=make(map[string]interface{},0)
+	paramBody := make(map[string]interface{}, 0)
 	paramBody["cameraId"] = cameraId
 	paramBody["runEnable"] = runEnable
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_FORM, paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, 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 {
 		logPrint(err)
-		return false,nil
+		return false, nil
 	}
 
-	return res.Success,res.Data
+	return res.Success, res.Data
 }
 
-func (api Gb28181Api) UpdateIsRunningState(cameraId string,isRunning bool) (bool,interface{}){
-	url := DATA_URL_PREFIX + "/camera/updateIsRunningState"
+func (api Gb28181Api) UpdateIsRunningState(cameraId string, isRunning bool) (bool, interface{}) {
+	url := DATA_URL_PREFIX + "/gb28181/camera/updateIsRunningState"
 	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
-	if netNode == nil {
-		return false,nil
-	}
 	client := NewClient(WithNodes(netNode))
-	paramBody :=make(map[string]interface{},0)
+	paramBody := make(map[string]interface{}, 0)
 	paramBody["cameraId"] = cameraId
 	paramBody["isRunning"] = isRunning
-	body,err := client.DoPostRequest(url,CONTENT_TYPE_FORM, paramBody,nil,nil)
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, 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 {
 		logPrint(err)
-		return false,nil
+		return false, nil
 	}
 
-	return res.Success,res.Data
+	return res.Success, res.Data
 }
 
-func (api Gb28181Api) UpdateIsRunningAll(cameraIds []string) (bool,interface{}){
-	url := DATA_URL_PREFIX + "/camera/updateIsRunningAll"
+func (api Gb28181Api) UpdateIsRunningAll(cameraIds []string) (bool, interface{}) {
+	url := DATA_URL_PREFIX + "/gb28181/camera/updateIsRunningAll"
 	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
-	if netNode == nil {
-		return false,nil
-	}
 	client := NewClient(WithNodes(netNode))
-	paramBody :=make(map[string]interface{},0)
+	paramBody := make(map[string]interface{}, 0)
 	paramBody["cameraIds"] = cameraIds
-	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 {
 		logPrint(err)
-		return false,nil
+		return false, nil
 	}
 
-	return res.Success,res.Data
+	return res.Success, res.Data
 }
 
 //鎵归噺鍒囨崲鎽勫儚鏈鸿疆璇㈡垨瀹炴椂鐘舵��
-func (api Gb28181Api) ChangeRunType(paramBody map[string]interface{}) (bool,interface{}){
-	url := DATA_URL_PREFIX + "/camera/changeRunType"
+func (api Gb28181Api) ChangeRunType(paramBody map[string]interface{}) (bool, interface{}) {
+	url := DATA_URL_PREFIX + "/gb28181/camera/changeRunType"
 	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
-	if netNode == nil {
-		return false,nil
-	}
 	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 {
 		logPrint(err)
-		return false,nil
+		return false, nil
 	}
 
-	return res.Success,res.Data
-}
\ No newline at end of file
+	return res.Success, res.Data
+}
+
+func (api Gb28181Api) SaveNotExistOrUpdate(paramBody map[string]interface{}) bool {
+	url := DATA_URL_PREFIX + "/gb28181/saveNotExistOrUpdate"
+	netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
+	client := NewClient(WithNodes(netNode))
+	body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
+	if err != nil {
+		return false
+	}
+
+	var res Result
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
+	if err = json.Unmarshal(body, &res); err != nil {
+		logPrint(err)
+		return false
+	}
+
+	return res.Success
+}

--
Gitblit v1.8.0