From 5c9ba220ac6640d9d1b1da97caa7aa3419441be3 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期一, 21 九月 2020 19:16:16 +0800
Subject: [PATCH] add app

---
 app.go |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/app.go b/app.go
new file mode 100644
index 0000000..d309ab0
--- /dev/null
+++ b/app.go
@@ -0,0 +1,41 @@
+package dbapi
+
+import (
+	"encoding/json"
+	"strconv"
+)
+
+type AppApi struct{
+	Ip string
+	Port int
+}
+
+func (api AppApi) 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 AppApi) FindAll(appName string) (flag bool, d interface{}) {
+	url := api.getBasicUrl() + DATA_URL_PREFIX + "/app/findAllApp"
+	client := NewClient()
+	paramMap := make(map[string]string, 0)
+	paramMap["appName"] = appName
+	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