| | |
| | | |
| | | import ( |
| | | "basic.com/pubsub/protomsg.git" |
| | | json "github.com/json-iterator/go" |
| | | jsoniter "github.com/json-iterator/go" |
| | | ) |
| | | |
| | | type AppApi struct{ |
| | | |
| | | type AppApi struct { |
| | | } |
| | | type AppWithShop struct { |
| | | protomsg.App |
| | | RemoteVersion string `json:"remoteVersion"` //商城仓库版本号 |
| | | Installed bool `json:"installed"` //是否已安装 |
| | | IsUpgrade bool `json:"isUpgrade"` //是否需要升级 |
| | | ProgressMsg string `json:"progressMsg"` //安装或升级进度 |
| | | 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) { |
| | |
| | | paramMap["appName"] = appName |
| | | respBody, err := client.DoGetRequest(url, paramMap, nil) |
| | | logPrint("DoGetRequest err:", err) |
| | | if err !=nil { |
| | | if err != nil { |
| | | return nil |
| | | } |
| | | var res Result |
| | | var json = jsoniter.ConfigCompatibleWithStandardLibrary |
| | | if err = json.Unmarshal(respBody, &res); err != nil { |
| | | logPrint(err) |
| | | return nil |
| | |
| | | url := DATA_URL_PREFIX + "/app/save" |
| | | netNode := getNetNode(url2Topic(Topic_AppCenter_Service, url)) |
| | | client := NewClient(WithNodes(netNode)) |
| | | body, err := client.DoPostRequest(url,CONTENT_TYPE_JSON,paramBody,nil,nil) |
| | | body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil) |
| | | if err != nil { |
| | | return false |
| | | } |
| | | |
| | | var res Result |
| | | var json = jsoniter.ConfigCompatibleWithStandardLibrary |
| | | if err = json.Unmarshal(body, &res); err != nil { |
| | | return false |
| | | } |
| | |
| | | url := DATA_URL_PREFIX + "/app/getAppInfo" |
| | | netNode := getNetNode(url2Topic(Topic_AppCenter_Service, url)) |
| | | client := NewClient(WithNodes(netNode)) |
| | | paramMap := map[string]string { |
| | | paramMap := map[string]string{ |
| | | "id": id, |
| | | } |
| | | body, err := client.DoGetRequest(url,paramMap,nil) |
| | | body, err := client.DoGetRequest(url, paramMap, nil) |
| | | if err != nil { |
| | | return false, err.Error() |
| | | } |
| | | |
| | | var res Result |
| | | var json = jsoniter.ConfigCompatibleWithStandardLibrary |
| | | if err = json.Unmarshal(body, &res); err != nil { |
| | | return false, err.Error() |
| | | } |
| | | return res.Success, res.Data |
| | | } |
| | | |
| | | func (api AppApi) Delete(appId string) (bool,interface{}) { |
| | | func (api AppApi) Delete(appId string) (bool, interface{}) { |
| | | url := DATA_URL_PREFIX + "/app/delete" |
| | | netNode := getNetNode(url2Topic(Topic_AppCenter_Service, url)) |
| | | client := NewClient(WithNodes(netNode)) |
| | | paramBody := map[string]interface{} { |
| | | paramBody := map[string]interface{}{ |
| | | "appId": appId, |
| | | } |
| | | body, err := client.DoPostRequest(url,CONTENT_TYPE_JSON,paramBody,nil,nil) |
| | | body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil) |
| | | if err != nil { |
| | | return false, err.Error() |
| | | } |
| | | |
| | | var res Result |
| | | var json = jsoniter.ConfigCompatibleWithStandardLibrary |
| | | if err = json.Unmarshal(body, &res); err != nil { |
| | | return false, err.Error() |
| | | } |
| | |
| | | url := DATA_URL_PREFIX + "/sdk/sdkDownload" |
| | | netNode := getNetNode(url2Topic(Topic_AppCenter_Service, url)) |
| | | client := NewClient(WithNodes(netNode)) |
| | | paramMap := map[string]string { |
| | | paramMap := map[string]string{ |
| | | "path": id, |
| | | } |
| | | body, err := client.DoGetRequest(url,paramMap,nil) |
| | | body, err := client.DoGetRequest(url, paramMap, nil) |
| | | if err != nil { |
| | | return false, err.Error() |
| | | } |
| | | |
| | | var res Result |
| | | var json = jsoniter.ConfigCompatibleWithStandardLibrary |
| | | if err = json.Unmarshal(body, &res); err != nil { |
| | | return false, err.Error() |
| | | } |
| | |
| | | m := make(map[string]protomsg.App) |
| | | apps := api.FindAll("") |
| | | if apps != nil { |
| | | for _,a := range apps { |
| | | for _, a := range apps { |
| | | m[a.Package] = a |
| | | } |
| | | } |
| | |
| | | paramMap["appName"] = appName |
| | | respBody, err := client.DoGetRequest(url, paramMap, nil) |
| | | logPrint("DoGetRequest err:", err) |
| | | if err !=nil { |
| | | if err != nil { |
| | | return nil |
| | | } |
| | | var res Result |
| | | var json = jsoniter.ConfigCompatibleWithStandardLibrary |
| | | if err = json.Unmarshal(respBody, &res); err != nil { |
| | | logPrint(err) |
| | | return nil |
| | |
| | | logPrint("unmarshal err:", err) |
| | | return nil |
| | | } |
| | | } |
| | | } |