[#39] '시간' -> '일정' 스키마 변경으로 테마별 시간 지정 #40

Merged
pricelees merged 16 commits from refactor/#39 into main 2025-09-04 04:14:12 +00:00
4 changed files with 84 additions and 0 deletions
Showing only changes of commit b8e9c38024 - Show all commits

View File

@ -0,0 +1,36 @@
package roomescape.schedule.infrastructure.persistence
import jakarta.persistence.Entity
import jakarta.persistence.EnumType
import jakarta.persistence.Enumerated
import jakarta.persistence.Table
import jakarta.persistence.UniqueConstraint
import roomescape.common.entity.AuditingBaseEntity
import java.time.LocalDate
import java.time.LocalTime
@Entity
@Table(name = "schedule", uniqueConstraints = [UniqueConstraint(columnNames = ["date", "time", "theme_id"])])
class ScheduleEntity(
id: Long,
var date: LocalDate,
var time: LocalTime,
var themeId: Long,
@Enumerated(value = EnumType.STRING)
var status: ScheduleStatus
) : AuditingBaseEntity(id) {
fun modifyIfNotNull(
time: LocalTime?,
status: ScheduleStatus?
) {
time?.let { this.time = it }
status?.let { this.status = it }
}
}
enum class ScheduleStatus {
AVAILABLE, PENDING, RESERVED, BLOCKED
}

View File

@ -0,0 +1,14 @@
package roomescape.schedule.infrastructure.persistence
import org.springframework.data.jpa.repository.JpaRepository
import java.time.LocalDate
import java.time.LocalTime
interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
fun findAllByDate(date: LocalDate): List<ScheduleEntity>
fun findAllByDateAndThemeId(date: LocalDate, themeId: Long): List<ScheduleEntity>
fun existsByDateAndThemeIdAndTime(date: LocalDate, themeId: Long, time: LocalTime): Boolean
}

View File

@ -49,6 +49,23 @@ create table if not exists theme (
constraint fk_theme__updated_by foreign key (updated_by) references members (member_id) constraint fk_theme__updated_by foreign key (updated_by) references members (member_id)
); );
create table if not exists schedule (
id bigint primary key,
date date not null,
time time not null,
theme_id bigint not null,
status varchar(30) not null,
created_at timestamp not null,
created_by bigint not null,
updated_at timestamp not null,
updated_by bigint not null,
constraint uk_schedule__date_time_theme_id unique (date, time, theme_id),
constraint fk_schedule__created_by foreign key (created_by) references members (member_id),
constraint fk_schedule__updated_by foreign key (updated_by) references members (member_id),
constraint fk_schedule__theme_id foreign key (theme_id) references theme (id)
);
create table if not exists times ( create table if not exists times (
time_id bigint primary key, time_id bigint primary key,
start_at time not null, start_at time not null,

View File

@ -51,6 +51,23 @@ create table if not exists theme (
constraint fk_theme__updated_by foreign key (updated_by) references members (member_id) constraint fk_theme__updated_by foreign key (updated_by) references members (member_id)
); );
create table if not exists schedule (
id bigint primary key,
date date not null,
time time not null,
theme_id bigint not null,
status varchar(30) not null,
created_at datetime(6) not null,
created_by bigint not null,
updated_at datetime(6) not null,
updated_by bigint not null,
constraint uk_schedule__date_time_theme_id unique (date, time, theme_id),
constraint fk_schedule__created_by foreign key (created_by) references members (member_id),
constraint fk_schedule__updated_by foreign key (updated_by) references members (member_id),
constraint fk_schedule__theme_id foreign key (theme_id) references theme (id)
);
create table if not exists times create table if not exists times
( (
time_id bigint primary key, time_id bigint primary key,