From d8d991f239fb5e2fcb8ca134da6feb1758f6dade Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期六, 19 十月 2019 19:43:27 +0800
Subject: [PATCH] add ip config
---
syssetApi.go | 37 ++++++++++++++++++++++++++-----------
1 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/syssetApi.go b/syssetApi.go
index 93a561c..1f94681 100644
--- a/syssetApi.go
+++ b/syssetApi.go
@@ -4,14 +4,29 @@
"basic.com/pubsub/protomsg.git"
"encoding/json"
"fmt"
+ "strconv"
)
type SysSetApi struct {
+ Ip string
+ Port int
+}
+func (api SysSetApi) 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)
}
//鑾峰彇鏈嶅姟鍣ㄦ湰鏈洪厤缃俊鎭�
func (api SysSetApi) GetServerInfo() (flag bool,sysconf protomsg.LocalConfig){
- url := BASIC_URL + DATA_URL_PREFIX + "/sysset/getServerInfo"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/sysset/getServerInfo"
client := NewClient()
body, err := client.DoGetRequest(url, nil, nil)
@@ -38,7 +53,7 @@
}
//淇濆瓨杞閰嶇疆
func (api SysSetApi) SavePollPeriod(period int) (bool,interface{}){
- url := BASIC_URL + DATA_URL_PREFIX + "/pollConfig/savePollPeriod"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/pollConfig/savePollPeriod"
client := NewClient()
paramBody := make(map[string]interface{},0)
paramBody["period"] = period
@@ -57,7 +72,7 @@
}
func (api SysSetApi) SavePollDelay(delay int) (bool,interface{}){
- url := BASIC_URL + DATA_URL_PREFIX + "/pollConfig/savePollDelay"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/pollConfig/savePollDelay"
client := NewClient()
paramBody := make(map[string]interface{},0)
paramBody["delay"] = delay
@@ -77,7 +92,7 @@
//鑾峰彇杞閰嶇疆
func (api SysSetApi) GetPollConfig() (flag bool,config protomsg.PollConfig) {
- url := BASIC_URL + DATA_URL_PREFIX + "/pollConfig/getPollConfig"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/pollConfig/getPollConfig"
client := NewClient()
body, err := client.DoGetRequest(url, nil, nil)
@@ -105,7 +120,7 @@
//鍒囨崲杞鏄惁寮�鍚拰鍏抽棴
func (api SysSetApi) UpdatePollEnable(enable bool) bool{
- url := BASIC_URL + DATA_URL_PREFIX + "/pollConfig/updateEnable"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/pollConfig/updateEnable"
client := NewClient()
paramBody :=make(map[string]interface{},0)
paramBody["enable"] = enable
@@ -123,7 +138,7 @@
}
func (api SysSetApi) AlarmEdit(paramBody map[string]interface{}) (bool,interface{}){
- url := BASIC_URL + DATA_URL_PREFIX + "/sysset/alarmEdit"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/sysset/alarmEdit"
client := NewClient()
body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
if err != nil {
@@ -139,7 +154,7 @@
}
func (api SysSetApi) VideoLenShow() (bool,interface{}){
- url := BASIC_URL + DATA_URL_PREFIX + "/sysset/videoLenShow"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/sysset/videoLenShow"
client := NewClient()
body, err := client.DoGetRequest(url, nil, nil)
@@ -155,7 +170,7 @@
}
func (api SysSetApi) VideoLenEdit(maxVideoLen string,minVideoLen string) (bool,interface{}){
- url := BASIC_URL + DATA_URL_PREFIX + "/sysset/videoLenEdit"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/sysset/videoLenEdit"
client := NewClient()
paramBody :=make(map[string]interface{},0)
paramBody["max_video_len"] = maxVideoLen
@@ -174,7 +189,7 @@
}
func (api SysSetApi) SaveServerInfo(paramBody map[string]interface{}) (bool,interface{}){
- url := BASIC_URL + DATA_URL_PREFIX + "/sysset/saveServerInfo"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/sysset/saveServerInfo"
client := NewClient()
body,err := client.DoPostRequest(url,CONTENT_TYPE_FORM, paramBody,nil,nil)
if err != nil {
@@ -190,7 +205,7 @@
}
func (api SysSetApi) Gb28181ConfigShow() (bool,interface{}){
- url := BASIC_URL + DATA_URL_PREFIX + "/sysset/gb28181ConfigShow"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/sysset/gb28181ConfigShow"
client := NewClient()
body, err := client.DoGetRequest(url, nil, nil)
@@ -206,7 +221,7 @@
}
func (api SysSetApi) Gb28181ConfigEdit(paramBody map[string]interface{}) (bool,interface{}){
- url := BASIC_URL + DATA_URL_PREFIX + "/sysset/gb28181ConfigEdit"
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/sysset/gb28181ConfigEdit"
client := NewClient()
body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
if err != nil {
--
Gitblit v1.8.0