generated from pricelees/issue-pr-template
60 lines
1.2 KiB
Kotlin
60 lines
1.2 KiB
Kotlin
package roomescape.reservation.infrastructure.persistence;
|
|
|
|
import java.time.LocalTime;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import jakarta.persistence.Entity;
|
|
import jakarta.persistence.GeneratedValue;
|
|
import jakarta.persistence.GenerationType;
|
|
import jakarta.persistence.Id;
|
|
import roomescape.common.exception.ErrorType;
|
|
import roomescape.common.exception.RoomescapeException;
|
|
|
|
@Entity
|
|
public class ReservationTime {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long id;
|
|
|
|
private LocalTime startAt;
|
|
|
|
protected ReservationTime() {
|
|
}
|
|
|
|
public ReservationTime(final LocalTime startAt) {
|
|
this(null, startAt);
|
|
}
|
|
|
|
public ReservationTime(final Long id, final LocalTime startAt) {
|
|
this.id = id;
|
|
this.startAt = startAt;
|
|
|
|
validateNull();
|
|
}
|
|
|
|
private void validateNull() {
|
|
if (startAt == null) {
|
|
throw new RoomescapeException(ErrorType.REQUEST_DATA_BLANK, String.format("[values: %s]", this),
|
|
HttpStatus.BAD_REQUEST);
|
|
}
|
|
}
|
|
|
|
public Long getId() {
|
|
return id;
|
|
}
|
|
|
|
public LocalTime getStartAt() {
|
|
return startAt;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "ReservationTime{" +
|
|
"id=" + id +
|
|
", startAt=" + startAt +
|
|
'}';
|
|
}
|
|
}
|