Skip to content

Commit

Permalink
refactor: View 네이밍 -> Get으로 통일
Browse files Browse the repository at this point in the history
  • Loading branch information
ddingmin committed May 20, 2024
1 parent 49f97a5 commit 794232d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ViewSessions.ViewSessionsInput, List<Session>> {
data class ViewSessionsInput(
) : UseCase<GetSessions.GetSessionsInput, List<Session>> {
data class GetSessionsInput(
val generation: Int,
)

override fun execute(input: ViewSessionsInput): List<Session> {
override fun execute(input: GetSessionsInput): List<Session> {
return sessionGateway.findAllByGeneration(input.generation).sortedBy { it.week }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SessionGateway>()
val viewSessions = ViewSessions(sessionGateway)
val getSessions = GetSessions(sessionGateway)

val mockShuffledSessionList = (1..16).map { week ->
Session(
Expand All @@ -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,
)
)
Expand Down

0 comments on commit 794232d

Please sign in to comment.