-
Notifications
You must be signed in to change notification settings - Fork 0
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
도서 대출 연장 기능 추가 및 테스트 #14
base: main
Are you sure you want to change the base?
Changes from 6 commits
3221555
7a89eb5
23ec6b3
886f768
8a5658f
fc84d63
559eeb4
43abbc2
0c0ee5e
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,11 +1,14 @@ | ||
package com.study.bookcafe.domain.borrow; | ||
|
||
import java.util.Collection; | ||
import java.util.Optional; | ||
|
||
public interface BorrowRepository { | ||
|
||
void save(Borrow borrow); | ||
void save(Collection<Borrow> borrows); | ||
void save(Reservation reservation); | ||
void cancelReservation(long reservationId); | ||
Optional<Borrow> findBorrowByMemberIdAndBookId(long memberId, long bookId, boolean canExtend); | ||
void updatePeriod(Borrow borrow); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,16 @@ public static Period of(@NonNull LocalDate from, Level level) { | |
return new Period(from, level); | ||
} | ||
|
||
public Period createExtended(Level level) { | ||
return new Period(from, to.plusWeeks(level.getExtendPeriod())); | ||
} | ||
|
||
public boolean isExtendable() { | ||
long epochDay = (from.toEpochDay() + to.toEpochDay()) / 2; | ||
LocalDate targetDate = LocalDate.ofEpochDay(epochDay).minusDays(1); | ||
LocalDate now = LocalDate.now(); | ||
|
||
return now.isAfter(targetDate); | ||
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. now 를 객체 내부에서 직접 얻으면 객체가 결정적이지 못하게 됩니다. 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. 항상 동일한 입력 값에 동일한 출력이 나온다는 뜻입니다. (순수함수) 메서드에서 해결방법으로
2번이나 3번이 괜찮아보이는데, 그럼 예외처리...? 한다고해도 매개변수를 오늘날짜로 강제한다는 건 지금의 코드랑 다를 게 없어 보입니다...😵 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. ㅋㅋㅋㅋ 그럼 상상력이 등장할 때죠. 자 정리해봅시다. 먼저 연장가능하다 는 것은 Period 에 어울리는 역할일까요? 기간이 곧 대출기간인가? 맞다면 이름을 좀 더 구체적으로 지을 필요가 있겠습니다. 연장 말고 기간에 입장에서 무엇을 검사하고 싶었나 하는거죠. 더.. 얘기하면 뭔가 상상이 줄어들 수 있으니 한번 고민해보세요 |
||
} | ||
|
||
} |
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.
👍