From d015a2ced957b7eed30b1d1cba9c9750458c27fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Sat, 9 May 2020 11:14:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=AC=E4=B8=9C=E5=95=86=E5=9F=8E=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=B1=BB=E7=9B=AE=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/jdshopapi/sku.go | 22 ++++++++++++++++++++++ platformapi/jdshopapi/sku_test.go | 8 ++++++++ 2 files changed, 30 insertions(+) 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)) +}