Skip to content

Commit

Permalink
bug: 도서 반환 및 대출 연장 오류 버그 수정 #327
Browse files Browse the repository at this point in the history
  • Loading branch information
mingmingmon committed May 3, 2024
1 parent 6826381 commit bedcfe5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
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

0 comments on commit bedcfe5

Please sign in to comment.