From c46639bf55f0b10463d9c9e244221da7b3f89159 Mon Sep 17 00:00:00 2001 From: gengminy Date: Wed, 3 Aug 2022 12:35:18 +0900 Subject: [PATCH 1/2] =?UTF-8?q?:hammer:=20refactor(ticket):=20=ED=8B=B0?= =?UTF-8?q?=EC=BC=93=20=EC=9E=85=EC=9E=A5=20=EC=9D=91=EB=8B=B5=20=EC=98=88?= =?UTF-8?q?=EC=8B=9C=20=EC=B6=94=EA=B0=80=20#118?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tickets/tickets.controller.ts | 61 +++++++++++++++++++++++++++++-- src/tickets/tickets.service.ts | 1 + 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/tickets/tickets.controller.ts b/src/tickets/tickets.controller.ts index 5c30efa..3255d8c 100644 --- a/src/tickets/tickets.controller.ts +++ b/src/tickets/tickets.controller.ts @@ -37,6 +37,7 @@ import { PageDto } from 'src/common/dtos/page/page.dto'; import { NoAuth } from 'src/auth/guards/NoAuth.guard'; import { TicketCountDto } from './dtos/ticket-count.dto'; import { ErrorResponse } from 'src/common/decorators/ErrorResponse.decorator'; +import { TicketEntryResponseDto } from './dtos/ticket-entry-response.dto'; @ApiTags('tickets') @ApiBearerAuth('accessToken') @@ -70,7 +71,7 @@ export class TicketsController { } @ApiOperation({ - summary: '[어드민]해당 조건의 티켓을 모두 불러온다, querystring으로 전달' + summary: '[어드민]해당 조건의 티켓을 모두 불러온다' }) // @ApiResponse({ // status: 200, @@ -181,14 +182,68 @@ export class TicketsController { return this.ticketService.findByUuid(uuid, user); } + @ErrorResponse(HttpStatus.BAD_REQUEST, [ + { + model: BadRequestException, + exampleDescription: '이미 입장 완료된 티켓', + exampleTitle: 'status:400 BadRequestException DONE', + message: '이미 입장 완료된 티켓입니다' + }, + { + model: BadRequestException, + exampleDescription: '입금 기한이 만료된 티켓', + exampleTitle: 'status:400 BadRequestException EXPIRE', + message: '입금 기한이 만료된 티켓입니다' + }, + { + model: BadRequestException, + exampleDescription: '입금 대기중인 티켓', + exampleTitle: 'status:400 BadRequestException ORDERWAIT', + message: '입금 대기중인 티켓입니다' + }, + { + model: BadRequestException, + exampleDescription: 'Body 파라미터와 타켓 공연 날짜가 일치하지 않음', + exampleTitle: 'status:400 BadRequestException Date', + message: '공연 날짜가 일치하지 않습니다' + }, + { + model: BadRequestException, + exampleDescription: 'Body 파라미터와 타켓 공연 날짜가 일치하지 않음', + exampleTitle: 'status:400 BadRequestException Date', + message: '공연 날짜가 일치하지 않습니다' + }, + { + model: BadRequestException, + exampleDescription: 'Body 파라미터 검증 오류', + exampleTitle: 'status:400 BadRequestException Validation', + message: '검증 오류' + } + ]) + @ErrorResponse(HttpStatus.UNAUTHORIZED, [ + { + model: UnauthorizedException, + exampleDescription: '엑세스 토큰이 없거나 어드민이 아닐 경우 접근 제어', + exampleTitle: 'status:401 UnauthorizedException', + message: '잘못된 헤더 요청' + } + ]) + @ErrorResponse(HttpStatus.NOT_FOUND, [ + { + model: NotFoundException, + exampleDescription: 'Ticket uuid 입력 오류입니다', + exampleTitle: 'status:404 NotFoundException', + message: "Can't find Ticket with uuid {ticketId}" + } + ]) @ApiOperation({ summary: '[어드민] 티켓 QR코드 찍었을 때 uuid를 받아 소켓 이벤트를 전송한다' }) @ApiBody({ type: TicketEntryDateValidationDto }) @ApiResponse({ - status: 200 || 201, + status: 201, description: '요청 성공시', - type: TicketEntryDateValidationDto + type: TicketEntryResponseDto }) @ApiUnauthorizedResponse({ status: 401, diff --git a/src/tickets/tickets.service.ts b/src/tickets/tickets.service.ts index ef0e6b6..9dfd1c9 100644 --- a/src/tickets/tickets.service.ts +++ b/src/tickets/tickets.service.ts @@ -150,6 +150,7 @@ export class TicketsService { await connectedRepository.saveTicket(ticket); response.message = `[입장성공] ${ticket.user?.name}님이 입장하셨습니다`; + response.success = true; this.logger.log(`${ticket.user?.name}님이 입장하셨습니다`); this.socketService.emitToAll(response); From df2389b6dc9198c3cc8404fbd26c18f085e7c70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=B5=E1=84=8E=E1=85=A1=E1=86=AB=E1=84=8C?= =?UTF-8?q?=E1=85=B5=E1=86=AB?= Date: Wed, 3 Aug 2022 12:40:29 +0900 Subject: [PATCH 2/2] =?UTF-8?q?:hammer:=20fix(auth)=20:=20dto=20=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=9D=B8=EC=A6=9D=EB=B2=88=ED=98=B8=20exclude=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auth/dtos/AdminSendValidationNumber.response.dto.ts | 4 ++-- src/auth/dtos/RequestValidation.response.dto.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/auth/dtos/AdminSendValidationNumber.response.dto.ts b/src/auth/dtos/AdminSendValidationNumber.response.dto.ts index bbbef12..aef0fee 100644 --- a/src/auth/dtos/AdminSendValidationNumber.response.dto.ts +++ b/src/auth/dtos/AdminSendValidationNumber.response.dto.ts @@ -1,5 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; -import { Expose } from 'class-transformer'; +import { Exclude, Expose } from 'class-transformer'; import { IsEmail, IsMobilePhone } from 'class-validator'; export class ResponseAdminSendValidationNumberDto { @@ -11,6 +11,6 @@ export class ResponseAdminSendValidationNumberDto { isArray: true, example: 'asdf' }) - @Expose() + @Exclude() validationNumber: string; } diff --git a/src/auth/dtos/RequestValidation.response.dto.ts b/src/auth/dtos/RequestValidation.response.dto.ts index 78b23b2..86ed562 100644 --- a/src/auth/dtos/RequestValidation.response.dto.ts +++ b/src/auth/dtos/RequestValidation.response.dto.ts @@ -1,5 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; -import { Expose } from 'class-transformer'; +import { Exclude, Expose } from 'class-transformer'; export class ResponseRequestValidationDto { @ApiProperty({ description: '요청보낸 전화번호', type: String }) @@ -7,7 +7,7 @@ export class ResponseRequestValidationDto { phoneNumber: string; @ApiProperty({ description: '테스트용 인증번호', type: String }) - @Expose() + @Exclude() validationNumber: string; @ApiProperty({ description: '이미 가입했는지에대한 정보', type: Boolean })