1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package tmv3
import (
"context"
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gtime"
)
type Config struct {
AppKey string
AppSecret string
}
var server *client.Client
const (
PkgName = "tmv3"
Endpoint = "linkedmall-distributor.cn-zhangjiakou.aliyuncs.com"
RegionId = "cn-zhangjiakou"
PurchaserId = "PID2200006434"
)
func New(req *Config) {
config := &openapi.Config{
AccessKeyId: tea.String(req.AppKey),
AccessKeySecret: tea.String(req.AppSecret),
RegionId: tea.String(RegionId),
}
config.Endpoint = tea.String(Endpoint)
server = &client.Client{}
server, _ = client.NewClient(config)
return
}
func Log(ctx context.Context, req interface{}, res interface{}, err error, start int64) {
if err != nil {
g.Log().Ctx(ctx).Cat(PkgName).Errorf("参数【%v】错误【%v】响应时间【%vms】", gjson.New(req).MustToJsonString(), err.Error(), gtime.TimestampMilli()-start)
} else {
g.Log().Ctx(ctx).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%vms】", gjson.New(req).MustToJsonString(), gjson.New(res).MustToJsonString(), gtime.TimestampMilli()-start)
}
}
type CommonRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
}