-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 이번 주차 세션 정보 조회
- Loading branch information
Showing
3 changed files
with
114 additions
and
21 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/com/depromeet/makers/domain/usecase/GetInfoSession.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.depromeet.makers.domain.usecase | ||
|
||
import com.depromeet.makers.domain.exception.SessionNotFoundException | ||
import com.depromeet.makers.domain.gateway.SessionGateway | ||
import com.depromeet.makers.domain.model.Session | ||
import java.time.DayOfWeek | ||
import java.time.LocalDateTime | ||
|
||
class GetInfoSession( | ||
private val sessionGateway: SessionGateway, | ||
) : UseCase<GetInfoSession.GetInfoSessionInput, Session> { | ||
data class GetInfoSessionInput( | ||
val now: LocalDateTime, | ||
) | ||
|
||
override fun execute(input: GetInfoSessionInput): Session { | ||
val monday = input.now.getMonday() | ||
|
||
return sessionGateway.findByStartTimeBetween( | ||
monday, | ||
monday.plusDays(7) | ||
) ?: throw SessionNotFoundException() | ||
} | ||
|
||
private fun LocalDateTime.getMonday() = this.toLocalDate().with(DayOfWeek.MONDAY).atStartOfDay() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/main/kotlin/com/depromeet/makers/presentation/restapi/dto/response/GetSessionResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.depromeet.makers.presentation.restapi.dto.response | ||
|
||
import com.depromeet.makers.domain.model.Place | ||
import com.depromeet.makers.domain.model.Session | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
@Schema(description = "세션 조회 응답 DTO") | ||
class GetSessionResponse( | ||
@Schema(description = "세션 ID", example = "01HWPNRE5TS9S7VC99WPETE5KE") | ||
val sessionId: String, | ||
|
||
@Schema(description = "기수", example = "15") | ||
val generation: Int, | ||
|
||
@Schema(description = "주차", example = "1") | ||
val week: Int, | ||
|
||
@Schema(description = "세션 제목", example = "오리엔테이션") | ||
val title: String, | ||
|
||
@Schema(description = "세션 설명", example = "세션 설명을 입력해주세요.") | ||
val description: String?, | ||
|
||
@Schema(description = "시작 시간", example = "2021-10-01T19:00:00") | ||
val startTime: String, | ||
|
||
@Schema(description = "세션 타입", example = "ONLINE") | ||
val sessionType: String, | ||
|
||
@Schema(description = "장소", example = "온라인") | ||
val place: PlaceResponse, | ||
) { | ||
companion object { | ||
fun fromDomain(session: Session) = with(session) { | ||
GetSessionResponse( | ||
sessionId = sessionId, | ||
generation = generation, | ||
week = week, | ||
title = title, | ||
description = description, | ||
startTime = startTime.toString(), | ||
sessionType = sessionType.name, | ||
place = place.let { PlaceResponse.fromDomain(it) }, | ||
) | ||
} | ||
} | ||
|
||
data class PlaceResponse( | ||
@Schema(description = "장소 이름", example = "전북 익산시 부송동 100") | ||
val address: String, | ||
|
||
@Schema(description = "위도", example = "35.9418") | ||
val latitude: Double, | ||
|
||
@Schema(description = "경도", example = "35.9418") | ||
val longitude: Double, | ||
) { | ||
companion object { | ||
fun fromDomain(place: Place) = with(place) { | ||
PlaceResponse( | ||
address = address, | ||
latitude = latitude, | ||
longitude = longitude, | ||
) | ||
} | ||
} | ||
} | ||
} |