aa
This commit is contained in:
40
platformapi/pddapi/sku.go
Normal file
40
platformapi/pddapi/sku.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package pddapi
|
||||
|
||||
import "git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
type GoodsCatsGetResult struct {
|
||||
CatName string `json:"cat_name"`
|
||||
Level int `json:"level"`
|
||||
CatID int `json:"cat_id"`
|
||||
ParentCatID int `json:"parent_cat_id"`
|
||||
}
|
||||
|
||||
//多多进宝商品类目查询
|
||||
func (a *API) GoodsCatsGet(catID int) (goodsCatsGetResult []*GoodsCatsGetResult, err error) {
|
||||
result, err := a.AccessAPI("pdd.goods.cats.get", false, map[string]interface{}{
|
||||
"parent_cat_id": catID,
|
||||
})
|
||||
if err == nil {
|
||||
utils.Map2StructByJson(result["goods_cats_get_response"].(map[string]interface{})["goods_cats_list"], &goodsCatsGetResult, false)
|
||||
}
|
||||
return goodsCatsGetResult, err
|
||||
}
|
||||
|
||||
type GoodsSearchParam struct {
|
||||
CatID int `json:"cat_id,omitempty"`
|
||||
GoodsSignList []string `json:"goods_sign_list,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
ListID string `json:"list_id,omitempty"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"page_size,omitempty"`
|
||||
SortType int `json:"sort_type,omitempty"`
|
||||
}
|
||||
|
||||
//多多进宝商品查询
|
||||
func (a *API) GoodsSearch(goodsSearchParam *GoodsSearchParam) (resourceURLGenResult *ResourceURLGenResult, err error) {
|
||||
result, err := a.AccessAPI("pdd.ddk.goods.search", false, utils.Struct2FlatMap(goodsSearchParam))
|
||||
if err == nil {
|
||||
utils.Map2StructByJson(result["resource_url_response"], &resourceURLGenResult, false)
|
||||
}
|
||||
return resourceURLGenResult, err
|
||||
}
|
||||
22
platformapi/pddapi/sku_test.go
Normal file
22
platformapi/pddapi/sku_test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package pddapi
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGoodsCatsGet(t *testing.T) {
|
||||
result, err := api.GoodsCatsGet(0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGoodsSearch(t *testing.T) {
|
||||
result, err := api.GoodsSearch(0, nil, "", "", 1, 5, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
Reference in New Issue
Block a user