From 83fc0616d607760cf8b15fc44dd4b5feaed2b194 Mon Sep 17 00:00:00 2001 From: overthestream Date: Sat, 27 Jan 2024 11:34:22 +0100 Subject: [PATCH] =?UTF-8?q?=ED=99=94=EC=82=B4=ED=91=9C=20Day=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/blurting/blurting.controller.ts | 15 ++++++++++++--- src/blurting/blurting.service.ts | 13 +++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/blurting/blurting.controller.ts b/src/blurting/blurting.controller.ts index d12e9ab..0b237df 100644 --- a/src/blurting/blurting.controller.ts +++ b/src/blurting/blurting.controller.ts @@ -180,12 +180,17 @@ export class BlurtingController { return await this.blurtingService.likeAnswer(id, answerId); } @UseGuards(AuthGuard('access')) - @Post('/arrow/:toId') + @Post('/arrow/:toId/:day') @ApiParam({ description: '화살표 받을 사람 id', name: 'toId', type: Number, }) + @ApiParam({ + description: 'day', + name: 'day, 1,2,3으로 보내주세요', + type: Number, + }) @ApiOperation({ summary: '화살표 보내기', description: '화살표 보내기', @@ -194,9 +199,13 @@ export class BlurtingController { @ApiOkResponse({ description: '화살표 보내기 성공', }) - async makeArrow(@Req() req: Request, @Param('toId') toId: number) { + async makeArrow( + @Req() req: Request, + @Param('toId') toId: number, + @Param('day') day: number, + ) { const { id } = req.user as JwtPayload; - return await this.blurtingService.makeArrow(id, toId); + return await this.blurtingService.makeArrow(id, toId, day); } @UseGuards(AuthGuard('access')) @Get('/arrow') diff --git a/src/blurting/blurting.service.ts b/src/blurting/blurting.service.ts index 759096b..44a1601 100644 --- a/src/blurting/blurting.service.ts +++ b/src/blurting/blurting.service.ts @@ -480,7 +480,7 @@ export class BlurtingService { } } - async makeArrow(userId: number, toId: number) { + async makeArrow(userId: number, toId: number, day: number) { const user = await this.userService.findUserByVal('id', userId); const arrow = await this.arrowRepository.findOne({ @@ -490,9 +490,10 @@ export class BlurtingService { }, order: { no: 'DESC' }, }); - let no = 1; - if (arrow) no = arrow.no + 1; - + const no = day; + if (arrow && arrow.no >= day) { + throw new BadRequestException('이미 화살표 존재'); + } const newArrow = this.arrowRepository.create({ from: { id: userId }, to: toId === -1 ? null : { id: toId }, @@ -504,12 +505,12 @@ export class BlurtingService { this.fcmService.sendPush( toId, - `${user.userNickname}님이 당신에게 화살표를 보냈습니다!`, + `${user.userNickname}님이 당신에게 화살을 보냈습니다!`, 'blurting', ); const newEntity = this.notificationRepository.create({ user: { id: userId }, - body: `${user.userNickname}님이 당신에게 화살표를 보냈습니다!`, + body: `${user.userNickname}님이 당신에게 화살을 보냈습니다!`, }); await this.notificationRepository.insert(newEntity); }