This commit is contained in:
邹宗楠
2023-09-22 15:09:35 +08:00
parent 76af28b1ba
commit 990ea93f60
3 changed files with 23 additions and 77 deletions

View File

@@ -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
}