1
This commit is contained in:
@@ -125,6 +125,7 @@ type AppFood struct {
|
||||
Unit string `json:"unit"`
|
||||
Utime int `json:"utime"`
|
||||
ZhName string `json:"zh_name"`
|
||||
CommonAttrValue string `json:"common_attr_value"`
|
||||
}
|
||||
|
||||
type AppFoodResult struct {
|
||||
@@ -243,18 +244,12 @@ func (a *API) RetailList(poiCode string, offset, limit int) (foodList []*AppFood
|
||||
return foodList, err
|
||||
}
|
||||
|
||||
func (a *API) RetailListAll(poiCode string) (foodList []*AppFood, err error) {
|
||||
offset := 0
|
||||
func (a *API) RetailListAll(poiCode string, offset int) (foodList []*AppFood, err error) {
|
||||
data := make([]*AppFood, 0, 0)
|
||||
for {
|
||||
batchList, err2 := a.RetailList(poiCode, offset, GeneralMaxLimit)
|
||||
if err = err2; err == nil {
|
||||
data = append(data, batchList...)
|
||||
}
|
||||
if len(batchList) < GeneralMaxLimit {
|
||||
break
|
||||
}
|
||||
offset += GeneralMaxLimit
|
||||
offset = (offset - 1) * 200
|
||||
batchList, err2 := a.RetailList(poiCode, offset, GeneralMaxLimit)
|
||||
if err = err2; err == nil {
|
||||
data = append(data, batchList...)
|
||||
}
|
||||
return data, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user