46 lines
1.1 KiB
Kotlin

package roomescape.theme.web
import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.Size
import org.hibernate.validator.constraints.URL
import roomescape.theme.infrastructure.persistence.ThemeEntity
data class ThemeCreateRequest(
@NotBlank
@Size(max = 20)
val name: String,
@NotBlank
@Size(max = 100)
val description: String,
@URL
@NotBlank
@Schema(description = "썸네일 이미지 주소(URL).")
val thumbnail: String
)
data class ThemeRetrieveResponse(
val id: Long,
val name: String,
val description: String,
@Schema(description = "썸네일 이미지 주소(URL).")
val thumbnail: String
)
fun ThemeEntity.toResponse(): ThemeRetrieveResponse = ThemeRetrieveResponse(
id = this.id!!,
name = this.name,
description = this.description,
thumbnail = this.thumbnail
)
data class ThemeRetrieveListResponse(
val themes: List<ThemeRetrieveResponse>
)
fun List<ThemeEntity>.toResponse(): ThemeRetrieveListResponse = ThemeRetrieveListResponse(
themes = this.map { it.toResponse() }
)