fix: 修复顺运宝分页总数误判 (#60)
This commit is contained in:
+4
-1
@@ -504,7 +504,7 @@ type StockRow struct {
|
||||
}
|
||||
|
||||
// ListPage 按日期范围翻一页货运单列表:POST /am/stock/list。
|
||||
// 返回响应内的 total,供上层核对分页期间总数有没有漂移。
|
||||
// 返回响应内的 total;HAR 证明它是当前页条数,不是筛选范围总数。
|
||||
func (c *Client) ListPage(ctx context.Context, dateFrom, dateTo string, start, pageIndex, pageSize int) ([]StockRow, int, error) {
|
||||
data, err := c.do(ctx, http.MethodPost, "/am/stock/list", nil,
|
||||
listPayload(dateFrom, dateTo, start, pageIndex, pageSize))
|
||||
@@ -522,6 +522,9 @@ func (c *Client) ListPage(ctx context.Context, dateFrom, dateTo string, start, p
|
||||
if wrap.Total == nil || *wrap.Total < 0 {
|
||||
return nil, 0, fmt.Errorf("货运单列表响应缺少合法的 total")
|
||||
}
|
||||
if *wrap.Total != len(wrap.List) {
|
||||
return nil, 0, fmt.Errorf("货运单列表响应的当前页条数为 %d,但实际返回 %d 行", *wrap.Total, len(wrap.List))
|
||||
}
|
||||
|
||||
rows := make([]StockRow, 0, len(wrap.List))
|
||||
for _, raw := range wrap.List {
|
||||
|
||||
Reference in New Issue
Block a user