- ebai api
This commit is contained in:
32
platformapi/ebaiapi/common.go
Normal file
32
platformapi/ebaiapi/common.go
Normal file
@@ -0,0 +1,32 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user