| | |
| | | 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" |
| | |
| | | } |
| | | |
| | | 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 |
| | | } |
| | | } |