From 335162d99a6a9389b4935a6d683a9ad80739a9ae Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Jan 2019 16:57:11 +0800 Subject: [PATCH] - remove nonexistent field shop_custom_id in ShopCategoryCreate and ShopCategoryUpdate --- platformapi/ebaiapi/shop_sku.go | 36 +++++++++++++--------------- platformapi/ebaiapi/shop_sku_test.go | 4 ++-- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/platformapi/ebaiapi/shop_sku.go b/platformapi/ebaiapi/shop_sku.go index aa4ce20d..e2b15182 100644 --- a/platformapi/ebaiapi/shop_sku.go +++ b/platformapi/ebaiapi/shop_sku.go @@ -18,12 +18,11 @@ const ( ) type CategoryInfo struct { - CategoryID int64 `json:"category_id"` - ShopCustomID string `json:"shop_custom_id"` - Name string `json:"name"` - Rank int `json:"rank"` // 店内分类独有 - Children []*CategoryInfo `json:"children"` - Level int `json:"level"` + CategoryID int64 `json:"category_id"` + Name string `json:"name"` + Rank int `json:"rank"` // 店内分类独有 + Children []*CategoryInfo `json:"children"` + Level int `json:"level"` } type PageDataInfo struct { @@ -35,13 +34,12 @@ type PageDataInfo struct { // category相关的函数,shop_custom_id可重 -func (a *API) ShopCategoryCreate(shopID string, parentID int64, name string, rank int, shopCustomID string) (catID int64, err error) { +func (a *API) ShopCategoryCreate(shopID string, parentID int64, name string, rank int) (catID int64, err error) { result, err := a.AccessAPI("sku.shop.category.create", map[string]interface{}{ KeyShopID: shopID, "parent_category_id": parentID, "name": name, "rank": rank, - "shop_custom_id": shopCustomID, }) if err == nil { return utils.Str2Int64(utils.Interface2String(result.Data.(map[string]interface{})["category_id"])), nil @@ -60,13 +58,12 @@ func (a *API) ShopCategoryGet(shopID string) (cats []*CategoryInfo, err error) { return nil, err } -func (a *API) ShopCategoryUpdate(shopID string, categoryID int64, name string, rank int, shopCustomID string) (err error) { +func (a *API) ShopCategoryUpdate(shopID string, categoryID int64, name string, rank int) (err error) { _, err = a.AccessAPI("sku.shop.category.update", map[string]interface{}{ - KeyShopID: shopID, - "category_id": categoryID, - "name": name, - "rank": rank, - "shop_custom_id": shopCustomID, + KeyShopID: shopID, + "category_id": categoryID, + "name": name, + "rank": rank, }) if errWithCode, ok := err.(*utils.ErrorWithCode); ok { if errWithCode.Level() == 0 && errWithCode.IntCode() == 1 { //忽略同名错误 @@ -224,12 +221,11 @@ func interface2CatList(data interface{}, level int) (cats []*CategoryInfo) { func interface2Cat(data interface{}, level int) (cat *CategoryInfo) { catMap := data.(map[string]interface{}) cat = &CategoryInfo{ - CategoryID: utils.MustInterface2Int64(catMap["category_id"]), - ShopCustomID: utils.Interface2String(catMap["shop_custom_id"]), - Name: utils.Interface2String(catMap["name"]), - Rank: int(utils.MustInterface2Int64(catMap["rank"])), - Children: interface2CatList(catMap["children"], level+1), - Level: level, + CategoryID: utils.MustInterface2Int64(catMap["category_id"]), + Name: utils.Interface2String(catMap["name"]), + Rank: int(utils.MustInterface2Int64(catMap["rank"])), + Children: interface2CatList(catMap["children"], level+1), + Level: level, } return cat } diff --git a/platformapi/ebaiapi/shop_sku_test.go b/platformapi/ebaiapi/shop_sku_test.go index 729ee98e..1207c74e 100644 --- a/platformapi/ebaiapi/shop_sku_test.go +++ b/platformapi/ebaiapi/shop_sku_test.go @@ -7,7 +7,7 @@ import ( ) func TestShopCategoryCreate(t *testing.T) { - result, err := api.ShopCategoryCreate(testShopID, 0, "绿色蔬菜", 16, "16") + result, err := api.ShopCategoryCreate(testShopID, 0, "绿色蔬菜", 16) if err != nil { t.Fatal(err) } else { @@ -25,7 +25,7 @@ func TestShopCategoryGet(t *testing.T) { } func TestShopCategoryUpdate(t *testing.T) { - err := api.ShopCategoryUpdate(testShopID, 153760204017121, "水果2", 2, "2") + err := api.ShopCategoryUpdate(testShopID, 153760204017121, "水果2", 2) if err != nil { t.Fatal(err) }