From 39c78abafe057ac580c048b1f3bdf23bbfa79e18 Mon Sep 17 00:00:00 2001 From: yanfan <1406317364@qq.com> Date: Fri, 20 Jun 2025 11:02:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=81=9A=E6=8E=A8=E5=AE=A2?= =?UTF-8?q?=E5=8F=96=E9=93=BE=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/jutuike/api.go | 68 ++++++++++++++++++++++++------------ platform/jutuike/api_test.go | 6 ++-- 2 files changed, 49 insertions(+), 25 deletions(-) diff --git a/platform/jutuike/api.go b/platform/jutuike/api.go index 281b58c..1588183 100644 --- a/platform/jutuike/api.go +++ b/platform/jutuike/api.go @@ -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 } diff --git a/platform/jutuike/api_test.go b/platform/jutuike/api_test.go index 58edd77..a1936fd 100644 --- a/platform/jutuike/api_test.go +++ b/platform/jutuike/api_test.go @@ -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) {