33 lines
1.0 KiB
Go
33 lines
1.0 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"`
|
|
}
|
|
|
|
func (a *API) CommonShopCities(parentID int) (cityList []*CityInfo, err error) {
|
|
result, err := a.AccessAPI("common.shopcities", utils.Params2Map("pid", parentID))
|
|
if err == nil {
|
|
cityMapList := utils.Slice2MapSlice(result.Data.([]interface{}))
|
|
// baseapi.SugarLogger.Debug(utils.Format4Output(cityMapList, false))
|
|
cityList = make([]*CityInfo, len(cityMapList))
|
|
for k, v := range cityMapList {
|
|
cityList[k] = &CityInfo{
|
|
ID: int(utils.Str2Int64(utils.Interface2String(v["city_id"]))),
|
|
Name: utils.Interface2String(v["city_name"]),
|
|
ParentID: int(utils.Str2Int64(utils.Interface2String(v["parent_id"]))),
|
|
IsOpen: int(utils.Str2Int64(utils.Interface2String(v["is_open"]))),
|
|
}
|
|
}
|
|
return cityList, nil
|
|
}
|
|
return nil, err
|
|
}
|