-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BE] 변경된 ERD 설계에 따른 전체 코드 리팩토링 #72
Changes from all commits
6363ef7
8ad0fb1
bf1a4d1
3b36199
df69986
a6f1369
25bcfa6
20b15eb
c97438b
63052ae
7216cf9
dd3d17d
b19d69e
3165e0d
5d782e9
d74772f
d7f7851
3b1f165
2e3ab79
729de3e
885b3be
fe830bc
8406aef
955ed50
a28515b
d77f72a
f73fea4
28f6195
82f8ce4
2227130
022290e
bc4def3
3514227
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
package com.woowacourse.momo.domain.availabledate; | ||
|
||
import com.woowacourse.momo.domain.meeting.Meeting; | ||
import java.time.LocalDate; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface AvailableDateRepository extends JpaRepository<AvailableDate, Long> { | ||
|
||
Optional<AvailableDate> findByMeetingAndDate(Meeting meeting, LocalDate date); | ||
|
||
List<AvailableDate> findAllByMeeting(Meeting meeting); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.woowacourse.momo.domain.timeslot; | ||
|
||
import com.woowacourse.momo.exception.MomoException; | ||
import com.woowacourse.momo.exception.code.MeetingErrorCode; | ||
import com.woowacourse.momo.exception.code.ScheduleErrorCode; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import java.time.LocalTime; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Embeddable | ||
@Getter | ||
@EqualsAndHashCode(of = {"startTimeslot", "endTimeslot"}) | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class TimeslotInterval { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 클래스는 Meeting의 가능시간과 끝 시간을 따로 분리해 둔 클래스로 이해했어요. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 무슨 말인지 이해했습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네 좋습니다~! |
||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(nullable = false, length = 10) | ||
private Timeslot startTimeslot; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(nullable = false, length = 10) | ||
private Timeslot endTimeslot; | ||
|
||
public TimeslotInterval(LocalTime startTime, LocalTime lastTime) { | ||
validateTimeRange(startTime, lastTime); | ||
this.startTimeslot = Timeslot.from(startTime); | ||
this.endTimeslot = Timeslot.from(lastTime); | ||
} | ||
|
||
private void validateTimeRange(LocalTime firstTime, LocalTime lastTime) { | ||
if (firstTime.isAfter(lastTime)) { | ||
throw new MomoException(MeetingErrorCode.INVALID_TIME_RANGE); | ||
} | ||
} | ||
Comment on lines
+38
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 좋네요~~👍 |
||
|
||
public Timeslot getValidatedTimeslot(LocalTime other) { | ||
if (isNotContainedWithin(other)) { | ||
throw new MomoException(ScheduleErrorCode.INVALID_SCHEDULE_TIMESLOT); | ||
} | ||
return Timeslot.from(other); | ||
} | ||
|
||
private boolean isNotContainedWithin(LocalTime other) { | ||
return this.startTimeslot.isAfter(other) || this.endTimeslot.isBefore(other); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
누락된 어노테이션을 잘 짚어 주셨군요ㅎㅎ