diff --git a/platform/shoutu-show/api.go b/platform/shoutu-show/api.go index d87a5db..a60f6b1 100644 --- a/platform/shoutu-show/api.go +++ b/platform/shoutu-show/api.go @@ -37,7 +37,7 @@ func (a *ShouTuShowApiImpl) GenerateLink(ctx context.Context, req GenerateLinkRe //直接替换 newUrl := strings.ReplaceAll(req.ActivityUrl, "subChannelId=", fmt.Sprintf("subChannelId=%s", req.Sid)) return &GenerateLinkResponse{ - H5: newUrl, + MiniProgramUrl: newUrl, }, nil } diff --git a/platform/shoutu-show/api_test.go b/platform/shoutu-show/api_test.go new file mode 100644 index 0000000..ed9f0d1 --- /dev/null +++ b/platform/shoutu-show/api_test.go @@ -0,0 +1,46 @@ +package shoutu_show + +import ( + "context" + "encoding/json" + "github.com/stretchr/testify/suite" + "github.com/zeromicro/go-zero/core/logx" + "testing" +) + +// api-单元测试 +type apiClientSuite struct { + suite.Suite + api ShouTuShowApi +} + +func TestApiClient(t *testing.T) { + suite.Run(t, new(apiClientSuite)) +} + +func (a *apiClientSuite) SetupSuite() { + log := logx.WithContext(context.Background()) + apiClient := NewApiClient(log, AuthConfig{ + AppKey: "", // + AppSecret: "", + }) + a.api = apiClient +} + +func (a *apiClientSuite) Test_GenerateLink() { + req := GenerateLinkRequest{ + ActivityUrl: "pages/index/index?distributorId=VCiCWwU2&subChannelId=", + Sid: "f3a8c1", + } + result, err := a.api.GenerateLink(context.Background(), req) + if !a.NoError(err) { + a.T().Errorf("========[Test_GenerateLink] response error:%s", err) + return + } + resultByte, err := json.Marshal(result) + if err != nil { + a.T().Errorf("========[Test_GenerateLink] json_marshal error:%s", err) + return + } + a.T().Logf("=====[Test_GenerateLink] result: %s", string(resultByte)) +} diff --git a/platform/shoutu-show/types.go b/platform/shoutu-show/types.go index 852cb6c..781221b 100644 --- a/platform/shoutu-show/types.go +++ b/platform/shoutu-show/types.go @@ -7,7 +7,8 @@ type GenerateLinkRequest struct { // GenerateLinkResponse 生成推广链接响应 type GenerateLinkResponse struct { - H5 string `json:"h5"` // H5链接 + H5 string `json:"h5"` // H5链接 + MiniProgramUrl string `json:"MiniProgramUrl"` //小程序链接 } type QueryOrderListRequest struct {