fix(snapshot): 修复 listSnapshots 分页参数 NaN 问题
NestJS @Query() 返回 string,需手动 parseInt 再传给 Prisma Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b8b4305ea5
commit
a4689d5e8b
|
|
@ -60,10 +60,12 @@ export class SnapshotController {
|
||||||
@ApiQuery({ name: 'page', required: false, type: Number })
|
@ApiQuery({ name: 'page', required: false, type: Number })
|
||||||
@ApiQuery({ name: 'limit', required: false, type: Number })
|
@ApiQuery({ name: 'limit', required: false, type: Number })
|
||||||
async listSnapshots(
|
async listSnapshots(
|
||||||
@Query('page') page: number = 1,
|
@Query('page') page?: string,
|
||||||
@Query('limit') limit: number = 20,
|
@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 {
|
return {
|
||||||
tasks: result.tasks.map(toSnapshotResponse),
|
tasks: result.tasks.map(toSnapshotResponse),
|
||||||
total: result.total,
|
total: result.total,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue