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
59
60
61
62
63
64
65
66
67
68
package ikc
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/util/gconv"
)
type categoryIkc struct {
}
//Category 品类
var Category = categoryIkc{}
type CategoryListRes struct {
ResultCode int `json:"resultCode"`
ResultMessage string `json:"resultMessage"`
Data []struct {
Id string `json:"id"`
Name string `json:"name"`
Sort int `json:"sort"`
} `json:"data"`
}
//List 列表
func (*categoryIkc) List(ctx context.Context) (res *CategoryListRes, err error) {
method := "category/frontCategory"
result, err := post(ctx, method, g.Map{})
_ = gjson.New(result).Scan(&res)
return
}
type CategoryTreeRes struct {
ResultCode int `json:"resultCode"`
ResultMessage string `json:"resultMessage"`
Data []struct {
Pid string `json:"pid"`
ParentId string `json:"parentId"`
CategoryCode string `json:"categoryCode"`
CategoryName string `json:"categoryName"`
CategoryNameEn string `json:"categoryNameEn,omitempty"`
CategoryLevel int `json:"categoryLevel"`
OrderNo int `json:"orderNo"`
Children []children `json:"children"`
} `json:"data"`
}
type children struct {
Pid string `json:"pid"`
ParentId string `json:"parentId"`
CategoryCode string `json:"categoryCode"`
CategoryName string `json:"categoryName"`
CategoryNameEn string `json:"categoryNameEn,omitempty"`
CategoryLevel int `json:"categoryLevel"`
OrderNo int `json:"orderNo"`
Children []children `json:"children"`
}
//Tree 类目树
func (*categoryIkc) Tree(ctx context.Context, level interface{}) (res *CategoryTreeRes, err error) {
method := "category/getTree"
result, err := post(ctx, method, g.Map{
"level": gconv.Int(level),
})
_ = gjson.New(result).Scan(&res)
return
}