- 几个平台的获取平台分类信息
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -180,3 +180,10 @@ func TestUpdateSpuSaleAttr(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateSpu(t *testing.T) {
|
||||
err := api.UpdateSpu("8620", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,13 @@ type RetailCategoryInfo struct {
|
||||
Children []*RetailCategoryInfo `json:"children"`
|
||||
}
|
||||
|
||||
type RetailTag struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Level int `json:"level"`
|
||||
NamePath string `json:"namePath"`
|
||||
}
|
||||
|
||||
// 美团分类没有ID,就以名字为唯一标识,不论级别都必须不能重名
|
||||
// name(和originName)的长度不能超过10个字符(字符,不是字节)
|
||||
// 创建一级分类,originName为空,name为新分类名,secondaryName为空
|
||||
@@ -157,10 +164,12 @@ func (a *API) RetailSkuDelete(poiCode, foodCode, skuID string) (err error) {
|
||||
}
|
||||
|
||||
// 就是厂商商品类别
|
||||
func (a *API) RetailGetSpTagIds() (tagIds []map[string]interface{}, err error) {
|
||||
func (a *API) RetailGetSpTagIds() (tagIds []*RetailTag, err error) {
|
||||
result, err := a.AccessAPI("retail/getSpTagIds", true, nil)
|
||||
if err == nil {
|
||||
return utils.Slice2MapSlice(result.([]interface{})), nil
|
||||
if err = utils.Map2StructByJson(result, &tagIds, false); err == nil {
|
||||
return tagIds, nil
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user