- 几个平台的获取平台分类信息

This commit is contained in:
gazebo
2019-04-23 17:36:59 +08:00
parent 144aba73f9
commit 0bff70c554
4 changed files with 30 additions and 5 deletions

View File

@@ -6,19 +6,28 @@ import (
"git.rosy.net.cn/baseapi/utils"
)
type VendorCategoryInfo struct {
CatID string `json:"cat_id"`
CatName string `json:"cat_name"`
Depth int `json:"depth"`
ParentID string `json:"parent_id"`
}
type BrandInfo struct {
BrandID int64 `json:"brand_id"`
BrandName string `json:"brand_name"`
}
func (a *API) SkuCategoryList(keyword string, depth int, parentID int64) (cats []interface{}, err error) {
func (a *API) SkuCategoryList(keyword string, depth int, parentID int64) (cats []*VendorCategoryInfo, err error) {
result, err := a.AccessAPI("sku.category.list", map[string]interface{}{
"keyword": keyword,
"depth": depth,
"parent_id": parentID,
})
if err == nil {
return utils.Interface2Slice(result.Data), nil
if err = utils.Map2StructByJson(result.Data, &cats, true); err == nil {
return cats, nil
}
}
return nil, err
}

View File

@@ -7,7 +7,7 @@ import (
)
func TestSkuCategoryList(t *testing.T) {
result, err := api.SkuCategoryList("", 3, 1491490798176)
result, err := api.SkuCategoryList("", 1, 0)
if err != nil {
t.Fatal(err)
} else {