Skip to content

Commit

Permalink
Merge branch 'dev' into feat/#39/find-shows-api
Browse files Browse the repository at this point in the history
  • Loading branch information
ParkJuhan94 committed Jan 10, 2024
2 parents 9278bde + 4a5eee9 commit f603941
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 3 deletions.
2 changes: 2 additions & 0 deletions api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework:spring-tx:6.1.1'
//swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0'

implementation project(':core')
testImplementation(testFixtures(project(':core')))
Expand Down
8 changes: 8 additions & 0 deletions api/src/main/java/dev/hooon/auth/AuthApiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
import dev.hooon.auth.dto.request.AuthRequest;

import dev.hooon.auth.dto.response.AuthResponse;
import io.swagger.v3.oas.annotations.Operation;
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 = "Auth API")
@RequestMapping("/api/auth")
@RestController
@RequiredArgsConstructor
Expand All @@ -24,6 +28,8 @@ public class AuthApiController {

@NoAuth
@PostMapping("/login")
@Operation(summary = "로그인 API", description = "로그인을 한다")
@ApiResponse(responseCode = "200", useReturnTypeSchema = true)
public ResponseEntity<AuthResponse> login(
@Valid @RequestBody AuthRequest authRequest
) {
Expand All @@ -33,6 +39,8 @@ public ResponseEntity<AuthResponse> login(

@NoAuth
@PostMapping("/token")
@Operation(summary = "토큰 재발급 API", description = "토큰을 재발급한다")
@ApiResponse(responseCode = "200", useReturnTypeSchema = true)
public ResponseEntity<String> reIssueAccessToken(
@RequestBody TokenReIssueRequest tokenReIssueRequest
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
import dev.hooon.auth.annotation.NoAuth;
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.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;

@Tag(name = "Booking API")
@RestController
@RequiredArgsConstructor
public class BookingCancelApiController {
Expand All @@ -19,6 +23,8 @@ public class BookingCancelApiController {

@NoAuth
@PostMapping("/api/bookings/cancel/{booking_id}")
@Operation(summary = "예매 취소 API", description = "예매를 취소한다")
@ApiResponse(responseCode = "200", useReturnTypeSchema = true)
public ResponseEntity<BookingCancelResponse> cancelBooking(
@RequestParam(name = "userId") Long userId, // TODO
@PathVariable("booking_id") Long bookingId
Expand Down
47 changes: 47 additions & 0 deletions api/src/main/java/dev/hooon/common/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package dev.hooon.common.config;

import static org.springframework.http.HttpHeaders.*;

import java.util.List;

import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;

@OpenAPIDefinition(
info = @Info(
title = "hooon interpark API",
description = "hooon interpark API 명세",
version = "v1"))
@Configuration
public class SwaggerConfig {

@Bean
public OpenAPI openAPI(){
SecurityScheme securityScheme = new SecurityScheme()
.type(SecurityScheme.Type.HTTP)
.in(SecurityScheme.In.HEADER).name(AUTHORIZATION);
SecurityRequirement securityRequirement = new SecurityRequirement().addList(AUTHORIZATION);

return new OpenAPI()
.components(new Components().addSecuritySchemes(AUTHORIZATION, securityScheme))
.security(List.of(securityRequirement));
}

@Bean
public GroupedOpenApi chatOpenApi() {
String[] paths = {"/api/**"};

return GroupedOpenApi.builder()
.group("API v1")
.pathsToMatch(paths)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.hooon.common.exception.config;
package dev.hooon.common.config;

import java.util.List;

Expand Down
6 changes: 6 additions & 0 deletions api/src/main/java/dev/hooon/show/RankingApiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
import dev.hooon.show.application.facade.RankingCacheFacade;
import dev.hooon.show.dto.request.RankingRequest;
import dev.hooon.show.dto.response.RankingResponse;
import io.swagger.v3.oas.annotations.Operation;
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 = "Ranking API")
@RestController
@RequiredArgsConstructor
public class RankingApiController {
Expand All @@ -20,6 +24,8 @@ public class RankingApiController {

@NoAuth
@GetMapping("/api/shows/ranking")
@Operation(summary = "랭킹 조회 API", description = "카테고리, 집계기간별 랭킹을 조회한다")
@ApiResponse(responseCode = "200", useReturnTypeSchema = true)
public ResponseEntity<RankingResponse> getShowRanking(@Valid @ModelAttribute RankingRequest request) {
RankingResponse rankingResponse = rankingCacheFacade.getShowRankingWithCache(request);
return ResponseEntity.ok(rankingResponse);
Expand Down
6 changes: 6 additions & 0 deletions api/src/main/java/dev/hooon/show/ShowApiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
import dev.hooon.auth.annotation.NoAuth;
import dev.hooon.show.application.ShowService;
import dev.hooon.show.dto.response.AbleBookingDateRoundResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;

@Tag(name = "Show API")
@RestController
@RequiredArgsConstructor
public class ShowApiController {
Expand All @@ -18,6 +22,8 @@ public class ShowApiController {

@NoAuth
@GetMapping("/api/shows/{show_id}/available")
@Operation(summary = "공연 예매가능 날짜, 회차 조회 API", description = "공연의 예매 가능한 날짜와 회차 정보를 조회한다")
@ApiResponse(responseCode = "200", useReturnTypeSchema = true)
public ResponseEntity<AbleBookingDateRoundResponse> getAbleBookingDateRoundInfo(
@PathVariable("show_id") Long showId
) {
Expand Down
6 changes: 6 additions & 0 deletions api/src/main/java/dev/hooon/show/ShowDetailApiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
import dev.hooon.auth.annotation.NoAuth;
import dev.hooon.show.application.ShowService;
import dev.hooon.show.dto.response.ShowDetailsInfoResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;

@Tag(name = "Show API")
@RestController
@RequiredArgsConstructor
public class ShowDetailApiController {
Expand All @@ -18,6 +22,8 @@ public class ShowDetailApiController {

@NoAuth
@GetMapping("/api/shows/{show_id}")
@Operation(summary = "공연 상세정보 조회 API", description = "공연의 상세정보를 조회한다")
@ApiResponse(responseCode = "200", useReturnTypeSchema = true)
public ResponseEntity<ShowDetailsInfoResponse> getShowDetailInfo(
@PathVariable("show_id") Long showId
) {
Expand Down
8 changes: 8 additions & 0 deletions api/src/main/java/dev/hooon/show/ShowSeatsApiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
import dev.hooon.show.dto.request.BookedSeatQueryRequest;
import dev.hooon.show.dto.response.ShowSeatResponse;
import dev.hooon.show.dto.response.seats.ShowSeatsResponse;
import io.swagger.v3.oas.annotations.Operation;
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 = "Show API")
@RestController
@RequiredArgsConstructor
public class ShowSeatsApiController {
Expand All @@ -28,6 +32,8 @@ public class ShowSeatsApiController {

@NoAuth
@GetMapping("/api/shows/{showId}/seats")
@Operation(summary = "공연 예매할 날짜, 회차의 좌석정보 조회 API", description = "공연의 예매할 날짜, 회차에 해당하는 좌석 정보를 조회한다")
@ApiResponse(responseCode = "200", useReturnTypeSchema = true)
public ResponseEntity<ShowSeatsResponse> getShowSeatsInfo(
@PathVariable("showId") Long showId,
@RequestParam("date") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date,
Expand All @@ -41,6 +47,8 @@ public ResponseEntity<ShowSeatsResponse> getShowSeatsInfo(

@NoAuth
@GetMapping("/api/shows/seats/booked")
@Operation(summary = "공연 예매할 날짜, 회차의 예매된 좌석정보 조회 API", description = "공연의 예매할 날짜, 회차에 예매된 좌석정보를 조회한다")
@ApiResponse(responseCode = "200", useReturnTypeSchema = true)
public ResponseEntity<ShowSeatResponse> getBookedSeatInfo(
@Valid @ModelAttribute BookedSeatQueryRequest request
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
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.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 {
Expand All @@ -21,6 +25,8 @@ public class TicketBookingApiController {

@NoAuth
@PostMapping("/api/bookings")
@Operation(summary = "티켓 예매 API", description = "티켓을 예매한다")
@ApiResponse(responseCode = "200", useReturnTypeSchema = true)
public ResponseEntity<TicketBookingResponse> bookingTicket(
@RequestParam(name = "userId") Long userId, // TODO
@Valid @RequestBody TicketBookingRequest ticketBookingRequest
Expand Down
6 changes: 6 additions & 0 deletions api/src/main/java/dev/hooon/user/UserApiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
import dev.hooon.user.application.UserService;
import dev.hooon.user.dto.request.UserJoinRequest;
import dev.hooon.user.dto.response.UserJoinResponse;
import io.swagger.v3.oas.annotations.Operation;
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 = "User API")
@RestController
@RequiredArgsConstructor
public class UserApiController {
Expand All @@ -20,6 +24,8 @@ public class UserApiController {

@NoAuth
@PostMapping("/api/users")
@Operation(summary = "회원가입 API", description = "회원가입을 한다")
@ApiResponse(responseCode = "200", useReturnTypeSchema = true)
public ResponseEntity<UserJoinResponse> join(
final @Valid @RequestBody UserJoinRequest userJoinRequest
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
import dev.hooon.waitingbooking.application.facade.WaitingBookingFacade;
import dev.hooon.waitingbooking.dto.request.WaitingRegisterRequest;
import dev.hooon.waitingbooking.dto.response.WaitingRegisterResponse;
import io.swagger.v3.oas.annotations.Operation;
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 = "Waiting Booking API")
@RestController
@RequiredArgsConstructor
public class WaitingBookingApiController {
Expand All @@ -21,6 +25,8 @@ public class WaitingBookingApiController {

@NoAuth
@PostMapping("/api/waiting_bookings")
@Operation(summary = "예매대기 등록 API", description = "예매된 좌석에 대해서 예매대기를 등록한다")
@ApiResponse(responseCode = "200", useReturnTypeSchema = true)
public ResponseEntity<WaitingRegisterResponse> registerWaitingBooking(
@RequestParam(name = "userId") Long userId, // TODO 추후에 인증정보 ArgumentResolver 가 구현되면 수정 예정
@Valid @RequestBody WaitingRegisterRequest request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ void scheduleExpiredWaitingBookingProcess_test() {
userRepository.save(user);

LocalDateTime now = LocalDateTime.of(2023, 11, 16, 12, 12);
LocalDateTime beforeNow = now.minusSeconds(10);
LocalDateTime afterNow = now.plusSeconds(10);
LocalDateTime beforeNow = now.minusSeconds(100);
LocalDateTime afterNow = now.plusSeconds(100);
// 스케줄러 기준시간 동적으로 조정
given(nowLocalDateTime.get()).willReturn(now);

Expand Down

0 comments on commit f603941

Please sign in to comment.