Skip to content

Commit be0bb56

Browse files
committed
✨ feat: 관리자 기능: 이벤트 예약 상태 초기화
Issue Resolved: #233
1 parent 39b5d7b commit be0bb56

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

back/src/domains/booking/controller/booking.controller.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,16 @@ export class BookingController {
195195
async reloadOpenTarget() {
196196
await this.openBookingService.scheduleUpcomingReservations();
197197
}
198+
199+
@Post('init/:eventId')
200+
@UseGuards(SessionAuthGuard(USER_STATUS.ADMIN))
201+
@ApiOperation({
202+
summary: 'ADMIN: 예약 초기화',
203+
description: '특정 이벤트의 예약 상태를 초기화한다.',
204+
})
205+
@ApiOkResponse({ description: '예약 초기화 완료' })
206+
@ApiUnauthorizedResponse({ description: '인증 실패' })
207+
async initReservation(@Param('eventId') eventId: number) {
208+
await this.openBookingService.initReservation(eventId);
209+
}
198210
}

back/src/domains/booking/service/open-booking.service.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export class OpenBookingService implements OnApplicationBootstrap {
4141
await this.scheduleUpcomingReservations();
4242
}
4343

44+
async initReservation(eventId: number) {
45+
await this.closeReservationAnyway(eventId);
46+
await this.openReservationById(eventId);
47+
}
48+
4449
@Cron(ONE_MINUTE_BEFORE_THE_HOUR)
4550
async scheduleUpcomingReservations() {
4651
const comingEvents = await this.eventRepository.selectUpcomingEvents();
@@ -156,6 +161,14 @@ export class OpenBookingService implements OnApplicationBootstrap {
156161
await this.redis.set(`open-booking:${eventId}:opened`, 'true');
157162
}
158163

164+
async closeReservationAnyway(eventId: number) {
165+
await this.unlinkOpenedEvent(eventId);
166+
await this.clearWaitingService(eventId);
167+
await this.clearEnteringService(eventId);
168+
await this.seatsUpdateService.clearSeatsSubscription(eventId);
169+
await this.clearInBookingService(eventId);
170+
}
171+
159172
async closeReservation(eventId: number) {
160173
await this.validateClosingEvent(eventId);
161174
await this.unlinkOpenedEvent(eventId);

0 commit comments

Comments
 (0)