task-113(任务与重复分析中心): 实现店铺数据任务批量下载

新增 shop-data-download.ts(打包请求体 result_ids + 下载 job 状态),
shop-data-api.ts 增加 requestShopDataZipDownload(POST /download-zip, blob)。

TDD: task-113.test.ts 8 用例先 RED 后 GREEN。
This commit is contained in:
2026-09-05 17:20:39 +08:00
parent 40463772c5
commit 69f6965c93
3 changed files with 125 additions and 1 deletions
@@ -1,7 +1,9 @@
/** 店铺数据任务列表载适配(任务 110GET /api/admin/shop-data-crawl-tasks + 筛选归一与解析。 */
/** 店铺数据任务列表/批量下载适配(任务 110/113)。 */
import { http } from '@/api/http'
import { parseShopDataTaskPage, type ShopDataTaskPageResult } from './shop-data-model.ts'
import { toShopDataQuery, type ShopDataFilter } from './shop-data-filter.ts'
import { toShopDataZipRequest } from './shop-data-download.ts'
import { downloadZipHeaderCounts } from './image-video-download.ts'
export const SHOP_DATA_CRAWL_TASKS_ENDPOINT = '/api/admin/shop-data-crawl-tasks'
@@ -15,3 +17,18 @@ export async function fetchShopDataTaskList(
})
return parseShopDataTaskPage(data)
}
export interface ShopDataZipDownloadResult {
blob: Blob
fileCount?: number
errorCount?: number
}
/** 批量下载选中结果文件为 zipPOST /download-zip(blob);从响应头读成功/失败计数。 */
export async function requestShopDataZipDownload(resultIds: readonly (number | string)[]): Promise<ShopDataZipDownloadResult> {
const { data, headers } = await http.post<Blob>(`${SHOP_DATA_CRAWL_TASKS_ENDPOINT}/download-zip`, toShopDataZipRequest(resultIds), {
responseType: 'blob',
})
const counts = downloadZipHeaderCounts(headers as Record<string, string>)
return { blob: data, fileCount: counts.fileCount, errorCount: counts.errorCount }
}