From 0213e81df2bcddb9ba59ba9a3d745992b2e4159e Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期三, 04 十二月 2019 13:42:47 +0800
Subject: [PATCH] add UpdateChannelCount

---
 soApi.go |   39 ++++++++++++++++++++-------------------
 1 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/soApi.go b/soApi.go
index 014bab6..fc888b5 100644
--- a/soApi.go
+++ b/soApi.go
@@ -4,13 +4,30 @@
 	"basic.com/pubsub/protomsg.git"
 	"encoding/json"
 	"fmt"
+	"strconv"
 )
 
-type SoApi struct {}
+type SoApi struct {
+	Ip string
+	Port int
+}
+
+func (api SoApi) 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)
+}
 
 //鑾峰彇鎵�鏈塻dkId涓巗oName鏄犲皠淇℃伅
 func (api SoApi) FindAll() (soInfos []protomsg.SoInfo) {
-	url := BASIC_URL + DATA_URL_PREFIX + "/soInfo/findAll"
+	url := api.getBasicUrl() + DATA_URL_PREFIX + "/so/findAll"
 	client := NewClient()
 
 	respBody, err := client.DoGetRequest(url, nil, nil)
@@ -28,7 +45,7 @@
 }
 
 func (api SoApi) Add(paramBody map[string]interface{}) (bool,interface{}) {
-	url := BASIC_URL + DATA_URL_PREFIX + "/soInfo/addSo"
+	url := api.getBasicUrl() + DATA_URL_PREFIX + "/so/addSo"
 	client := NewClient()
 	respBody, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
 	if err != nil {
@@ -37,22 +54,6 @@
 	var res Result
 	if err = json.Unmarshal(respBody, &res); err != nil {
 		fmt.Println(err)
-		return false,nil
-	}
-	return res.Success,res.Data
-}
-
-func (api SoApi) Delete(taskId string) (bool,interface{}){
-	url := BASIC_URL + DATA_URL_PREFIX + "/task/delete"
-	client := NewClient()
-	paramQuery :=make(map[string]string,0)
-	paramQuery["taskId"] = taskId
-	respBody, err := client.DoGetRequest(url, paramQuery, nil)
-	if err != nil {
-		return false,nil
-	}
-	var res Result
-	if err = json.Unmarshal(respBody, &res); err != nil {
 		return false,nil
 	}
 	return res.Success,res.Data

--
Gitblit v1.8.0