diff --git a/src/main/java/page/clab/api/domain/book/application/BookLoanRecordService.java b/src/main/java/page/clab/api/domain/book/application/BookLoanRecordService.java index e4a62d7fa..352214c4c 100644 --- a/src/main/java/page/clab/api/domain/book/application/BookLoanRecordService.java +++ b/src/main/java/page/clab/api/domain/book/application/BookLoanRecordService.java @@ -130,7 +130,7 @@ public PagedResponseDto getOverdueBookLoanReco } public BookLoanRecord getBookLoanRecordByBookAndReturnedAtIsNullOrThrow(Book book) { - return bookLoanRecordRepository.findByBookAndReturnedAtIsNull(book) + return bookLoanRecordRepository.findByBookAndReturnedAtIsNullAndStatus(book, BookLoanStatus.APPROVED) .orElseThrow(() -> new NotFoundException("해당 도서 대출 기록이 없습니다.")); } diff --git a/src/main/java/page/clab/api/domain/book/application/BookService.java b/src/main/java/page/clab/api/domain/book/application/BookService.java index 224104e2c..b4e483478 100644 --- a/src/main/java/page/clab/api/domain/book/application/BookService.java +++ b/src/main/java/page/clab/api/domain/book/application/BookService.java @@ -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; @@ -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); } diff --git a/src/main/java/page/clab/api/domain/book/dao/BookLoanRecordRepository.java b/src/main/java/page/clab/api/domain/book/dao/BookLoanRecordRepository.java index a9ccc3fcc..0998e4554 100644 --- a/src/main/java/page/clab/api/domain/book/dao/BookLoanRecordRepository.java +++ b/src/main/java/page/clab/api/domain/book/dao/BookLoanRecordRepository.java @@ -10,7 +10,7 @@ public interface BookLoanRecordRepository extends JpaRepository, BookLoanRecordRepositoryCustom { - Optional findByBookAndReturnedAtIsNull(Book book); + Optional findByBookAndReturnedAtIsNullAndStatus(Book book, BookLoanStatus bookLoanStatus); Optional findByBookAndBorrowerAndStatus(Book book, Member borrower, BookLoanStatus bookLoanStatus);