- remove nonexistent field shop_custom_id in ShopCategoryCreate and ShopCategoryUpdate
This commit is contained in:
@@ -19,7 +19,6 @@ const (
|
|||||||
|
|
||||||
type CategoryInfo struct {
|
type CategoryInfo struct {
|
||||||
CategoryID int64 `json:"category_id"`
|
CategoryID int64 `json:"category_id"`
|
||||||
ShopCustomID string `json:"shop_custom_id"`
|
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Rank int `json:"rank"` // 店内分类独有
|
Rank int `json:"rank"` // 店内分类独有
|
||||||
Children []*CategoryInfo `json:"children"`
|
Children []*CategoryInfo `json:"children"`
|
||||||
@@ -35,13 +34,12 @@ type PageDataInfo struct {
|
|||||||
|
|
||||||
// category相关的函数,shop_custom_id可重
|
// 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{}{
|
result, err := a.AccessAPI("sku.shop.category.create", map[string]interface{}{
|
||||||
KeyShopID: shopID,
|
KeyShopID: shopID,
|
||||||
"parent_category_id": parentID,
|
"parent_category_id": parentID,
|
||||||
"name": name,
|
"name": name,
|
||||||
"rank": rank,
|
"rank": rank,
|
||||||
"shop_custom_id": shopCustomID,
|
|
||||||
})
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return utils.Str2Int64(utils.Interface2String(result.Data.(map[string]interface{})["category_id"])), 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
|
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{}{
|
_, err = a.AccessAPI("sku.shop.category.update", map[string]interface{}{
|
||||||
KeyShopID: shopID,
|
KeyShopID: shopID,
|
||||||
"category_id": categoryID,
|
"category_id": categoryID,
|
||||||
"name": name,
|
"name": name,
|
||||||
"rank": rank,
|
"rank": rank,
|
||||||
"shop_custom_id": shopCustomID,
|
|
||||||
})
|
})
|
||||||
if errWithCode, ok := err.(*utils.ErrorWithCode); ok {
|
if errWithCode, ok := err.(*utils.ErrorWithCode); ok {
|
||||||
if errWithCode.Level() == 0 && errWithCode.IntCode() == 1 { //忽略同名错误
|
if errWithCode.Level() == 0 && errWithCode.IntCode() == 1 { //忽略同名错误
|
||||||
@@ -225,7 +222,6 @@ func interface2Cat(data interface{}, level int) (cat *CategoryInfo) {
|
|||||||
catMap := data.(map[string]interface{})
|
catMap := data.(map[string]interface{})
|
||||||
cat = &CategoryInfo{
|
cat = &CategoryInfo{
|
||||||
CategoryID: utils.MustInterface2Int64(catMap["category_id"]),
|
CategoryID: utils.MustInterface2Int64(catMap["category_id"]),
|
||||||
ShopCustomID: utils.Interface2String(catMap["shop_custom_id"]),
|
|
||||||
Name: utils.Interface2String(catMap["name"]),
|
Name: utils.Interface2String(catMap["name"]),
|
||||||
Rank: int(utils.MustInterface2Int64(catMap["rank"])),
|
Rank: int(utils.MustInterface2Int64(catMap["rank"])),
|
||||||
Children: interface2CatList(catMap["children"], level+1),
|
Children: interface2CatList(catMap["children"], level+1),
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestShopCategoryCreate(t *testing.T) {
|
func TestShopCategoryCreate(t *testing.T) {
|
||||||
result, err := api.ShopCategoryCreate(testShopID, 0, "绿色蔬菜", 16, "16")
|
result, err := api.ShopCategoryCreate(testShopID, 0, "绿色蔬菜", 16)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
@@ -25,7 +25,7 @@ func TestShopCategoryGet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestShopCategoryUpdate(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 {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user