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
52
53
54
55
56
57
58
package tmv3
import (
"context"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type categoryTm struct {
}
var Category = categoryTm{}
type CategoryListReq struct {
ParentId int64
CategoryIds []int64
}
type CategoryListRes struct {
Categories []struct {
CategoryId int `json:"categoryId"`
IsLeaf bool `json:"isLeaf"`
Level int `json:"level"`
Name string `json:"name"`
ParentId int `json:"parentId"`
} `json:"categories"`
RequestId string `json:"requestId"`
}
func (s categoryTm) List(ctx context.Context, req CategoryListReq) (res *CategoryListRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "ListCategories")
defer func() {
Log(ctx, req, res, err, Start)
}()
Request := &client.ListCategoriesRequest{}
var Body = new(client.CategoryListQuery)
if req.ParentId != 0 {
Body.SetParentCategoryId(req.ParentId)
}
var list []*int64
for _, item := range req.CategoryIds {
list = append(list, tea.Int64(item))
}
Body.SetCategoryIds(list)
Request.SetBody(Body)
r, err := server.ListCategories(Request)
if err != nil {
return
}
//
err = gjson.New(r.Body).Scan(&res)
return
}