|
@@ -80,6 +80,16 @@ func ChartThemeTypeSaveLib(req string) (resp *models.BaseResponse, err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// GetUserChartListLib 查询有权限的图表列表
|
|
|
|
+func GetUserChartListLib(req string) (resp *UserChartListResp, err error) {
|
|
|
|
+ _, resultByte, err := get(req, "/v1/chart/theme/type/save")
|
|
|
|
+ err = json.Unmarshal(resultByte, &resp)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
// post
|
|
// post
|
|
func post(paramStr string, urlStr string) (resp *models.BaseResponse, result []byte, err error) {
|
|
func post(paramStr string, urlStr string) (resp *models.BaseResponse, result []byte, err error) {
|
|
if utils.ETA_FORUM_HUB_URL == "" {
|
|
if utils.ETA_FORUM_HUB_URL == "" {
|
|
@@ -122,3 +132,41 @@ func HttpPost(url, postData string, params ...string) ([]byte, error) {
|
|
utils.FileLog.Debug("HttpPost:" + string(b))
|
|
utils.FileLog.Debug("HttpPost:" + string(b))
|
|
return b, err
|
|
return b, err
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// get
|
|
|
|
+func get(paramStr string, urlStr string) (resp *models.BaseResponse, result []byte, err error) {
|
|
|
|
+ if utils.ETA_FORUM_HUB_URL == "" {
|
|
|
|
+ err = fmt.Errorf("ETA社区桥接服务地址为空")
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ urlStr = urlStr + "?" + paramStr
|
|
|
|
+ getUrl := utils.ETA_FORUM_HUB_URL + urlStr
|
|
|
|
+ result, err = HttpGet(getUrl)
|
|
|
|
+ if err != nil {
|
|
|
|
+ err = fmt.Errorf("调用ETA社区桥接服务接口失败 error:%s", err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ err = json.Unmarshal(result, &resp)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func HttpGet(url string) ([]byte, error) {
|
|
|
|
+ client := &http.Client{}
|
|
|
|
+ req, err := http.NewRequest("GET", url, nil)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return nil, err
|
|
|
|
+ }
|
|
|
|
+ req.Header.Set("authorization", utils.MD5(utils.ETA_FORUM_HUB_NAME_EN+utils.ETA_FORUM_HUB_MD5_KEY))
|
|
|
|
+ resp, err := client.Do(req)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return nil, err
|
|
|
|
+ }
|
|
|
|
+ defer resp.Body.Close()
|
|
|
|
+ b, err := ioutil.ReadAll(resp.Body)
|
|
|
|
+ utils.FileLog.Debug("HttpPost:" + string(b))
|
|
|
|
+ return b, err
|
|
|
|
+}
|