diff --git a/src/main/kotlin/roomescape/reservation/business/ReservationService.kt b/src/main/kotlin/roomescape/reservation/business/ReservationService.kt index f59889e9..e7d20335 100644 --- a/src/main/kotlin/roomescape/reservation/business/ReservationService.kt +++ b/src/main/kotlin/roomescape/reservation/business/ReservationService.kt @@ -22,7 +22,7 @@ import roomescape.schedule.infrastructure.persistence.ScheduleStatus import roomescape.schedule.web.ScheduleSummaryResponse import roomescape.schedule.web.ScheduleUpdateRequest import roomescape.theme.business.ThemeService -import roomescape.theme.web.ThemeSummaryResponse +import roomescape.theme.web.ThemeInfoRetrieveResponse import java.time.LocalDateTime private val log: KLogger = KotlinLogging.logger {} @@ -96,7 +96,7 @@ class ReservationService( return ReservationSummaryRetrieveListResponse(reservations.map { val schedule: ScheduleSummaryResponse = scheduleService.findSummaryById(it.scheduleId) - val theme: ThemeSummaryResponse = themeService.findSummaryById(schedule.themeId) + val theme: ThemeInfoRetrieveResponse = themeService.findSummaryById(schedule.themeId) ReservationSummaryRetrieveResponse( id = it.id, diff --git a/src/main/kotlin/roomescape/reservation/business/ReservationValidator.kt b/src/main/kotlin/roomescape/reservation/business/ReservationValidator.kt index 2bcdaea8..ecc92dcd 100644 --- a/src/main/kotlin/roomescape/reservation/business/ReservationValidator.kt +++ b/src/main/kotlin/roomescape/reservation/business/ReservationValidator.kt @@ -8,7 +8,7 @@ import roomescape.reservation.exception.ReservationException import roomescape.reservation.web.PendingReservationCreateRequest import roomescape.schedule.infrastructure.persistence.ScheduleStatus import roomescape.schedule.web.ScheduleSummaryResponse -import roomescape.theme.web.ThemeSummaryResponse +import roomescape.theme.web.ThemeInfoRetrieveResponse private val log: KLogger = KotlinLogging.logger {} @@ -17,7 +17,7 @@ class ReservationValidator { fun validateCanCreate( schedule: ScheduleSummaryResponse, - theme: ThemeSummaryResponse, + theme: ThemeInfoRetrieveResponse, request: PendingReservationCreateRequest ) { if (schedule.status != ScheduleStatus.HOLD) { diff --git a/src/main/kotlin/roomescape/theme/business/ThemeService.kt b/src/main/kotlin/roomescape/theme/business/ThemeService.kt index 66778111..60171bef 100644 --- a/src/main/kotlin/roomescape/theme/business/ThemeService.kt +++ b/src/main/kotlin/roomescape/theme/business/ThemeService.kt @@ -24,7 +24,7 @@ class ThemeService( private val adminService: AdminService ) { @Transactional(readOnly = true) - fun findThemesByIds(request: ThemeListRetrieveRequest): ThemeSummaryListResponse { + fun findThemesByIds(request: ThemeIdListRetrieveResponse): ThemeInfoListRetrieveResponse { log.info { "[ThemeService.findThemesByIds] 예약 페이지에서의 테마 목록 조회 시작: themeIds=${request.themeIds}" } val result: MutableList = mutableListOf() @@ -43,7 +43,7 @@ class ThemeService( } @Transactional(readOnly = true) - fun findThemesForReservation(): ThemeSummaryListResponse { + fun findThemesForReservation(): ThemeInfoListRetrieveResponse { log.info { "[ThemeService.findThemesForReservation] 예약 페이지에서의 테마 목록 조회 시작" } return themeRepository.findOpenedThemes() @@ -52,7 +52,7 @@ class ThemeService( } @Transactional(readOnly = true) - fun findAdminThemes(): AdminThemeSummaryRetrieveListResponse { + fun findAdminThemes(): AdminThemeSummaryListRetrieveResponse { log.info { "[ThemeService.findAdminThemes] 관리자 페이지에서의 테마 목록 조회 시작" } return themeRepository.findAll() @@ -74,7 +74,7 @@ class ThemeService( } @Transactional(readOnly = true) - fun findSummaryById(id: Long): ThemeSummaryResponse { + fun findSummaryById(id: Long): ThemeInfoRetrieveResponse { log.info { "[ThemeService.findById] 테마 조회 시작: id=$id" } return findOrThrow(id).toSummaryResponse() diff --git a/src/main/kotlin/roomescape/theme/docs/ThemeApi.kt b/src/main/kotlin/roomescape/theme/docs/ThemeApi.kt index d07cc8ce..e11e4dfd 100644 --- a/src/main/kotlin/roomescape/theme/docs/ThemeApi.kt +++ b/src/main/kotlin/roomescape/theme/docs/ThemeApi.kt @@ -20,7 +20,7 @@ interface ThemeAPIV2 { @AdminOnly(privilege = Privilege.READ_SUMMARY) @Operation(summary = "모든 테마 조회", description = "관리자 페이지에서 요약된 테마 목록을 조회합니다.", tags = ["관리자 로그인이 필요한 API"]) @ApiResponses(ApiResponse(responseCode = "200", description = "성공", useReturnTypeSchema = true)) - fun findAdminThemes(): ResponseEntity> + fun findAdminThemes(): ResponseEntity> @AdminOnly(privilege = Privilege.READ_DETAIL) @Operation(summary = "테마 상세 조회", description = "해당 테마의 상세 정보를 조회합니다.", tags = ["관리자 로그인이 필요한 API"]) @@ -48,10 +48,10 @@ interface ThemeAPIV2 { @UserOnly @Operation(summary = "예약 페이지에서 모든 테마 조회", description = "모든 테마를 조회합니다.", tags = ["로그인이 필요한 API"]) @ApiResponses(ApiResponse(responseCode = "200", description = "성공", useReturnTypeSchema = true)) - fun findUserThemes(): ResponseEntity> + fun findUserThemes(): ResponseEntity> @UserOnly @Operation(summary = "예약 페이지에서 입력한 날짜에 가능한 테마 조회", description = "입력한 날짜에 가능한 테마를 조회합니다.", tags = ["로그인이 필요한 API"]) @ApiResponses(ApiResponse(responseCode = "200", description = "성공", useReturnTypeSchema = true)) - fun findThemesByIds(request: ThemeListRetrieveRequest): ResponseEntity> + fun findThemesByIds(request: ThemeIdListRetrieveResponse): ResponseEntity> } diff --git a/src/main/kotlin/roomescape/theme/web/ThemeController.kt b/src/main/kotlin/roomescape/theme/web/ThemeController.kt index bc7321da..8f5a667a 100644 --- a/src/main/kotlin/roomescape/theme/web/ThemeController.kt +++ b/src/main/kotlin/roomescape/theme/web/ThemeController.kt @@ -14,22 +14,22 @@ class ThemeController( @PostMapping("/themes/retrieve") override fun findThemesByIds( - @RequestBody request: ThemeListRetrieveRequest - ): ResponseEntity> { + @RequestBody request: ThemeIdListRetrieveResponse + ): ResponseEntity> { val response = themeService.findThemesByIds(request) return ResponseEntity.ok(CommonApiResponse(response)) } @GetMapping("/v2/themes") - override fun findUserThemes(): ResponseEntity> { + override fun findUserThemes(): ResponseEntity> { val response = themeService.findThemesForReservation() return ResponseEntity.ok(CommonApiResponse(response)) } @GetMapping("/admin/themes") - override fun findAdminThemes(): ResponseEntity> { + override fun findAdminThemes(): ResponseEntity> { val response = themeService.findAdminThemes() return ResponseEntity.ok(CommonApiResponse(response)) diff --git a/src/main/kotlin/roomescape/theme/web/ThemeDto.kt b/src/main/kotlin/roomescape/theme/web/ThemeDto.kt index a1cf87a8..ce3ae4eb 100644 --- a/src/main/kotlin/roomescape/theme/web/ThemeDto.kt +++ b/src/main/kotlin/roomescape/theme/web/ThemeDto.kt @@ -82,11 +82,11 @@ fun ThemeEntity.toAdminThemeSummaryResponse() = AdminThemeSummaryRetrieveRespons isOpen = this.isOpen ) -data class AdminThemeSummaryRetrieveListResponse( +data class AdminThemeSummaryListRetrieveResponse( val themes: List ) -fun List.toAdminThemeSummaryListResponse() = AdminThemeSummaryRetrieveListResponse( +fun List.toAdminThemeSummaryListResponse() = AdminThemeSummaryListRetrieveResponse( themes = this.map { it.toAdminThemeSummaryResponse() } ) @@ -129,11 +129,11 @@ fun ThemeEntity.toAdminThemeDetailResponse(createdBy: OperatorInfo, updatedBy: O updatedBy = updatedBy ) -data class ThemeListRetrieveRequest( +data class ThemeIdListRetrieveResponse( val themeIds: List ) -data class ThemeSummaryResponse( +data class ThemeInfoRetrieveResponse( val id: Long, val name: String, val thumbnailUrl: String, @@ -147,7 +147,7 @@ data class ThemeSummaryResponse( val expectedMinutesTo: Short ) -fun ThemeEntity.toSummaryResponse() = ThemeSummaryResponse( +fun ThemeEntity.toSummaryResponse() = ThemeInfoRetrieveResponse( id = this.id, name = this.name, thumbnailUrl = this.thumbnailUrl, @@ -161,10 +161,10 @@ fun ThemeEntity.toSummaryResponse() = ThemeSummaryResponse( expectedMinutesTo = this.expectedMinutesTo ) -data class ThemeSummaryListResponse( - val themes: List +data class ThemeInfoListRetrieveResponse( + val themes: List ) -fun List.toRetrieveListResponse() = ThemeSummaryListResponse( +fun List.toRetrieveListResponse() = ThemeInfoListRetrieveResponse( themes = this.map { it.toSummaryResponse() } ) diff --git a/src/test/kotlin/roomescape/theme/ThemeApiTest.kt b/src/test/kotlin/roomescape/theme/ThemeApiTest.kt index 31c0dabe..7e7799ba 100644 --- a/src/test/kotlin/roomescape/theme/ThemeApiTest.kt +++ b/src/test/kotlin/roomescape/theme/ThemeApiTest.kt @@ -18,7 +18,7 @@ import roomescape.theme.business.MIN_PRICE import roomescape.theme.exception.ThemeErrorCode import roomescape.theme.infrastructure.persistence.ThemeEntity import roomescape.theme.infrastructure.persistence.ThemeRepository -import roomescape.theme.web.ThemeListRetrieveRequest +import roomescape.theme.web.ThemeIdListRetrieveResponse import roomescape.theme.web.ThemeUpdateRequest import roomescape.supports.* import roomescape.supports.ThemeFixture.createRequest @@ -289,7 +289,7 @@ class ThemeApiTest( test("비회원") { runExceptionTest( method = HttpMethod.POST, - requestBody = ThemeListRetrieveRequest(themeIds = listOf()), + requestBody = ThemeIdListRetrieveResponse(themeIds = listOf()), endpoint = endpoint, expectedErrorCode = AuthErrorCode.TOKEN_NOT_FOUND ) @@ -299,7 +299,7 @@ class ThemeApiTest( runExceptionTest( token = authUtil.defaultAdminLogin(), method = HttpMethod.POST, - requestBody = ThemeListRetrieveRequest(themeIds = listOf()), + requestBody = ThemeIdListRetrieveResponse(themeIds = listOf()), endpoint = endpoint, expectedErrorCode = AuthErrorCode.ACCESS_DENIED ) @@ -319,7 +319,7 @@ class ThemeApiTest( runTest( token = authUtil.defaultUserLogin(), using = { - body(ThemeListRetrieveRequest(themeIds)) + body(ThemeIdListRetrieveResponse(themeIds)) }, on = { post("/themes/retrieve") @@ -345,7 +345,7 @@ class ThemeApiTest( runTest( token = authUtil.defaultUserLogin(), using = { - body(ThemeListRetrieveRequest(themeIds)) + body(ThemeIdListRetrieveResponse(themeIds)) }, on = { post("/themes/retrieve")