Skip to content
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

도서 반환 및 대출 연장 오류 수정 완료 #328

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public PagedResponseDto<BookLoanRecordOverdueResponseDto> getOverdueBookLoanReco
}

public BookLoanRecord getBookLoanRecordByBookAndReturnedAtIsNullOrThrow(Book book) {
return bookLoanRecordRepository.findByBookAndReturnedAtIsNull(book)
return bookLoanRecordRepository.findByBookAndReturnedAtIsNullAndStatus(book, BookLoanStatus.APPROVED)
.orElseThrow(() -> new NotFoundException("해당 도서 대출 기록이 없습니다."));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import page.clab.api.domain.book.dao.BookRepository;
import page.clab.api.domain.book.domain.Book;
import page.clab.api.domain.book.domain.BookLoanRecord;
import page.clab.api.domain.book.domain.BookLoanStatus;
import page.clab.api.domain.book.dto.request.BookRequestDto;
import page.clab.api.domain.book.dto.request.BookUpdateRequestDto;
import page.clab.api.domain.book.dto.response.BookDetailsResponseDto;
Expand Down Expand Up @@ -72,7 +73,7 @@ public Book getBookByIdOrThrow(Long bookId) {
}

public BookLoanRecord getBookLoanRecordByBookAndReturnedAtIsNull(Book book) {
return bookLoanRecordRepository.findByBookAndReturnedAtIsNull(book)
return bookLoanRecordRepository.findByBookAndReturnedAtIsNullAndStatus(book, BookLoanStatus.APPROVED)
.orElse(null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public interface BookLoanRecordRepository extends JpaRepository<BookLoanRecord, Long>, BookLoanRecordRepositoryCustom {

Optional<BookLoanRecord> findByBookAndReturnedAtIsNull(Book book);
Optional<BookLoanRecord> findByBookAndReturnedAtIsNullAndStatus(Book book, BookLoanStatus bookLoanStatus);

Optional<Object> findByBookAndBorrowerAndStatus(Book book, Member borrower, BookLoanStatus bookLoanStatus);

Expand Down
Loading