fix(trading-service): 修复P2P转账历史查询参数解析
确保 page 和 pageSize 是有效数字,避免 skip: NaN 错误 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
dcc83b9f79
commit
28c73136a8
|
|
@ -253,6 +253,10 @@ export class P2pTransferService {
|
|||
page: number = 1,
|
||||
pageSize: number = 20,
|
||||
): Promise<{ data: P2pTransferHistoryItem[]; total: number }> {
|
||||
// 确保 page 和 pageSize 是有效数字
|
||||
const validPage = Math.max(1, Number(page) || 1);
|
||||
const validPageSize = Math.max(1, Math.min(100, Number(pageSize) || 20));
|
||||
|
||||
const [records, total] = await Promise.all([
|
||||
this.prisma.p2pTransfer.findMany({
|
||||
where: {
|
||||
|
|
@ -262,8 +266,8 @@ export class P2pTransferService {
|
|||
],
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
skip: (page - 1) * pageSize,
|
||||
take: pageSize,
|
||||
skip: (validPage - 1) * validPageSize,
|
||||
take: validPageSize,
|
||||
}),
|
||||
this.prisma.p2pTransfer.count({
|
||||
where: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue