From 245656c2b8178e4fb56e89e0c9c3157bc9f28c56 Mon Sep 17 00:00:00 2001 From: Devheun Date: Fri, 19 Jul 2024 15:43:10 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=ED=9A=8D?= =?UTF-8?q?=EB=93=9D/=EC=82=AD=EC=A0=9C=20=EC=97=94=EB=93=9C=ED=8F=AC?= =?UTF-8?q?=EC=9D=B8=ED=8A=B8=20=EC=9E=84=EC=9D=98=EB=A1=9C=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/user/user.controller.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/user/user.controller.ts b/src/user/user.controller.ts index abbd12ac..7abbc044 100644 --- a/src/user/user.controller.ts +++ b/src/user/user.controller.ts @@ -86,6 +86,13 @@ export class UserController { return await this.userService.getProfile(id); } + @UseGuards(JwtAuthGuard) + @Patch('point') + async changePoint(@User() user: AuthorizedUserDto): Promise { + const id = user.id; + return await this.userService.changePoint(id, -100, '포인트 획득'); + } + @ApiOperation({ summary: '포인트 내역 조회', description: '포인트 획득/사용 내역을 조회 합니다', From 9925e483f8a3b65f2e724d14f606d20c7114ba5c Mon Sep 17 00:00:00 2001 From: Devheun Date: Fri, 30 Aug 2024 17:44:12 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat::=20=EA=B0=95=EC=9D=98=ED=8F=89=20?= =?UTF-8?q?=EC=97=B4=EB=9E=8C=EA=B6=8C=20=EB=A7=8C=EB=A3=8C=20=EC=97=AC?= =?UTF-8?q?=EB=B6=80=20=EB=B0=98=ED=99=98=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../check-course-review-reading-ticket.dto.ts | 10 ++++++++ src/user/user.controller.ts | 18 +++++++++++++++ src/user/user.service.ts | 23 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 src/user/dto/check-course-review-reading-ticket.dto.ts diff --git a/src/user/dto/check-course-review-reading-ticket.dto.ts b/src/user/dto/check-course-review-reading-ticket.dto.ts new file mode 100644 index 00000000..ebf91683 --- /dev/null +++ b/src/user/dto/check-course-review-reading-ticket.dto.ts @@ -0,0 +1,10 @@ +import { ApiProperty } from '@nestjs/swagger'; + +export class CheckCourseReviewReadingTicketResponseDto { + constructor(date: Date) { + this.date = date; + } + + @ApiProperty({ description: '강의평 열람권 만료 일자' }) + date: Date; +} diff --git a/src/user/user.controller.ts b/src/user/user.controller.ts index dc5764ff..78457f3f 100644 --- a/src/user/user.controller.ts +++ b/src/user/user.controller.ts @@ -37,6 +37,7 @@ import { LanguageRequestDto, LanguageResponseDto, } from './dto/user-language.dto'; +import { CheckCourseReviewReadingTicketResponseDto } from './dto/check-course-review-reading-ticket.dto'; @ApiTags('User') @ApiBearerAuth('accessToken') @@ -189,6 +190,23 @@ export class UserController { ); } + @ApiOperation({ + summary: '강의평 열람권 만료 조회', + description: + '해당 사용자의 강의평 열람권이 만료되었는지 확인 후 만료되었으면 null, 만료되지 않았으면 강의평 열람권 만료일자를 반환합니다.', + }) + @ApiResponse({ + status: 200, + description: '강의평 열람권 만료 조회 성공', + type: CheckCourseReviewReadingTicketResponseDto, + }) + @Get('course-review-reading-ticket') + async checkCourseReviewReadingTicket( + @User() user: AuthorizedUserDto, + ): Promise { + return await this.userService.checkCourseReviewReadingTicket(user.id); + } + @ApiOperation({ summary: '회원탈퇴', description: '사용자의 계정을 삭제합니다.', diff --git a/src/user/user.service.ts b/src/user/user.service.ts index f2e636ed..4e036640 100644 --- a/src/user/user.service.ts +++ b/src/user/user.service.ts @@ -25,6 +25,7 @@ import { CharacterType } from 'src/enums/character-type.enum'; import { Language } from 'src/enums/language'; import { UserLanguageEntity } from 'src/entities/user-language.entity'; import { LanguageResponseDto } from './dto/user-language.dto'; +import { CheckCourseReviewReadingTicketResponseDto } from './dto/check-course-review-reading-ticket.dto'; @Injectable() export class UserService { @@ -392,4 +393,26 @@ export class UserService { return result; } + + async checkCourseReviewReadingTicket( + userId: number, + ): Promise { + const user = await this.userRepository.findOne({ + where: { + id: userId, + }, + }); + + if (!user) throw new NotFoundException('Cannot find user!'); + + const offset = 1000 * 60 * 60 * 9; // 9시간 밀리세컨드 값 + const koreaTime = new Date(Date.now() + offset); // 현재 시간 + + if (user.viewableUntil <= koreaTime) { + // 강의평 열람기간이 같을때도 만료되었다고 처리 + return null; + } + + return new CheckCourseReviewReadingTicketResponseDto(user.viewableUntil); + } } From 46a3b5e006a044a16b627a8e899a582412b1967c Mon Sep 17 00:00:00 2001 From: Devheun Date: Sun, 1 Sep 2024 00:57:47 +0900 Subject: [PATCH 3/3] =?UTF-8?q?mod::=20=EA=B0=95=EC=9D=98=20=EC=97=B4?= =?UTF-8?q?=EB=9E=8C=20=EB=A1=9C=EC=A7=81=20=EC=B4=88=20=EB=8B=A8=EC=9C=84?= =?UTF-8?q?=EB=A1=9C=20=EC=B2=B4=ED=81=AC=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20-=20=EC=B4=88=20=EB=8B=A8=EC=9C=84?= =?UTF-8?q?=EB=A1=9C=20=EC=B2=B4=ED=81=AC=ED=95=B4=EC=84=9C=20=EB=8D=94=20?= =?UTF-8?q?=EC=97=84=EB=B0=80=ED=95=98=EA=B2=8C=20=EA=B0=95=EC=9D=98?= =?UTF-8?q?=ED=8F=89=20=EC=97=B4=EB=9E=8C=EA=B6=8C=20=EA=B8=B0=ED=95=9C=20?= =?UTF-8?q?=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/course-review/course-review.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/course-review/course-review.service.ts b/src/course-review/course-review.service.ts index b96d58a9..071222b1 100644 --- a/src/course-review/course-review.service.ts +++ b/src/course-review/course-review.service.ts @@ -205,7 +205,8 @@ export class CourseReviewService { // 해당 과목의 강의평들 조회 (유저가 열람권 구매 안했으면 열람 불가 ) const viewableUser = await this.userService.findUserById(user.id); - if (viewableUser.viewableUntil.getDate() < koreaTime.getDate()) { + + if (viewableUser.viewableUntil <= koreaTime) { throw new ForbiddenException('열람권을 구매해야 합니다.'); }