generated from pricelees/issue-pr-template
94 lines
2.8 KiB
Kotlin
94 lines
2.8 KiB
Kotlin
package roomescape.reservation.web
|
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty
|
|
import io.swagger.v3.oas.annotations.media.Schema
|
|
import roomescape.member.web.MemberRetrieveResponse
|
|
import roomescape.member.web.toRetrieveResponse
|
|
import roomescape.reservation.infrastructure.persistence.ReservationEntity
|
|
import roomescape.reservation.infrastructure.persistence.ReservationStatus
|
|
import roomescape.theme.web.ThemeRetrieveResponse
|
|
import roomescape.theme.web.toRetrieveResponse
|
|
import roomescape.time.web.TimeCreateResponse
|
|
import roomescape.time.web.toCreateResponse
|
|
import java.time.LocalDate
|
|
import java.time.LocalTime
|
|
|
|
data class ReservationCreateResponse(
|
|
val id: Long,
|
|
val date: LocalDate,
|
|
|
|
@JsonProperty("member")
|
|
val member: MemberRetrieveResponse,
|
|
|
|
@JsonProperty("time")
|
|
val time: TimeCreateResponse,
|
|
|
|
@JsonProperty("theme")
|
|
val theme: ThemeRetrieveResponse,
|
|
|
|
val status: ReservationStatus
|
|
)
|
|
|
|
fun ReservationEntity.toCreateResponse() = ReservationCreateResponse(
|
|
id = this.id!!,
|
|
date = this.date,
|
|
member = this.member.toRetrieveResponse(),
|
|
time = this.time.toCreateResponse(),
|
|
theme = this.theme.toRetrieveResponse(),
|
|
status = this.status
|
|
)
|
|
|
|
data class MyReservationRetrieveResponse(
|
|
val id: Long,
|
|
val themeName: String,
|
|
val date: LocalDate,
|
|
val time: LocalTime,
|
|
val status: ReservationStatus,
|
|
@Schema(description = "대기 순번. 확정된 예약은 0의 값을 가집니다.")
|
|
val rank: Long,
|
|
@Schema(description = "결제 키. 결제가 완료된 예약에만 값이 존재합니다.")
|
|
val paymentKey: String?,
|
|
@Schema(description = "결제 금액. 결제가 완료된 예약에만 값이 존재합니다.")
|
|
val amount: Long?
|
|
)
|
|
|
|
data class MyReservationRetrieveListResponse(
|
|
@Schema(description = "현재 로그인한 회원의 예약 및 대기 목록")
|
|
val reservations: List<MyReservationRetrieveResponse>
|
|
)
|
|
|
|
fun List<MyReservationRetrieveResponse>.toRetrieveListResponse() = MyReservationRetrieveListResponse(this)
|
|
|
|
data class ReservationRetrieveResponse(
|
|
val id: Long,
|
|
val date: LocalDate,
|
|
|
|
@JsonProperty("member")
|
|
val member: MemberRetrieveResponse,
|
|
|
|
@JsonProperty("time")
|
|
val time: TimeCreateResponse,
|
|
|
|
@JsonProperty("theme")
|
|
val theme: ThemeRetrieveResponse,
|
|
|
|
val status: ReservationStatus
|
|
)
|
|
|
|
fun ReservationEntity.toRetrieveResponse(): ReservationRetrieveResponse = ReservationRetrieveResponse(
|
|
id = this.id!!,
|
|
date = this.date,
|
|
member = this.member.toRetrieveResponse(),
|
|
time = this.time.toCreateResponse(),
|
|
theme = this.theme.toRetrieveResponse(),
|
|
status = this.status
|
|
)
|
|
|
|
data class ReservationRetrieveListResponse(
|
|
val reservations: List<ReservationRetrieveResponse>
|
|
)
|
|
|
|
fun List<ReservationEntity>.toRetrieveListResponse()= ReservationRetrieveListResponse(
|
|
this.map { it.toRetrieveResponse() }
|
|
)
|