|
| 1 | +package com.wypl.jpacalendardomain.calendar.domain; |
| 2 | + |
| 3 | +import com.wypl.jpacalendardomain.calendar.data.RepetitionCycle; |
| 4 | +import com.wypl.jpacommon.JpaBaseEntity; |
| 5 | +import jakarta.persistence.*; |
| 6 | +import lombok.*; |
| 7 | +import org.hibernate.annotations.SQLRestriction; |
| 8 | + |
| 9 | +import java.time.LocalDate; |
| 10 | +import java.time.LocalDateTime; |
| 11 | + |
| 12 | +@Getter |
| 13 | +@NoArgsConstructor(access = AccessLevel.PROTECTED) |
| 14 | +@SQLRestriction("deleted_at is null") |
| 15 | +@Entity |
| 16 | +@Table(name = "schedule_tbl") |
| 17 | +public class Schedule extends JpaBaseEntity { |
| 18 | + |
| 19 | + @Id |
| 20 | + @GeneratedValue(strategy = GenerationType.IDENTITY) |
| 21 | + @Column(name = "schedule_id") |
| 22 | + private Long scheduleId; |
| 23 | + |
| 24 | + @ManyToOne(fetch = FetchType.LAZY) |
| 25 | + @JoinColumn(name = "schedule_info_id", nullable = false) |
| 26 | + private ScheduleInfo scheduleInfo; |
| 27 | + |
| 28 | + @Column(name = "title", length = 100) |
| 29 | + private String title; |
| 30 | + |
| 31 | + @Column(name = "description") |
| 32 | + private String description; |
| 33 | + |
| 34 | + @Column(name = "start_datetime", nullable = false) |
| 35 | + private LocalDateTime startDateTime; |
| 36 | + |
| 37 | + @Column(name = "end_datetime", nullable = false) |
| 38 | + private LocalDateTime endDateTime; |
| 39 | + |
| 40 | + @Column(name = "repetition_start_date", nullable = false) |
| 41 | + private LocalDate repetitionStartDate; |
| 42 | + |
| 43 | + @Column(name = "repetition_end_date") |
| 44 | + private LocalDate repetitionEndDate; |
| 45 | + |
| 46 | + @Enumerated(EnumType.STRING) |
| 47 | + private RepetitionCycle repetitionCycle; // 반복 주기 (일, 주, 달, 년) |
| 48 | + |
| 49 | + @Column(name = "day_of_week") |
| 50 | + private Integer dayOfWeek; // 반복 요일 |
| 51 | + |
| 52 | + @Column(name = "week_interval") |
| 53 | + private Integer weekInterval; // 주 반복 |
| 54 | + |
| 55 | + // Todo: Review Mapping |
| 56 | + |
| 57 | + @Builder |
| 58 | + public Schedule(ScheduleInfo scheduleInfo, String title, String description, LocalDateTime startDateTime, LocalDateTime endDateTime, LocalDate repetitionStartDate, LocalDate repetitionEndDate, RepetitionCycle repetitionCycle, Integer dayOfWeek, Integer weekInterval) { |
| 59 | + this.scheduleInfo = scheduleInfo; |
| 60 | + this.title = title; |
| 61 | + this.description = description; |
| 62 | + this.startDateTime = startDateTime; |
| 63 | + this.endDateTime = endDateTime; |
| 64 | + this.repetitionStartDate = repetitionStartDate; |
| 65 | + this.repetitionEndDate = repetitionEndDate; |
| 66 | + this.repetitionCycle = repetitionCycle; |
| 67 | + this.dayOfWeek = dayOfWeek; |
| 68 | + this.weekInterval = weekInterval; |
| 69 | + } |
| 70 | +} |
0 commit comments