diff --git a/platformapi/jdshopapi/sku.go b/platformapi/jdshopapi/sku.go index 42ab035a..7ffb9979 100644 --- a/platformapi/jdshopapi/sku.go +++ b/platformapi/jdshopapi/sku.go @@ -45,6 +45,28 @@ func (a *API) DeleteShopCategory(cid int64) (uniteResp *UniteResp, err error) { return uniteResp, err } +type FindVendorCategoriesResult struct { + ID int `json:"id"` + Fid int `json:"fid"` + AliasName string `json:"aliasName"` + Lev int `json:"lev"` + IndexID int `json:"indexId"` + Status int `json:"status"` + Created int64 `json:"created"` + Name string `json:"name"` + Modified int64 `json:"modified"` +} + +//查询商家所有的类目 +//https://open.jd.com/home/home#/doc/api?apiCateId=88&apiId=2727&apiName=jingdong.vender.category.getValidCategoryResultByVenderId +func (a *API) FindVendorCategories() (findVendorCategoriesResult []*FindVendorCategoriesResult, err error) { + result, err := a.AccessAPI("jingdong.vender.category.getValidCategoryResultByVenderId", prodURL, nil) + if err == nil { + utils.Map2StructByJson(result["jingdong_vender_category_getValidCategoryResultByVenderId_responce"].(map[string]interface{})["getvalidcategoryresultbyvenderid_result"].(map[string]interface{})["list"], &findVendorCategoriesResult, false) + } + return findVendorCategoriesResult, err +} + //京东商城发布商品(创建商品?) //https://open.jd.com/home/home#/doc/api?apiCateId=48&apiId=1379&apiName=jingdong.ware.write.add func (a *API) CreateSku() (err error) { diff --git a/platformapi/jdshopapi/sku_test.go b/platformapi/jdshopapi/sku_test.go index 0c6cf3f8..ea88f94e 100644 --- a/platformapi/jdshopapi/sku_test.go +++ b/platformapi/jdshopapi/sku_test.go @@ -21,3 +21,11 @@ func TestDeleteShopCategory(t *testing.T) { } t.Log(utils.Format4Output(result, false)) } + +func TestFindVendorCategories(t *testing.T) { + result, err := api.FindVendorCategories() + if err != nil { + t.Fatal(err) + } + t.Log(utils.Format4Output(result, false)) +}