From 7f452364a10b6b5951247f508faa034c5dc26cf5 Mon Sep 17 00:00:00 2001 From: xiaoch05 Date: Wed, 6 Nov 2024 16:34:59 +0800 Subject: [PATCH] update api --- apollo/src/app.controller.ts | 28 +++++++++++----------------- apollo/src/app.service.ts | 2 +- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/apollo/src/app.controller.ts b/apollo/src/app.controller.ts index 1b25005..a616596 100644 --- a/apollo/src/app.controller.ts +++ b/apollo/src/app.controller.ts @@ -1,4 +1,4 @@ -import { Controller, Get, Query } from '@nestjs/common'; +import { Controller, Get, Query, Param } from '@nestjs/common'; import { AppService } from './app.service'; @Controller() @@ -10,9 +10,9 @@ export class AppController { return this.appService.getHello(); } - @Get('questn/used') - async questNUsedHelix(@Query('address') address: string) { - return await this.appService.questNUsedHelix( + @Get('quest/used') + async questUsedHelix(@Query('address') address: string) { + return await this.appService.questUsedHelix( { sender: address.toLowerCase(), }, @@ -20,21 +20,15 @@ export class AppController { ); } - @Get('questn/usedafter') - async questNUsedAfter(@Query('address') address: string) { + @Get('quest/after/:timestamp/times/:times') + async questUsedAfterAnd3Times( + @Param('timestamp') timestamp: number, + @Param('times') times: number, + @Query('address') address: string) { const where = { sender: address.toLowerCase(), - startTime: { gt: 1729428516 }, + startTime: { gt: timestamp }, }; - return await this.appService.questNUsedHelix(where, 1); - } - - @Get('questn/afterand3times') - async questNUsedAfterAnd3Times(@Query('address') address: string) { - const where = { - sender: address.toLowerCase(), - startTime: { gt: 1729428516 }, - }; - return await this.appService.questNUsedHelix(where, 3); + return await this.appService.questUsedHelix(where, times); } } diff --git a/apollo/src/app.service.ts b/apollo/src/app.service.ts index 7b7fed5..507d2ac 100644 --- a/apollo/src/app.service.ts +++ b/apollo/src/app.service.ts @@ -7,7 +7,7 @@ export class AppService extends PrismaClient { return 'Hello World!'; } - async questNUsedHelix(where: Prisma.HistoryRecordWhereInput, times: number) { + async questUsedHelix(where: Prisma.HistoryRecordWhereInput, times: number) { const total = await this.historyRecord.count({ where, });