59 lines
2.0 KiB
Go
59 lines
2.0 KiB
Go
|
package httpcall
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"encoding/json"
|
||
|
"errors"
|
||
|
"finclip-app-manager/infrastructure/config"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
type GetAppTagConfigRsp struct {
|
||
|
Data MopPrivateConfigData `json:"data"`
|
||
|
Errcode string `json:"errcode"`
|
||
|
Error string `json:"error"`
|
||
|
}
|
||
|
|
||
|
type MopPrivateConfigData struct {
|
||
|
Id string `json:"id" bson:"_id"`
|
||
|
PlatformName string `json:"platformName"` //平台名称
|
||
|
BackstageLogoUrl string `json:"backstageLogoUrl"` //后台logo
|
||
|
IndexWithPic string `json:"indexWithPic"` //登陆与注册页面
|
||
|
CopyrightNotice string `json:"copyrightNotice"` //版权提示
|
||
|
AppClass []CModel `json:"appClass"` //小程序分类
|
||
|
AppTag []CModel `json:"appTag"` //小程序标签
|
||
|
CreateTime int64 `json:"createTime" bson:"createTime"` //创建时间
|
||
|
UpdateTime int64 `json:"updateTime" bson:"updateTime"` //更新时间
|
||
|
Cas int64 `json:"cas" bson:"cas"` //防冲突
|
||
|
AppDowanloadLink string `json:"appDowanloadLink"` //app下载链接
|
||
|
}
|
||
|
|
||
|
type CModel struct {
|
||
|
Key string `json:"key"`
|
||
|
Name string `json:"name"`
|
||
|
}
|
||
|
|
||
|
func (c *Client) GetAppTagConfigInfo(ctx context.Context) (*GetAppTagConfigRsp, error) {
|
||
|
var headers = map[string]string{
|
||
|
"Accept": "application/json, text/plain, */*",
|
||
|
"Content-Type": "application/json",
|
||
|
}
|
||
|
url := fmt.Sprintf(config.GetConfig().ConfigManagerHost + config.GetConfig().GetAppTagConfigUrl)
|
||
|
|
||
|
rspInfo := GetAppTagConfigRsp{}
|
||
|
|
||
|
rsp, err := c.Request(ctx).SetHeaders(headers).Get(url)
|
||
|
if err != nil || rsp.StatusCode() != 200 {
|
||
|
fmt.Println("rsp body", rsp.String())
|
||
|
return nil, errors.New("GetAppTagConfigInfo error")
|
||
|
}
|
||
|
|
||
|
err = json.Unmarshal(rsp.Body(), &rspInfo)
|
||
|
if err != nil {
|
||
|
log.Errorf("Failed to unmarshal DomainResponse: %v\n", err)
|
||
|
return nil, err
|
||
|
}
|
||
|
fmt.Println("rsp body", rsp.String())
|
||
|
return &rspInfo, nil
|
||
|
}
|