generated from pricelees/issue-pr-template
refactor: theme 패키지 내 DTO 코틀린 전환 및 클래스 통합
This commit is contained in:
parent
fae11c4212
commit
5f57499d79
62
src/main/java/roomescape/theme/web/ThemeDTO.kt
Normal file
62
src/main/java/roomescape/theme/web/ThemeDTO.kt
Normal file
@ -0,0 +1,62 @@
|
||||
package roomescape.theme.web
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import jakarta.validation.constraints.NotBlank
|
||||
import jakarta.validation.constraints.Size
|
||||
import roomescape.theme.infrastructure.persistence.Theme
|
||||
|
||||
@Schema(name = "테마 저장 요청", description = "테마 정보를 저장할 때 사용합니다.")
|
||||
@JvmRecord
|
||||
data class ThemeRequest(
|
||||
@field:Schema(description = "필수 값이며, 최대 20글자까지 입력 가능합니다.")
|
||||
@NotBlank
|
||||
@Size(max = 20, message = "테마의 이름은 1~20글자 사이여야 합니다.")
|
||||
val name: String,
|
||||
|
||||
@field:Schema(description = "필수 값이며, 최대 100글자까지 입력 가능합니다.")
|
||||
@NotBlank
|
||||
@Size(max = 100, message = "테마의 설명은 1~100글자 사이여야 합니다.")
|
||||
val description: String,
|
||||
|
||||
@field:Schema(description = "필수 값이며, 썸네일 이미지 URL 을 입력해주세요.")
|
||||
@NotBlank
|
||||
val thumbnail: String
|
||||
)
|
||||
|
||||
@Schema(name = "테마 정보", description = "테마 추가 및 조회 응답에 사용됩니다.")
|
||||
@JvmRecord
|
||||
data class ThemeResponse(
|
||||
@field:Schema(description = "테마 번호. 테마를 식별할 때 사용합니다.")
|
||||
val id: Long,
|
||||
|
||||
@field:Schema(description = "테마 이름. 중복을 허용하지 않습니다.")
|
||||
val name: String,
|
||||
|
||||
@field:Schema(description = "테마 설명")
|
||||
val description: String,
|
||||
|
||||
@field:Schema(description = "테마 썸네일 이미지 URL")
|
||||
val thumbnail: String
|
||||
) {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun from(theme: Theme): ThemeResponse {
|
||||
return ThemeResponse(theme.id, theme.name, theme.description, theme.thumbnail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Theme.toResponse(): ThemeResponse = ThemeResponse(
|
||||
id = this.id,
|
||||
name = this.name,
|
||||
description = this.description,
|
||||
thumbnail = this.thumbnail
|
||||
)
|
||||
|
||||
|
||||
@Schema(name = "테마 목록 조회 응답", description = "모든 테마 목록 조회 응답시 사용됩니다.")
|
||||
@JvmRecord
|
||||
data class ThemesResponse(
|
||||
@field:Schema(description = "모든 테마 목록")
|
||||
val themes: List<ThemeResponse>
|
||||
)
|
||||
@ -1,21 +0,0 @@
|
||||
package roomescape.theme.web;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
@Schema(name = "테마 저장 요청", description = "테마 정보를 저장할 때 사용합니다.")
|
||||
public record ThemeRequest(
|
||||
@NotBlank(message = "테마의 이름은 null 또는 공백일 수 없습니다.")
|
||||
@Size(min = 1, max = 20, message = "테마의 이름은 1~20글자 사이여야 합니다.")
|
||||
@Schema(description = "필수 값이며, 최대 20글자까지 입력 가능합니다.")
|
||||
String name,
|
||||
@NotBlank(message = "테마의 설명은 null 또는 공백일 수 없습니다.")
|
||||
@Size(min = 1, max = 100, message = "테마의 설명은 1~100글자 사이여야 합니다.")
|
||||
@Schema(description = "필수 값이며, 최대 100글자까지 입력 가능합니다.")
|
||||
String description,
|
||||
@NotBlank(message = "테마의 쌈네일은 null 또는 공백일 수 없습니다.")
|
||||
@Schema(description = "필수 값이며, 썸네일 이미지 URL 을 입력해주세요.")
|
||||
String thumbnail
|
||||
) {
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
package roomescape.theme.web;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import roomescape.theme.infrastructure.persistence.Theme;
|
||||
|
||||
@Schema(name = "테마 정보", description = "테마 추가 및 조회 응답에 사용됩니다.")
|
||||
public record ThemeResponse(
|
||||
@Schema(description = "테마 번호. 테마를 식별할 때 사용합니다.")
|
||||
Long id,
|
||||
@Schema(description = "테마 이름. 중복을 허용하지 않습니다.")
|
||||
String name,
|
||||
@Schema(description = "테마 설명")
|
||||
String description,
|
||||
@Schema(description = "테마 썸네일 이미지 URL")
|
||||
String thumbnail
|
||||
) {
|
||||
|
||||
public static ThemeResponse from(Theme theme) {
|
||||
return new ThemeResponse(theme.getId(), theme.getName(), theme.getDescription(), theme.getThumbnail());
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package roomescape.theme.web;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Schema(name = "테마 목록 조회 응답", description = "모든 테마 목록 조회 응답시 사용됩니다.")
|
||||
public record ThemesResponse(
|
||||
@Schema(description = "모든 테마 목록") List<ThemeResponse> themes
|
||||
) {
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user