fix(snapshot): 修复 listSnapshots 分页参数 NaN 问题

NestJS @Query() 返回 string,需手动 parseInt 再传给 Prisma

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-23 23:15:26 -08:00
parent b8b4305ea5
commit a4689d5e8b
1 changed files with 5 additions and 3 deletions

View File

@ -60,10 +60,12 @@ export class SnapshotController {
@ApiQuery({ name: 'page', required: false, type: Number })
@ApiQuery({ name: 'limit', required: false, type: Number })
async listSnapshots(
@Query('page') page: number = 1,
@Query('limit') limit: number = 20,
@Query('page') page?: string,
@Query('limit') limit?: string,
) {
const result = await this.repo.findAll(page, limit);
const p = Math.max(1, parseInt(page || '1', 10) || 1);
const l = Math.min(100, Math.max(1, parseInt(limit || '20', 10) || 20));
const result = await this.repo.findAll(p, l);
return {
tasks: result.tasks.map(toSnapshotResponse),
total: result.total,