中捷乐淘-取链
This commit is contained in:
parent
460013ba5e
commit
338411e6ee
@ -2,8 +2,10 @@ package zjdg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
"net/url"
|
||||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||||
)
|
)
|
||||||
@ -46,6 +48,26 @@ func (a *zjdgApiImpl) ZoneAdd(ctx context.Context, req ZoneAddRequest) (*ZoneAdd
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *zjdgApiImpl) GenerateH5Url(ctx context.Context, req GenerateH5UrlRequest) (string, error) {
|
func (a *zjdgApiImpl) GenerateH5Url(ctx context.Context, req GenerateH5UrlRequest) (string, error) {
|
||||||
promotionUrl := fmt.Sprintf(PromotionUrl, req.Sid, a.client.authConfig.UserId)
|
u, err := url.Parse(req.ActivityUrl)
|
||||||
return promotionUrl, nil
|
if err != nil {
|
||||||
|
return "", errors.New("activityUrl不是一个url")
|
||||||
|
}
|
||||||
|
urlParams := u.Query()
|
||||||
|
for key, item := range urlParams {
|
||||||
|
if key == "adzoneid" {
|
||||||
|
urlParams.Set("adzoneid", req.Sid)
|
||||||
|
} else if key == "userid" {
|
||||||
|
urlParams.Set("userid", a.client.authConfig.UserId)
|
||||||
|
} else {
|
||||||
|
if len(item) > 0 {
|
||||||
|
urlParams.Set(key, item[0])
|
||||||
|
} else {
|
||||||
|
urlParams.Set(key, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Println(fmt.Sprintf("key=%s,val=%s,len=%d", key, item, len(item)))
|
||||||
|
}
|
||||||
|
u.RawQuery = urlParams.Encode()
|
||||||
|
|
||||||
|
return u.String(), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,13 +30,27 @@ func (a *apiClientSuite) Test_ZoneAdd() {
|
|||||||
req := ZoneAddRequest{}
|
req := ZoneAddRequest{}
|
||||||
result, err := a.api.ZoneAdd(context.Background(), req)
|
result, err := a.api.ZoneAdd(context.Background(), req)
|
||||||
if !a.NoError(err) {
|
if !a.NoError(err) {
|
||||||
a.T().Errorf("========[Test_GenerateLink] response error:%s", err)
|
a.T().Errorf("========[Test_ZoneAdd] response error:%s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resultByte, err := json.Marshal(result)
|
resultByte, err := json.Marshal(result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.T().Errorf("========[Test_GenerateLink] json_marshal error:%s", err)
|
a.T().Errorf("========[Test_ZoneAdd] json_marshal error:%s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
a.T().Logf("=====[Test_GenerateLink] result: %s", string(resultByte))
|
a.T().Logf("=====[Test_ZoneAdd] result: %s", string(resultByte))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *apiClientSuite) Test_GenerateH5Url() {
|
||||||
|
req := GenerateH5UrlRequest{
|
||||||
|
ActivityUrl: PromotionUrl,
|
||||||
|
Sid: "1963667",
|
||||||
|
}
|
||||||
|
result, err := a.api.GenerateH5Url(context.Background(), req)
|
||||||
|
if !a.NoError(err) {
|
||||||
|
a.T().Errorf("========[Test_GenerateH5Url] response error:%s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
a.T().Logf("=====[Test_GenerateH5Url] result: %s", result)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,5 +2,5 @@ package zjdg
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
ZoneAddUrl = "https://p.zjdg.cn/cpa/api/ugApi.ashx?method=getadzone_nologin&userid="
|
ZoneAddUrl = "https://p.zjdg.cn/cpa/api/ugApi.ashx?method=getadzone_nologin&userid="
|
||||||
PromotionUrl = "http://2025.zjdg.cn/ditui/qrcode?adzoneid=%s&userid=%s"
|
PromotionUrl = "http://2025.zjdg.cn/ditui/qrcode?adzoneid=&userid="
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user