守兔演出链接生成

This commit is contained in:
yanfan 2024-11-21 15:50:04 +08:00
parent 4c4478dc84
commit 982f6981d4
3 changed files with 49 additions and 2 deletions

View File

@ -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)) newUrl := strings.ReplaceAll(req.ActivityUrl, "subChannelId=", fmt.Sprintf("subChannelId=%s", req.Sid))
return &GenerateLinkResponse{ return &GenerateLinkResponse{
H5: newUrl, MiniProgramUrl: newUrl,
}, nil }, nil
} }

View File

@ -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))
}

View File

@ -7,7 +7,8 @@ type GenerateLinkRequest struct {
// GenerateLinkResponse 生成推广链接响应 // GenerateLinkResponse 生成推广链接响应
type GenerateLinkResponse struct { type GenerateLinkResponse struct {
H5 string `json:"h5"` // H5链接 H5 string `json:"h5"` // H5链接
MiniProgramUrl string `json:"MiniProgramUrl"` //小程序链接
} }
type QueryOrderListRequest struct { type QueryOrderListRequest struct {