From aeeadc95e1b1218a85f3b48da8dc5b4b57aeb219 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期一, 24 五月 2021 18:43:02 +0800
Subject: [PATCH] add GetVssChannel
---
dicApi.go | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/dicApi.go b/dicApi.go
index ddff79b..8b697d8 100644
--- a/dicApi.go
+++ b/dicApi.go
@@ -1 +1,58 @@
package dbapi
+
+import (
+ "encoding/json"
+ "strconv"
+)
+
+type DicApi struct {
+ Ip string
+ Port int
+}
+
+func (api DicApi) 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 DicApi) FindByType(dicType string) (bool,interface{}) {
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dictionary/findByType"
+ client := NewClient()
+ paramMap := make(map[string]string)
+ paramMap["type"] = dicType
+ respBody, err := client.DoGetRequest(url, paramMap, nil)
+ if err !=nil {
+ return false,nil
+ }
+ var res Result
+ if err = json.Unmarshal(respBody, &res); err != nil {
+ logPrint(err)
+ return false,nil
+ }
+ return res.Success,res.Data
+}
+
+func (api DicApi) FindByParentId(parentId string) (bool,interface{}){
+ url := api.getBasicUrl() + DATA_URL_PREFIX + "/dictionary/findByParentId"
+ client := NewClient()
+ paramMap := make(map[string]string)
+ paramMap["parentId"] = parentId
+ respBody, err := client.DoGetRequest(url, paramMap, nil)
+ if err !=nil {
+ return false,nil
+ }
+ var res Result
+ if err = json.Unmarshal(respBody, &res); err != nil {
+ logPrint(err)
+ return false,nil
+ }
+ return res.Success,res.Data
+}
\ No newline at end of file
--
Gitblit v1.8.0