From 768ce6c34ad923f5da3c6bd15a575d4e703268cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=88=98=EC=A7=84?= <71487608+ssssujini99@users.noreply.github.com> Date: Sun, 14 Jan 2024 19:50:57 +0900 Subject: [PATCH] =?UTF-8?q?[refactor]:=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=A0=95=EB=A6=AC=20=EB=B0=8F=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20(#74)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: EunChanNam --- .../hooon/booking/BookingApiController.java | 41 +++++++++++++++++++ .../BookingCancelApiController.java | 37 ----------------- .../TicketBookingApiController.java | 41 ------------------- .../BookingCancelApiControllerTest.java | 2 +- .../TicketBookingApiControllerTest.java | 2 +- 5 files changed, 43 insertions(+), 80 deletions(-) delete mode 100644 api/src/main/java/dev/hooon/bookingcancel/BookingCancelApiController.java delete mode 100644 api/src/main/java/dev/hooon/ticketbooking/TicketBookingApiController.java rename api/src/test/java/dev/hooon/{bookingcancel => booking}/BookingCancelApiControllerTest.java (98%) rename api/src/test/java/dev/hooon/{ticketbooking => booking}/TicketBookingApiControllerTest.java (98%) diff --git a/api/src/main/java/dev/hooon/booking/BookingApiController.java b/api/src/main/java/dev/hooon/booking/BookingApiController.java index 3fbba769..15b9b2a3 100644 --- a/api/src/main/java/dev/hooon/booking/BookingApiController.java +++ b/api/src/main/java/dev/hooon/booking/BookingApiController.java @@ -4,22 +4,34 @@ import org.springframework.data.web.PageableDefault; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import dev.hooon.auth.annotation.NoAuth; import dev.hooon.auth.jwt.JwtAuthorization; import dev.hooon.booking.application.BookingService; +import dev.hooon.booking.application.fascade.TicketBookingFacade; +import dev.hooon.booking.dto.request.TicketBookingRequest; +import dev.hooon.booking.dto.response.BookingCancelResponse; import dev.hooon.booking.dto.response.BookingListResponse; +import dev.hooon.booking.dto.response.TicketBookingResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; +@Tag(name = "Booking API") @RestController @RequiredArgsConstructor public class BookingApiController { private final BookingService bookingService; + private final TicketBookingFacade ticketBookingFacade; @GetMapping("/api/users/booking") @Operation(summary = "예매 조회 API", description = "예매를 조회한다") @@ -36,4 +48,33 @@ public ResponseEntity getBookings( ); return ResponseEntity.ok(bookingListResponse); } + + @PostMapping("/api/bookings/cancel/{booking_id}") + @Operation(summary = "예매 취소 API", description = "예매를 취소한다") + @ApiResponse(responseCode = "200", useReturnTypeSchema = true) + public ResponseEntity cancelBooking( + @Parameter(hidden = true) @JwtAuthorization Long userId, + @PathVariable("booking_id") Long bookingId + ) { + BookingCancelResponse bookingCancelResponse = bookingService.cancelBooking( + userId, + bookingId + ); + return ResponseEntity.ok(bookingCancelResponse); + } + + @NoAuth + @PostMapping("/api/bookings") + @Operation(summary = "티켓 예매 API", description = "티켓을 예매한다") + @ApiResponse(responseCode = "200", useReturnTypeSchema = true) + public ResponseEntity bookingTicket( + @Parameter(hidden = true) @JwtAuthorization Long userId, + @Valid @RequestBody TicketBookingRequest ticketBookingRequest + ) { + TicketBookingResponse ticketBookingResponse = ticketBookingFacade.bookingTicket( + userId, + ticketBookingRequest.seatIds() + ); + return ResponseEntity.ok(ticketBookingResponse); + } } diff --git a/api/src/main/java/dev/hooon/bookingcancel/BookingCancelApiController.java b/api/src/main/java/dev/hooon/bookingcancel/BookingCancelApiController.java deleted file mode 100644 index 26fa07d8..00000000 --- a/api/src/main/java/dev/hooon/bookingcancel/BookingCancelApiController.java +++ /dev/null @@ -1,37 +0,0 @@ -package dev.hooon.bookingcancel; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -import dev.hooon.auth.jwt.JwtAuthorization; -import dev.hooon.booking.application.BookingService; -import dev.hooon.booking.dto.response.BookingCancelResponse; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; - -@Tag(name = "Booking API") -@RestController -@RequiredArgsConstructor -public class BookingCancelApiController { - - private final BookingService bookingService; - - @PostMapping("/api/bookings/cancel/{booking_id}") - @Operation(summary = "예매 취소 API", description = "예매를 취소한다") - @ApiResponse(responseCode = "200", useReturnTypeSchema = true) - public ResponseEntity cancelBooking( - @Parameter(hidden = true) @JwtAuthorization Long userId, - @PathVariable("booking_id") Long bookingId - ) { - BookingCancelResponse bookingCancelResponse = bookingService.cancelBooking( - userId, - bookingId - ); - return ResponseEntity.ok(bookingCancelResponse); - } -} diff --git a/api/src/main/java/dev/hooon/ticketbooking/TicketBookingApiController.java b/api/src/main/java/dev/hooon/ticketbooking/TicketBookingApiController.java deleted file mode 100644 index e15a091b..00000000 --- a/api/src/main/java/dev/hooon/ticketbooking/TicketBookingApiController.java +++ /dev/null @@ -1,41 +0,0 @@ -package dev.hooon.ticketbooking; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -import dev.hooon.auth.annotation.NoAuth; -import dev.hooon.auth.jwt.JwtAuthorization; -import dev.hooon.booking.application.fascade.TicketBookingFacade; -import dev.hooon.booking.dto.request.TicketBookingRequest; -import dev.hooon.booking.dto.response.TicketBookingResponse; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import lombok.RequiredArgsConstructor; - -@Tag(name = "Booking API") -@RestController -@RequiredArgsConstructor -public class TicketBookingApiController { - - private final TicketBookingFacade ticketBookingFacade; - - @NoAuth - @PostMapping("/api/bookings") - @Operation(summary = "티켓 예매 API", description = "티켓을 예매한다") - @ApiResponse(responseCode = "200", useReturnTypeSchema = true) - public ResponseEntity bookingTicket( - @Parameter(hidden = true) @JwtAuthorization Long userId, - @Valid @RequestBody TicketBookingRequest ticketBookingRequest - ) { - TicketBookingResponse ticketBookingResponse = ticketBookingFacade.bookingTicket( - userId, - ticketBookingRequest.seatIds() - ); - return ResponseEntity.ok(ticketBookingResponse); - } -} diff --git a/api/src/test/java/dev/hooon/bookingcancel/BookingCancelApiControllerTest.java b/api/src/test/java/dev/hooon/booking/BookingCancelApiControllerTest.java similarity index 98% rename from api/src/test/java/dev/hooon/bookingcancel/BookingCancelApiControllerTest.java rename to api/src/test/java/dev/hooon/booking/BookingCancelApiControllerTest.java index f2916874..67c1636e 100644 --- a/api/src/test/java/dev/hooon/bookingcancel/BookingCancelApiControllerTest.java +++ b/api/src/test/java/dev/hooon/booking/BookingCancelApiControllerTest.java @@ -1,4 +1,4 @@ -package dev.hooon.bookingcancel; +package dev.hooon.booking; import static org.springframework.http.HttpHeaders.*; import static org.springframework.http.MediaType.*; diff --git a/api/src/test/java/dev/hooon/ticketbooking/TicketBookingApiControllerTest.java b/api/src/test/java/dev/hooon/booking/TicketBookingApiControllerTest.java similarity index 98% rename from api/src/test/java/dev/hooon/ticketbooking/TicketBookingApiControllerTest.java rename to api/src/test/java/dev/hooon/booking/TicketBookingApiControllerTest.java index 00e38cc0..3f686482 100644 --- a/api/src/test/java/dev/hooon/ticketbooking/TicketBookingApiControllerTest.java +++ b/api/src/test/java/dev/hooon/booking/TicketBookingApiControllerTest.java @@ -1,4 +1,4 @@ -package dev.hooon.ticketbooking; +package dev.hooon.booking; import static org.springframework.http.HttpHeaders.*; import static org.springframework.http.MediaType.*;