From d561b9eadc444bfffc5348e4178dd90006076e97 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期六, 17 十月 2020 16:53:05 +0800
Subject: [PATCH] add UpdateDriftState
---
areaApi.go | 39 ++++++++++++++++++++++++++++-----------
1 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/areaApi.go b/areaApi.go
index e1d10ca..80e0067 100644
--- a/areaApi.go
+++ b/areaApi.go
@@ -2,25 +2,41 @@
import (
"encoding/json"
- "fmt"
+ "strconv"
)
type AreaApi struct {
+ Ip string
+ Port int
+}
+
+func (api AreaApi) getBasicUrl() string {
+ if api.Ip == "" {
+ return BASIC_URL
+ }
+ if api.Ip == "" {
+ api.Ip = DEFAULT_IP
+ }
+ if api.Port == 0 {
+ api.Port = DEFAULT_PORT
+ }
+ return "http://"+api.Ip+":"+strconv.Itoa(api.Port)
}
//parentId 瑕佹煡瀵荤殑鐩綍鏍戠殑鏍硅妭鐐筰d
//searchType(0:鍏ㄩ儴锛�1:鍒嗘瀽鎽勫儚鏈�,2:鐩戞帶鎽勫儚鏈�)
//cameraName锛堟憚鍍忔満鍚嶇О锛�
-func (api AreaApi) GetLocalCameraTree(parentId string, searchType string, cameraName string) []TreeMenu {
+func (api AreaApi) GetLocalCameraTree(parentId string, searchType string, cameraName string, isPlatform int) []TreeMenu {
var result []TreeMenu
client := NewClient()
- url := BASIC_URL + DATA_URL_PREFIX + "/area/localmenu"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/area/localmenu"
params := make(map[string]string, 0)
params["parentId"] = parentId
params["searchType"] = searchType
params["cameraName"] = cameraName
+ params["isPlatform"] = strconv.Itoa(isPlatform)
respBody, err := client.DoGetRequest(url, params, nil)
if err != nil {
@@ -42,16 +58,17 @@
//parentId 瑕佹煡瀵荤殑鐩綍鏍戠殑鏍硅妭鐐筰d
//searchType(0:鍏ㄩ儴锛�1:鍒嗘瀽鎽勫儚鏈�,2:鐩戞帶鎽勫儚鏈�)
//cameraName锛堟憚鍍忔満鍚嶇О锛�
-func (api AreaApi) GetGb28181CameraTree(parentId string, searchType string, cameraName string) []TreeMenu {
+func (api AreaApi) GetGb28181CameraTree(parentId string, searchType string, cameraName string, isPlatform int) []TreeMenu {
var result []TreeMenu
client := NewClient()
- url := BASIC_URL + DATA_URL_PREFIX + "/area/gb28181Tree"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/area/gb28181Tree"
params := make(map[string]string, 0)
params["parentId"] = parentId
params["searchType"] = searchType
params["cameraName"] = cameraName
+ params["isPlatform"] = strconv.Itoa(isPlatform)
respBody, err := client.DoGetRequest(url, params, nil)
if err != nil {
@@ -72,7 +89,7 @@
func (api AreaApi) Gb28181TreeRefresh(id string) bool {
flag := false
- url := BASIC_URL + DATA_URL_PREFIX + "/area/gb28181TreeRefresh"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/area/gb28181TreeRefresh"
client := NewClient()
paramBody := map[string]interface{}{
"id":id,
@@ -91,7 +108,7 @@
func (api AreaApi) Gb28181TreeDelete() bool {
flag := false
- url := BASIC_URL + DATA_URL_PREFIX + "/area/gb28181TreeDelete"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/area/gb28181TreeDelete"
client := NewClient()
respBody, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, nil, nil, nil)
if err != nil {
@@ -108,7 +125,7 @@
//娣诲姞鐩綍鑺傜偣
func (api AreaApi) AreaAdd(paramBody map[string]interface{}) bool {
flag := false
- url := BASIC_URL + DATA_URL_PREFIX + "/area/add"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/area/add"
client := NewClient()
respBody, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, paramBody, nil, nil)
if err != nil {
@@ -125,7 +142,7 @@
//鐩綍鏇存柊
func (api AreaApi) AreaUpdate(paramBody map[string]interface{}) bool {
flag := false
- url := BASIC_URL + DATA_URL_PREFIX + "/area/update"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/area/update"
client := NewClient()
respBody, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, paramBody,nil, nil)
@@ -134,7 +151,7 @@
}
var res Result
if err = json.Unmarshal(respBody, &res); err != nil {
- fmt.Println(err)
+ logPrint(err)
return flag
}
flag = res.Success
@@ -147,7 +164,7 @@
if id == "" {
return flag
}
- url := BASIC_URL + DATA_URL_PREFIX + "/area/del"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/area/del"
client := NewClient()
paramBody := make(map[string]interface{}, 0)
paramBody["id"] = id
--
Gitblit v1.8.0