From bedcfe5e49499302b22276c6017c404965b17ac1 Mon Sep 17 00:00:00 2001 From: mingmingmon Date: Sat, 4 May 2024 00:13:02 +0900 Subject: [PATCH] =?UTF-8?q?bug:=20=EB=8F=84=EC=84=9C=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=20=EB=B0=8F=20=EB=8C=80=EC=B6=9C=20=EC=97=B0=EC=9E=A5=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?#327?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/domain/book/application/BookLoanRecordService.java | 2 +- .../page/clab/api/domain/book/application/BookService.java | 3 ++- .../clab/api/domain/book/dao/BookLoanRecordRepository.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) 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);