添加mtwmapi.RetailListAll
This commit is contained in:
@@ -193,6 +193,21 @@ 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
|
||||
for {
|
||||
batchList, err2 := a.RetailList(poiCode, offset, GeneralMaxLimit)
|
||||
if err = err2; err == nil {
|
||||
foodList = append(foodList, batchList...)
|
||||
}
|
||||
if len(batchList) < GeneralMaxLimit {
|
||||
break
|
||||
}
|
||||
offset += GeneralMaxLimit
|
||||
}
|
||||
return foodList, err
|
||||
}
|
||||
|
||||
func handleRetailBatchResult(result interface{}) (failedFoodList []*AppFoodResult, err error) {
|
||||
if msg, ok := result.(string); ok && msg != "" {
|
||||
err = utils.UnmarshalUseNumber([]byte(msg), &failedFoodList)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func TestRetailCatList(t *testing.T) {
|
||||
result, err := api.RetailCatList(testPoiCode)
|
||||
result, err := api.RetailCatList("7875210")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -25,22 +25,22 @@ func TestRetailCatUpdate(t *testing.T) {
|
||||
}
|
||||
func TestRetailCatDelete(t *testing.T) {
|
||||
var err error
|
||||
err = api.RetailCatDelete(testPoiCode, "", utils.GetUpperUUID())
|
||||
err = api.RetailCatDelete(testPoiCode, "" /*utils.GetUpperUUID()*/, "小月饼111")
|
||||
if err == nil {
|
||||
t.Fatal("should return error that can not find such cat")
|
||||
}
|
||||
uniqueCatName := "一二三四五六七八九十"
|
||||
// uniqueCatName := "1234567890" //fmt.Sprintf("CAT%d", time.Now().Unix())
|
||||
err = api.RetailCatUpdate(testPoiCode, uniqueCatName, &Param4UpdateCat{
|
||||
Sequence: 15,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = api.RetailCatDelete(testPoiCode, "", uniqueCatName)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// uniqueCatName := "一二三四五六七八九十"
|
||||
// // uniqueCatName := "1234567890" //fmt.Sprintf("CAT%d", time.Now().Unix())
|
||||
// err = api.RetailCatUpdate(testPoiCode, uniqueCatName, &Param4UpdateCat{
|
||||
// Sequence: 15,
|
||||
// })
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// err = api.RetailCatDelete(testPoiCode, "", uniqueCatName)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
}
|
||||
|
||||
func TestRetailList(t *testing.T) {
|
||||
@@ -52,6 +52,19 @@ func TestRetailList(t *testing.T) {
|
||||
t.Fatal("should have items")
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
t.Log(len(result))
|
||||
}
|
||||
|
||||
func TestRetailListAll(t *testing.T) {
|
||||
result, err := api.RetailListAll(testPoiCode)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(result) == 0 {
|
||||
t.Fatal("should have items")
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
t.Log(len(result))
|
||||
}
|
||||
|
||||
func TestRetailGet(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user