From 2eadc2e776cf3a935f9086a46786dfa23451c831 Mon Sep 17 00:00:00 2001 From: gengminy Date: Tue, 9 Aug 2022 23:35:10 +0900 Subject: [PATCH 1/2] =?UTF-8?q?:hammer:=20fix(ticket):=20=ED=8B=B0?= =?UTF-8?q?=EC=BC=93=20=EC=A0=95=EC=B1=85=20=EC=88=98=EC=A0=95=20#126?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tickets/tickets.controller.ts | 9 +++++---- src/tickets/tickets.service.ts | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/tickets/tickets.controller.ts b/src/tickets/tickets.controller.ts index c48c69c..f3c5156 100644 --- a/src/tickets/tickets.controller.ts +++ b/src/tickets/tickets.controller.ts @@ -168,10 +168,11 @@ export class TicketsController { description: '요청 성공시', type: Ticket }) - @ApiUnauthorizedResponse({ - status: 401, - description: 'AccessToken 권한이 없을 경우' - }) + // @ApiUnauthorizedResponse({ + // status: 401, + // description: 'AccessToken 권한이 없을 경우' + // }) + @NoAuth() @Get('/:uuid') getTicketByUuid( @Param('uuid') diff --git a/src/tickets/tickets.service.ts b/src/tickets/tickets.service.ts index 5607868..c3107df 100644 --- a/src/tickets/tickets.service.ts +++ b/src/tickets/tickets.service.ts @@ -50,9 +50,9 @@ export class TicketsService { const ticket = await this.ticketRepository.findByUuid(ticketUuid); //어드민이거나 Ticket.user.id === user.id 일때만 리턴 - if (ticket.user.id !== user.id && user.role !== Role.Admin) { - throw new UnauthorizedException('해당 티켓에 대한 접근 권한이 없습니다'); - } + // if (ticket.user.id !== user.id && user.role !== Role.Admin) { + // throw new UnauthorizedException('해당 티켓에 대한 접근 권한이 없습니다'); + // } return ticket; } From db517204c82e859e35961f29d9b4ca092d872fc9 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: Tue, 9 Aug 2022 23:46:54 +0900 Subject: [PATCH 2/2] =?UTF-8?q?:hammer:=20fix(order)=20:=20=EA=BD=81?= =?UTF-8?q?=EC=9E=90=20=ED=8B=B0=EC=BC=93=20=EC=A0=95=EB=B3=B4=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80,=EC=96=B4=EB=93=9C=EB=AF=BC=20=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EB=A6=AC=ED=84=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/database/repositories/order.repository.ts | 8 ++++++-- src/orders/orders.controller.ts | 3 ++- src/orders/orders.service.ts | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/database/repositories/order.repository.ts b/src/database/repositories/order.repository.ts index 4310d41..6b431c5 100644 --- a/src/database/repositories/order.repository.ts +++ b/src/database/repositories/order.repository.ts @@ -63,6 +63,10 @@ export class OrderRepository { async findById(orderId: number): Promise { const order = await this.orderRepository .createQueryBuilder('order') + .leftJoin('order.user', 'user') + .addSelect(['user.id', 'user.name', 'user.phoneNumber', 'user.role']) + .leftJoin('order.admin', 'admin') + .addSelect(['admin.id', 'admin.name', 'admin.phoneNumber', 'admin.role']) .where({ id: orderId }) .getOne(); @@ -157,7 +161,7 @@ export class OrderRepository { .where({ status: OrderStatus.DONE }) .andWhere({ isFree: false }); - let income = await queryBuilder.getRawOne(); + const income = await queryBuilder.getRawOne(); if (income.sum == null) { income.sum = 0; } @@ -168,7 +172,7 @@ export class OrderRepository { const queryBuilderForFree = this.orderRepository.createQueryBuilder('order'); - let freeOrder = await queryBuilderForFree + const freeOrder = await queryBuilderForFree .select('SUM(order.ticketCount)', 'freeTicketCount') .where({ isFree: 'true' }) .getRawOne(); diff --git a/src/orders/orders.controller.ts b/src/orders/orders.controller.ts index 7dd5f02..aecead3 100644 --- a/src/orders/orders.controller.ts +++ b/src/orders/orders.controller.ts @@ -158,9 +158,10 @@ export class OrdersController { @Roles(Role.Admin) @Patch('/:orderId/free') makeOrderFree( + @ReqUser() admin: User, @Param('orderId', OrderIdValidationPipe) orderId: number ): Promise { - return this.orderService.makeOrderFree(orderId); + return this.orderService.makeOrderFree(orderId, admin); } @ApiOperation({ diff --git a/src/orders/orders.service.ts b/src/orders/orders.service.ts index ea9cd20..a8ad1c1 100644 --- a/src/orders/orders.service.ts +++ b/src/orders/orders.service.ts @@ -223,10 +223,11 @@ export class OrdersService { } } - async makeOrderFree(orderId: number): Promise { + async makeOrderFree(orderId: number, admin: User): Promise { // orderId로 주문 찾기 const order = await this.orderRepository.findById(orderId); order.isFree = true; + order.admin = admin; await this.orderRepository.saveOrder(order); return order; }