51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package ebaiapi
|
|
|
|
import (
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
)
|
|
|
|
type CityInfo struct {
|
|
ID int `json:"city_id"`
|
|
Name string `json:"city_name"`
|
|
ParentID int `json:"parent_id"`
|
|
IsOpen int `json:"is_open"`
|
|
Level int `json:"level"`
|
|
}
|
|
|
|
type CatInfo struct {
|
|
ID int `json:"category_id"`
|
|
Name string `json:"category_name"`
|
|
}
|
|
|
|
func (a *API) CommonShopCities(parentID int) (cityList []*CityInfo, err error) {
|
|
result, err := a.AccessAPI("common.shopcities", utils.Params2Map("pid", parentID, "level", 2))
|
|
if err == nil {
|
|
err = utils.Map2StructByJson(result.Data, &cityList, true)
|
|
}
|
|
return cityList, err
|
|
}
|
|
|
|
func (a *API) CommonShopCategoriesGet() (cityList []*CatInfo, err error) {
|
|
result, err := a.AccessAPI("common.shop.category.get", nil)
|
|
if err == nil {
|
|
err = utils.Map2StructByJson(result.Data, &cityList, true)
|
|
}
|
|
return cityList, err
|
|
}
|
|
|
|
func (a *API) CommonShopCategories(parentID, level int) (cityList []*CatInfo, err error) {
|
|
result, err := a.AccessAPI("common.shopcategories", utils.Params2Map("category_id", parentID, "level", level))
|
|
if err == nil {
|
|
err = utils.Map2StructByJson(result.Data, &cityList, true)
|
|
}
|
|
return cityList, err
|
|
}
|
|
|
|
func (a *API) CommonBusinessCategories(parentID int) (cityList []*CatInfo, err error) {
|
|
result, err := a.AccessAPI("common.businesscategories", nil)
|
|
if err == nil {
|
|
err = utils.Map2StructByJson(result.Data, &cityList, true)
|
|
}
|
|
return cityList, err
|
|
}
|