From 418bc6e7c106326796e2abaf04a8a5066daa57ee Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期二, 31 八月 2021 14:33:08 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/valib/bhomedbapi

---
 userApi.go |    4 ++--
 appApi.go  |   35 +++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/appApi.go b/appApi.go
index 9bf868c..a4f690d 100644
--- a/appApi.go
+++ b/appApi.go
@@ -8,6 +8,13 @@
 type AppApi struct{
 
 }
+type AppWithShop struct {
+	protomsg.App
+	RemoteVersion 	string 		 `json:"remoteVersion"` 		//鍟嗗煄浠撳簱鐗堟湰鍙�
+	Installed 		bool 		 `json:"installed"`     		//鏄惁宸插畨瑁�
+	IsUpgrade 		bool 		 `json:"isUpgrade"`     		//鏄惁闇�瑕佸崌绾�
+	ProgressMsg 	string       `json:"progressMsg"` 			//瀹夎鎴栧崌绾ц繘搴�
+}
 
 func (api AppApi) FindAll(appName string) (list []protomsg.App) {
 	url := DATA_URL_PREFIX + "/app/findAllApp"
@@ -121,4 +128,32 @@
 	}
 
 	return m
+}
+
+//鑾峰彇甯﹀畨瑁呯姸鎬佺殑app鍒楄〃
+func (api AppApi) FindAppWithInstallStatus(appName string) (list []AppWithShop) {
+	url := DATA_URL_PREFIX + "/app/findAllApp"
+	netNode := getNetNode(url2Topic(Topic_AppCenter_Service, url))
+	logPrint("netNode:", netNode)
+	client := NewClient(WithNodes(netNode))
+	paramMap := make(map[string]string, 0)
+	paramMap["appName"] = appName
+	respBody, err := client.DoGetRequest(url, paramMap, nil)
+	logPrint("DoGetRequest err:", err)
+	if err !=nil {
+		return nil
+	}
+	var res Result
+	if err = json.Unmarshal(respBody, &res); err != nil {
+		logPrint(err)
+		return nil
+	}
+	bytes, _ := json.Marshal(res.Data)
+	err = json.Unmarshal(bytes, &list)
+	if err == nil {
+		return list
+	} else {
+		logPrint("unmarshal err:", err)
+		return nil
+	}
 }
\ No newline at end of file
diff --git a/userApi.go b/userApi.go
index 0dbd4a7..f97f2a5 100644
--- a/userApi.go
+++ b/userApi.go
@@ -9,13 +9,13 @@
 }
 
 func (api UserApi) Login(username string,password string) (bool,interface{}){
-	url := DATA_URL_PREFIX + "/user/login"
+	url := "/data/api-u/sys/login"
 	netNode := getNetNode(url2Topic(Topic_System_Service, url))
 	client := NewClient(WithNodes(netNode))
 	paramBody :=make(map[string]interface{},0)
 	paramBody["username"]=username
 	paramBody["password"]=password
-	respBody, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody,nil, nil)
+	respBody, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, paramBody,nil, nil)
 	if err != nil {
 		return false,nil
 	}

--
Gitblit v1.8.0