58 lines
1.7 KiB
Kotlin

package roomescape.time.web
import io.swagger.v3.oas.annotations.media.Schema
import roomescape.time.infrastructure.persistence.TimeEntity
import java.time.LocalTime
@Schema(name = "예약 시간 저장 요청", description = "예약 시간 저장 요청시 사용됩니다.")
data class TimeCreateRequest(
@Schema(description = "시간", type = "string", example = "09:00")
val startAt: LocalTime
)
fun TimeCreateRequest.toEntity(): TimeEntity = TimeEntity(startAt = this.startAt)
@Schema(name = "예약 시간 정보", description = "예약 시간 추가 및 조회 응답시 사용됩니다.")
data class TimeCreateResponse(
@Schema(description = "시간 식별자")
val id: Long,
@Schema(description = "시간")
val startAt: LocalTime
)
fun TimeEntity.toCreateResponse(): TimeCreateResponse = TimeCreateResponse(this.id!!, this.startAt)
data class TimeRetrieveResponse(
@Schema(description = "시간 식별자.")
val id: Long,
@Schema(description = "시간")
val startAt: LocalTime
)
fun TimeEntity.toResponse(): TimeRetrieveResponse = TimeRetrieveResponse(this.id!!, this.startAt)
data class TimeRetrieveListResponse(
val times: List<TimeRetrieveResponse>
)
fun List<TimeEntity>.toResponse(): TimeRetrieveListResponse = TimeRetrieveListResponse(
this.map { it.toResponse() }
)
data class TimeWithAvailabilityResponse(
@Schema(description = "시간 식별자")
val id: Long,
@Schema(description = "시간")
val startAt: LocalTime,
@Schema(description = "예약 가능 여부")
val isAvailable: Boolean
)
data class TimeWithAvailabilityListResponse(
val times: List<TimeWithAvailabilityResponse>
)