-
Notifications
You must be signed in to change notification settings - Fork 3
/
goods.category.go
45 lines (38 loc) · 1020 Bytes
/
goods.category.go
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
package temu
import (
"context"
"github.com/hiscaler/temu-go/entity"
"github.com/hiscaler/temu-go/normal"
"gopkg.in/guregu/null.v4"
)
// 商品分类服务
type goodsCategoryService service
type GoodsCategoryQueryParams struct {
ParentCatId null.Int `json:"parentCatId,omitempty"` // 上级分类 ID
}
func (m GoodsCategoryQueryParams) validate() error {
return nil
}
// Query 商品分类查询
func (s goodsCategoryService) Query(ctx context.Context, params GoodsCategoryQueryParams) (categories []entity.Category, err error) {
if err = params.validate(); err != nil {
err = invalidInput(err)
return
}
var result = struct {
normal.Response
Result struct {
CategoryDTOList []entity.Category `json:"categoryDTOList"`
} `json:"result"`
}{}
resp, err := s.httpClient.R().
SetContext(ctx).
SetBody(params).
SetResult(&result).
Post("bg.goods.cats.get")
if err = recheckError(resp, result.Response, err); err != nil {
return
}
categories = result.Result.CategoryDTOList
return
}