修复聚推客取链报错问题

This commit is contained in:
yanfan 2025-06-20 11:02:49 +08:00
parent 2dc89e17bc
commit 39c78abafe
2 changed files with 49 additions and 25 deletions

View File

@ -55,46 +55,70 @@ func (a *jutuikeApiImpl) GenerateLink(ctx context.Context, req GenerateLinkReque
}
result := new(GenerateLinkData)
data := cast.ToStringMap(response.Data)
if _, ok := data["act_name"]; ok {
result.ActName = data["act_name"].(string)
if actName, ok := data["act_name"]; ok {
if actName != nil {
result.ActName = cast.ToString(actName)
}
}
if _, ok := data["poster_qrcode_url"]; ok {
result.PosterQrcodeUrl = data["poster_qrcode_url"].(string)
if posterQrcodeUrl, ok := data["poster_qrcode_url"]; ok {
if posterQrcodeUrl != nil {
result.PosterQrcodeUrl = cast.ToString(posterQrcodeUrl)
}
}
if _, ok := data["h5"]; ok {
result.H5 = data["h5"].(string)
if h5Url, ok := data["h5"]; ok {
if h5Url != nil {
result.H5 = cast.ToString(h5Url)
}
}
if _, ok := data["long_h5"]; ok {
result.LongH5 = data["long_h5"].(string)
if longH5, ok := data["long_h5"]; ok {
if longH5 != nil {
result.LongH5 = cast.ToString(longH5)
}
}
if _, ok := data["h5_evoke"]; ok {
result.H5Evoke = data["h5_evoke"].(string)
if h5Evoke, ok := data["h5_evoke"]; ok {
if h5Evoke != nil {
result.H5Evoke = cast.ToString(h5Evoke)
}
}
if _, ok := data["deeplink"]; ok {
result.DeepLink = data["deeplink"].(string)
if deepLink, ok := data["deeplink"]; ok {
if deepLink != nil {
result.DeepLink = cast.ToString(deepLink)
}
}
if _, ok := data["we_app_info"]; ok {
weApp := cast.ToStringMap(data["we_app_info"])
weAppInfoTemp := new(WeAppInfo)
if _, tok := weApp["app_id"]; tok {
weAppInfoTemp.AppId = weApp["app_id"].(string)
if weAppAppId, tok := weApp["app_id"]; tok {
if weAppAppId != nil {
weAppInfoTemp.AppId = cast.ToString(weAppAppId)
}
}
if _, tok := weApp["page_path"]; tok {
weAppInfoTemp.PagePath = weApp["page_path"].(string)
if weAppPagePath, tok := weApp["page_path"]; tok {
if weAppPagePath != nil {
weAppInfoTemp.PagePath = cast.ToString(weAppPagePath)
}
}
if _, tok := weApp["miniCode"]; tok {
weAppInfoTemp.MiniCode = weApp["miniCode"].(string)
if weAppMiniCode, tok := weApp["miniCode"]; tok {
if weAppMiniCode != nil {
weAppInfoTemp.MiniCode = cast.ToString(weAppMiniCode)
}
}
result.WeAppInfo = weAppInfoTemp
}
if _, ok := data["alipay_app_info"]; ok {
alipayApp := cast.ToStringMap(data["alipay_app_info"])
alipayAppInfoTemp := new(AlipayAppInfo)
if _, tok := alipayApp["app_id"]; tok {
alipayAppInfoTemp.AppId = alipayApp["app_id"].(string)
if alipayAppAppid, tok := alipayApp["app_id"]; tok {
if alipayAppAppid != nil {
alipayAppInfoTemp.AppId = cast.ToString(alipayAppAppid)
}
}
if _, tok := alipayApp["page_path"]; tok {
alipayAppInfoTemp.PagePath = alipayApp["page_path"].(string)
if alipayAppPagePath, tok := alipayApp["page_path"]; tok {
if alipayAppPagePath != nil {
alipayAppInfoTemp.PagePath = cast.ToString(alipayAppPagePath)
}
}
result.AlipayAppInfo = alipayAppInfoTemp
}

View File

@ -21,15 +21,15 @@ func TestApiClient(t *testing.T) {
func (a *apiClientSuite) SetupSuite() {
log := logx.WithContext(context.Background())
apiClient := NewApiClient(log, AuthConfig{
ApiKey: "", //
ApiKey: "IyftVpzDVqDIRDqPZByW5xVpj9MgZSB7", //
})
a.api = apiClient
}
func (a *apiClientSuite) Test_GenerateLink() {
req := GenerateLinkRequest{
ActId: 65,
Sid: "f3a8c1",
ActId: 74,
Sid: "10001zdt100034",
}
result, err := a.api.GenerateLink(context.Background(), req)
if !a.NoError(err) {