style: Reformat Code & Optimize Imports

This commit is contained in:
이상진 2025-07-27 23:28:29 +09:00
parent 57c890cc64
commit 957996baf6
64 changed files with 766 additions and 729 deletions

View File

@ -16,7 +16,8 @@ class SwaggerConfig {
private fun apiInfo(): Info { private fun apiInfo(): Info {
return Info() return Info()
.title("방탈출 예약 API 문서") .title("방탈출 예약 API 문서")
.description(""" .description(
"""
## API 테스트는 '1. 인증 / 인가 API' '/login' 통해 로그인 사용해주세요. ## API 테스트는 '1. 인증 / 인가 API' '/login' 통해 로그인 사용해주세요.
### 테스트시 로그인 가능한 계정 정보 ### 테스트시 로그인 가능한 계정 정보
@ -70,7 +71,8 @@ class SwaggerConfig {
- 8 ~ 10: 예약 대기 상태 - 8 ~ 10: 예약 대기 상태
""".trimIndent()) """.trimIndent()
)
.version("1.0.0") .version("1.0.0")
} }
} }

View File

@ -64,7 +64,11 @@ interface ReservationAPI {
responseCode = "201", responseCode = "201",
description = "성공", description = "성공",
useReturnTypeSchema = true, useReturnTypeSchema = true,
headers = [Header(name = HttpHeaders.LOCATION, description = "생성된 예약 정보 URL", schema = Schema(example = "/reservations/1"))] headers = [Header(
name = HttpHeaders.LOCATION,
description = "생성된 예약 정보 URL",
schema = Schema(example = "/reservations/1")
)]
) )
) )
fun createReservationWithPayment( fun createReservationWithPayment(
@ -79,7 +83,11 @@ interface ReservationAPI {
responseCode = "201", responseCode = "201",
description = "성공", description = "성공",
useReturnTypeSchema = true, useReturnTypeSchema = true,
headers = [Header(name = HttpHeaders.LOCATION, description = "생성된 예약 정보 URL", schema = Schema(example = "/reservations/1"))], headers = [Header(
name = HttpHeaders.LOCATION,
description = "생성된 예약 정보 URL",
schema = Schema(example = "/reservations/1")
)],
) )
) )
fun createReservationByAdmin( fun createReservationByAdmin(
@ -98,7 +106,11 @@ interface ReservationAPI {
responseCode = "201", responseCode = "201",
description = "성공", description = "성공",
useReturnTypeSchema = true, useReturnTypeSchema = true,
headers = [Header(name = HttpHeaders.LOCATION, description = "생성된 예약 정보 URL", schema = Schema(example = "/reservations/1"))] headers = [Header(
name = HttpHeaders.LOCATION,
description = "생성된 예약 정보 URL",
schema = Schema(example = "/reservations/1")
)]
) )
) )
fun createWaiting( fun createWaiting(

View File

@ -16,17 +16,20 @@ interface ReservationRepository
fun findByDateAndThemeId(date: LocalDate, themeId: Long): List<ReservationEntity> fun findByDateAndThemeId(date: LocalDate, themeId: Long): List<ReservationEntity>
@Modifying @Modifying
@Query(""" @Query(
"""
UPDATE ReservationEntity r UPDATE ReservationEntity r
SET r.reservationStatus = :status SET r.reservationStatus = :status
WHERE r.id = :id WHERE r.id = :id
""") """
)
fun updateStatusByReservationId( fun updateStatusByReservationId(
@Param(value = "id") reservationId: Long, @Param(value = "id") reservationId: Long,
@Param(value = "status") statusForChange: ReservationStatus @Param(value = "status") statusForChange: ReservationStatus
): Int ): Int
@Query(""" @Query(
"""
SELECT EXISTS ( SELECT EXISTS (
SELECT 1 SELECT 1
FROM ReservationEntity r2 FROM ReservationEntity r2
@ -39,10 +42,12 @@ interface ReservationRepository
AND r.reservationStatus != 'WAITING' AND r.reservationStatus != 'WAITING'
) )
) )
""") """
)
fun isExistConfirmedReservation(@Param("id") reservationId: Long): Boolean fun isExistConfirmedReservation(@Param("id") reservationId: Long): Boolean
@Query(""" @Query(
"""
SELECT new roomescape.reservation.web.MyReservationRetrieveResponse( SELECT new roomescape.reservation.web.MyReservationRetrieveResponse(
r.id, r.id,
t.name, t.name,
@ -58,6 +63,7 @@ interface ReservationRepository
LEFT JOIN PaymentEntity p LEFT JOIN PaymentEntity p
ON p.reservation = r ON p.reservation = r
WHERE r.member.id = :memberId WHERE r.member.id = :memberId
""") """
)
fun findAllByMemberId(memberId: Long): List<MyReservationRetrieveResponse> fun findAllByMemberId(memberId: Long): List<MyReservationRetrieveResponse>
} }

View File

@ -67,8 +67,10 @@ class ReservationController(
val paymentCancelRequest = reservationWithPaymentService.deleteReservationAndPayment(reservationId, memberId) val paymentCancelRequest = reservationWithPaymentService.deleteReservationAndPayment(reservationId, memberId)
val paymentCancelResponse = paymentClient.cancel(paymentCancelRequest) val paymentCancelResponse = paymentClient.cancel(paymentCancelRequest)
reservationWithPaymentService.updateCanceledTime(paymentCancelRequest.paymentKey, reservationWithPaymentService.updateCanceledTime(
paymentCancelResponse.canceledAt) paymentCancelRequest.paymentKey,
paymentCancelResponse.canceledAt
)
return ResponseEntity.noContent().build() return ResponseEntity.noContent().build()
} }
@ -82,7 +84,8 @@ class ReservationController(
val paymentResponse: PaymentApproveResponse = paymentClient.confirm(paymentRequest) val paymentResponse: PaymentApproveResponse = paymentClient.confirm(paymentRequest)
try { try {
val reservationRetrieveResponse: ReservationRetrieveResponse = reservationWithPaymentService.createReservationAndPayment( val reservationRetrieveResponse: ReservationRetrieveResponse =
reservationWithPaymentService.createReservationAndPayment(
reservationCreateWithPaymentRequest, reservationCreateWithPaymentRequest,
paymentResponse, paymentResponse,
memberId memberId
@ -90,11 +93,17 @@ class ReservationController(
return ResponseEntity.created(URI.create("/reservations/${reservationRetrieveResponse.id}")) return ResponseEntity.created(URI.create("/reservations/${reservationRetrieveResponse.id}"))
.body(CommonApiResponse(reservationRetrieveResponse)) .body(CommonApiResponse(reservationRetrieveResponse))
} catch (e: Exception) { } catch (e: Exception) {
val cancelRequest = PaymentCancelRequest(paymentRequest.paymentKey, val cancelRequest = PaymentCancelRequest(
paymentRequest.amount, e.message!!) paymentRequest.paymentKey,
paymentRequest.amount,
e.message!!
)
val paymentCancelResponse = paymentClient.cancel(cancelRequest) val paymentCancelResponse = paymentClient.cancel(cancelRequest)
reservationWithPaymentService.createCanceledPayment(paymentCancelResponse, paymentResponse.approvedAt, reservationWithPaymentService.createCanceledPayment(
paymentRequest.paymentKey) paymentCancelResponse,
paymentResponse.approvedAt,
paymentRequest.paymentKey
)
throw e throw e
} }
} }

View File

@ -6,7 +6,8 @@ import java.time.LocalDate
interface ThemeRepository : JpaRepository<ThemeEntity, Long> { interface ThemeRepository : JpaRepository<ThemeEntity, Long> {
@Query(value = """ @Query(
value = """
SELECT t SELECT t
FROM ThemeEntity t FROM ThemeEntity t
RIGHT JOIN ReservationEntity r ON t.id = r.theme.id RIGHT JOIN ReservationEntity r ON t.id = r.theme.id
@ -20,12 +21,14 @@ interface ThemeRepository : JpaRepository<ThemeEntity, Long> {
fun existsByName(name: String): Boolean fun existsByName(name: String): Boolean
@Query(value = """ @Query(
value = """
SELECT EXISTS( SELECT EXISTS(
SELECT 1 SELECT 1
FROM ReservationEntity r FROM ReservationEntity r
WHERE r.theme.id = :id WHERE r.theme.id = :id
) )
""") """
)
fun isReservedTheme(id: Long): Boolean fun isReservedTheme(id: Long): Boolean
} }

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<included> <included>
<conversionRule conversionWord="maskedMessage" <conversionRule conversionWord="maskedMessage"
class="roomescape.common.log.RoomescapeLogMaskingConverter" /> class="roomescape.common.log.RoomescapeLogMaskingConverter"/>
<property name="CONSOLE_LOG_PATTERN" <property name="CONSOLE_LOG_PATTERN"
value="%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) %green(${PID:- }) --- [%15.15thread] %cyan(%-40logger{36}) : %maskedMessage%n%throwable"/> value="%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) %green(${PID:- }) --- [%15.15thread] %cyan(%-40logger{36}) : %maskedMessage%n%throwable"/>

View File

@ -27,9 +27,11 @@ class ReservationRepositoryTest(
beforeTest { beforeTest {
listOf( listOf(
ReservationFixture.create(time = time), ReservationFixture.create(time = time),
ReservationFixture.create(time = TimeFixture.create( ReservationFixture.create(
time = TimeFixture.create(
startAt = time.startAt.plusSeconds(1) startAt = time.startAt.plusSeconds(1)
)) )
)
).forEach { ).forEach {
persistReservation(it) persistReservation(it)
} }
@ -124,7 +126,8 @@ class ReservationRepositoryTest(
persistReservation(it) persistReservation(it)
} }
confirmedPaymentRequired = ReservationFixture.create(status = ReservationStatus.CONFIRMED_PAYMENT_REQUIRED).also { confirmedPaymentRequired =
ReservationFixture.create(status = ReservationStatus.CONFIRMED_PAYMENT_REQUIRED).also {
persistReservation(it) persistReservation(it)
} }
@ -168,7 +171,8 @@ class ReservationRepositoryTest(
entityManager.clear() entityManager.clear()
} }
val result: List<MyReservationRetrieveResponse> = reservationRepository.findAllByMemberId(reservation.member.id!!) val result: List<MyReservationRetrieveResponse> =
reservationRepository.findAllByMemberId(reservation.member.id!!)
result shouldHaveSize 1 result shouldHaveSize 1
assertSoftly(result.first()) { assertSoftly(result.first()) {
@ -179,7 +183,8 @@ class ReservationRepositoryTest(
} }
test("결제 정보가 없다면 paymentKey와 amount는 null로 반환한다.") { test("결제 정보가 없다면 paymentKey와 amount는 null로 반환한다.") {
val result: List<MyReservationRetrieveResponse> = reservationRepository.findAllByMemberId(reservation.member.id!!) val result: List<MyReservationRetrieveResponse> =
reservationRepository.findAllByMemberId(reservation.member.id!!)
result shouldHaveSize 1 result shouldHaveSize 1
assertSoftly(result.first()) { assertSoftly(result.first()) {