From 6b2f8d9488159c2509eb2bcd1078dfa87222d0ce Mon Sep 17 00:00:00 2001 From: pricelees Date: Wed, 3 Sep 2025 10:45:18 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=83=88=EB=A1=9C=EC=9A=B4=20=ED=85=8C?= =?UTF-8?q?=EB=A7=88=20=EC=8A=A4=ED=82=A4=EB=A7=88=20=EC=A0=95=EC=9D=98=20?= =?UTF-8?q?=EB=B0=8F=20=EC=97=94=ED=8B=B0=ED=8B=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../persistence/v2/ThemeEntityV2.kt | 66 +++++++++++++++++++ src/main/resources/schema/schema-h2.sql | 1 + src/main/resources/schema/schema-mysql.sql | 1 + 3 files changed, 68 insertions(+) create mode 100644 src/main/kotlin/roomescape/theme/infrastructure/persistence/v2/ThemeEntityV2.kt diff --git a/src/main/kotlin/roomescape/theme/infrastructure/persistence/v2/ThemeEntityV2.kt b/src/main/kotlin/roomescape/theme/infrastructure/persistence/v2/ThemeEntityV2.kt new file mode 100644 index 00000000..fd462878 --- /dev/null +++ b/src/main/kotlin/roomescape/theme/infrastructure/persistence/v2/ThemeEntityV2.kt @@ -0,0 +1,66 @@ +package roomescape.theme.infrastructure.persistence.v2 + +import jakarta.persistence.Column +import jakarta.persistence.Entity +import jakarta.persistence.EnumType +import jakarta.persistence.Enumerated +import jakarta.persistence.Table +import roomescape.common.entity.AuditingBaseEntity + +@Entity +@Table(name = "theme") +class ThemeEntityV2( + id: Long, + + var name: String, + var description: String, + var thumbnailUrl: String, + + @Enumerated(value = EnumType.STRING) + var difficulty: Difficulty, + + var price: Int, + var minParticipants: Short, + var maxParticipants: Short, + var availableMinutes: Short, + var expectedMinutesFrom: Short, + var expectedMinutesTo: Short, + + @Column(columnDefinition = "TINYINT", length = 1) + var isOpen: Boolean +) : AuditingBaseEntity(id) { + + fun modifyIfNotNull( + name: String?, + description: String?, + thumbnailUrl: String?, + difficulty: Difficulty?, + price: Int?, + minParticipants: Short?, + maxParticipants: Short?, + availableMinutes: Short?, + expectedMinutesFrom: Short?, + expectedMinutesTo: Short?, + isOpen: Boolean? + ) { + name?.let { this.name = it } + description?.let { this.description = it } + thumbnailUrl?.let { this.thumbnailUrl = it } + difficulty?.let { this.difficulty = it } + price?.let { this.price = it } + minParticipants?.let { this.minParticipants = it } + maxParticipants?.let { this.maxParticipants = it } + availableMinutes?.let { this.availableMinutes = it } + expectedMinutesFrom?.let { this.expectedMinutesFrom = it } + expectedMinutesTo?.let { this.expectedMinutesTo = it } + isOpen?.let { this.isOpen = it } + } +} + +enum class Difficulty { + VERY_EASY, + EASY, + NORMAL, + HARD, + VERY_HARD +} diff --git a/src/main/resources/schema/schema-h2.sql b/src/main/resources/schema/schema-h2.sql index a9c09b07..82d0965a 100644 --- a/src/main/resources/schema/schema-h2.sql +++ b/src/main/resources/schema/schema-h2.sql @@ -39,6 +39,7 @@ create table if not exists theme ( available_minutes smallint not null, expected_minutes_from smallint not null, expected_minutes_to smallint not null, + is_open boolean not null, created_at timestamp not null, created_by bigint not null, updated_at timestamp not null, diff --git a/src/main/resources/schema/schema-mysql.sql b/src/main/resources/schema/schema-mysql.sql index d3b60713..4664f1dd 100644 --- a/src/main/resources/schema/schema-mysql.sql +++ b/src/main/resources/schema/schema-mysql.sql @@ -41,6 +41,7 @@ create table if not exists theme ( available_minutes smallint not null, expected_minutes_from smallint not null, expected_minutes_to smallint not null, + is_open tinyint(1) not null, created_at datetime(6) not null, created_by bigint not null, updated_at datetime(6) not null,