From 794232d84b00d105cf6fc50c9d7faf5be12800c5 Mon Sep 17 00:00:00 2001 From: ddingmin Date: Mon, 20 May 2024 23:08:30 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20View=20=EB=84=A4=EC=9D=B4=EB=B0=8D?= =?UTF-8?q?=20->=20Get=EC=9C=BC=EB=A1=9C=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ViewSessions.kt => GetSessions.kt} | 8 +++---- .../restapi/controller/SessionController.kt | 22 +++++++++---------- ...ssionsRequest.kt => GetSessionsRequest.kt} | 2 +- ...ionsResponse.kt => GetSessionsResponse.kt} | 2 +- ...ViewSessionsTest.kt => GetSessionsTest.kt} | 8 +++---- 5 files changed, 21 insertions(+), 21 deletions(-) rename src/main/kotlin/com/depromeet/makers/domain/usecase/{ViewSessions.kt => GetSessions.kt} (64%) rename src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/{ViewSessionsRequest.kt => GetSessionsRequest.kt} (90%) rename src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/response/{ViewSessionsResponse.kt => GetSessionsResponse.kt} (98%) rename src/test/kotlin/com/depromeet/makers/domain/usecase/{ViewSessionsTest.kt => GetSessionsTest.kt} (88%) diff --git a/src/main/kotlin/com/depromeet/makers/domain/usecase/ViewSessions.kt b/src/main/kotlin/com/depromeet/makers/domain/usecase/GetSessions.kt similarity index 64% rename from src/main/kotlin/com/depromeet/makers/domain/usecase/ViewSessions.kt rename to src/main/kotlin/com/depromeet/makers/domain/usecase/GetSessions.kt index 3c3e306..61b1a2a 100644 --- a/src/main/kotlin/com/depromeet/makers/domain/usecase/ViewSessions.kt +++ b/src/main/kotlin/com/depromeet/makers/domain/usecase/GetSessions.kt @@ -3,14 +3,14 @@ package com.depromeet.makers.domain.usecase import com.depromeet.makers.domain.gateway.SessionGateway import com.depromeet.makers.domain.model.Session -class ViewSessions( +class GetSessions( private val sessionGateway: SessionGateway, -) : UseCase> { - data class ViewSessionsInput( +) : UseCase> { + data class GetSessionsInput( val generation: Int, ) - override fun execute(input: ViewSessionsInput): List { + override fun execute(input: GetSessionsInput): List { return sessionGateway.findAllByGeneration(input.generation).sortedBy { it.week } } } diff --git a/src/main/kotlin/com/depromeet/makers/presentation/restapi/controller/SessionController.kt b/src/main/kotlin/com/depromeet/makers/presentation/restapi/controller/SessionController.kt index 50eda3d..20b6b3f 100644 --- a/src/main/kotlin/com/depromeet/makers/presentation/restapi/controller/SessionController.kt +++ b/src/main/kotlin/com/depromeet/makers/presentation/restapi/controller/SessionController.kt @@ -4,15 +4,15 @@ import com.depromeet.makers.domain.usecase.CreateNewSession import com.depromeet.makers.domain.usecase.DeleteSession import com.depromeet.makers.domain.usecase.UpdateSession import com.depromeet.makers.domain.usecase.UpdateSessionPlace -import com.depromeet.makers.domain.usecase.ViewSessions +import com.depromeet.makers.domain.usecase.GetSessions import com.depromeet.makers.presentation.restapi.dto.request.CreateNewSessionRequest import com.depromeet.makers.presentation.restapi.dto.request.UpdateSessionPlaceRequest import com.depromeet.makers.presentation.restapi.dto.request.UpdateSessionRequest -import com.depromeet.makers.presentation.restapi.dto.request.ViewSessionsRequest +import com.depromeet.makers.presentation.restapi.dto.request.GetSessionsRequest import com.depromeet.makers.presentation.restapi.dto.response.CreateNewSessionResponse import com.depromeet.makers.presentation.restapi.dto.response.UpdateSessionPlaceResponse import com.depromeet.makers.presentation.restapi.dto.response.UpdateSessionResponse -import com.depromeet.makers.presentation.restapi.dto.response.ViewSessionsResponse +import com.depromeet.makers.presentation.restapi.dto.response.GetSessionsResponse import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.Parameter import io.swagger.v3.oas.annotations.tags.Tag @@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RestController @RequestMapping("/v1/sessions") class SessionController( private val createNewSession: CreateNewSession, - private val viewSessions: ViewSessions, + private val getSessions: GetSessions, private val updateSession: UpdateSession, private val updateSessionPlace: UpdateSessionPlace, private val deleteSession: DeleteSession, @@ -64,16 +64,16 @@ class SessionController( @Operation(summary = "기수에 따른 모든 주차의 세션들 조회 요청", description = "기수에 따른 모든 주차의 세션들을 조회합니다.") @Parameter(name = "generation", description = "조회할 세션의 기수", example = "15") @GetMapping - fun viewSessions( - @Valid request: ViewSessionsRequest, - ): ViewSessionsResponse { - val sessions = viewSessions.execute( - ViewSessions.ViewSessionsInput( + fun getSessions( + @Valid request: GetSessionsRequest, + ): GetSessionsResponse { + val sessions = getSessions.execute( + GetSessions.GetSessionsInput( generation = request.generation, ) - ).map { ViewSessionsResponse.SessionResponse.fromDomain(it) } + ).map { GetSessionsResponse.SessionResponse.fromDomain(it) } - return ViewSessionsResponse( + return GetSessionsResponse( generation = request.generation, sessions = sessions, ) diff --git a/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/ViewSessionsRequest.kt b/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/GetSessionsRequest.kt similarity index 90% rename from src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/ViewSessionsRequest.kt rename to src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/GetSessionsRequest.kt index 2804694..54ecf6d 100644 --- a/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/ViewSessionsRequest.kt +++ b/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/request/GetSessionsRequest.kt @@ -3,7 +3,7 @@ package com.depromeet.makers.presentation.restapi.dto.request import io.swagger.v3.oas.annotations.media.Schema @Schema(description = "기수에 따른 모든 주차의 세션들 조회 요청") -data class ViewSessionsRequest( +data class GetSessionsRequest( @Schema(description = "조회할 세션의 기수", example = "15") val generation: Int, diff --git a/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/response/ViewSessionsResponse.kt b/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/response/GetSessionsResponse.kt similarity index 98% rename from src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/response/ViewSessionsResponse.kt rename to src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/response/GetSessionsResponse.kt index 29a6f79..575d6dd 100644 --- a/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/response/ViewSessionsResponse.kt +++ b/src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/response/GetSessionsResponse.kt @@ -5,7 +5,7 @@ import com.depromeet.makers.domain.model.Session import io.swagger.v3.oas.annotations.media.Schema @Schema(description = "기수에 따른 모든 주차의 세션들 조회 응답 DTO") -data class ViewSessionsResponse( +data class GetSessionsResponse( @Schema(description = "기수", example = "15") val generation: Int, diff --git a/src/test/kotlin/com/depromeet/makers/domain/usecase/ViewSessionsTest.kt b/src/test/kotlin/com/depromeet/makers/domain/usecase/GetSessionsTest.kt similarity index 88% rename from src/test/kotlin/com/depromeet/makers/domain/usecase/ViewSessionsTest.kt rename to src/test/kotlin/com/depromeet/makers/domain/usecase/GetSessionsTest.kt index 9f1bfed..460d538 100644 --- a/src/test/kotlin/com/depromeet/makers/domain/usecase/ViewSessionsTest.kt +++ b/src/test/kotlin/com/depromeet/makers/domain/usecase/GetSessionsTest.kt @@ -10,10 +10,10 @@ import io.mockk.every import io.mockk.mockk import java.time.LocalDateTime -class ViewSessionsTest : BehaviorSpec({ +class GetSessionsTest : BehaviorSpec({ Given("기수 별 세션을 모두 조회할 때") { val sessionGateway = mockk() - val viewSessions = ViewSessions(sessionGateway) + val getSessions = GetSessions(sessionGateway) val mockShuffledSessionList = (1..16).map { week -> Session( @@ -31,8 +31,8 @@ class ViewSessionsTest : BehaviorSpec({ every { sessionGateway.findAllByGeneration(any()) } returns mockShuffledSessionList When("execute가 실행되면") { - val result = viewSessions.execute( - ViewSessions.ViewSessionsInput( + val result = getSessions.execute( + GetSessions.GetSessionsInput( generation = 15, ) )