diff --git a/src/main/java/com/study/bookcafe/controller/MemberController.java b/src/main/java/com/study/bookcafe/controller/MemberController.java index 24df377..c4eb7af 100644 --- a/src/main/java/com/study/bookcafe/controller/MemberController.java +++ b/src/main/java/com/study/bookcafe/controller/MemberController.java @@ -36,8 +36,8 @@ public ResponseEntity member(@PathVariable long id) { @PostMapping("/member/borrow") @ResponseBody public ResponseEntity> borrowBook(@RequestBody RequestBorrowDto requestBorrowDto) { - List borrowList = memberService.borrowBook(requestBorrowDto.getMemberId(), requestBorrowDto.getBookdIdList()); - return ResponseEntity.ok(borrowMapper.toBorrowDtoList(borrowList)); + List borrows = memberService.borrowBook(requestBorrowDto.getMemberId(), requestBorrowDto.getBookdIdList()); + return ResponseEntity.ok(borrowMapper.toBorrowDtoList(borrows)); } } diff --git a/src/main/java/com/study/bookcafe/domain/Member.java b/src/main/java/com/study/bookcafe/domain/Member.java index d6e839b..31266cc 100644 --- a/src/main/java/com/study/bookcafe/domain/Member.java +++ b/src/main/java/com/study/bookcafe/domain/Member.java @@ -27,16 +27,16 @@ public boolean canBorrow() { return this.getLevel().isBookBorrowCountLeft(getBorrowCount()); } - public List borrowBook(List bookList) { - List borrowList = new ArrayList<>(); + public List borrowBook(List books) { + List borrows = new ArrayList<>(); // 회원이 대출 가능한 상태 확인 if(!this.canBorrow()) { - return borrowList; + return borrows; } // 대출 가능한 도서만 목록에 담기 - return bookList.stream() + return books.stream() .filter(Book::canBorrow) .map(book -> new Borrow(this, book, LocalDateTime.now())) .toList(); diff --git a/src/main/java/com/study/bookcafe/dao/BookRepository.java b/src/main/java/com/study/bookcafe/repository/BookRepository.java similarity index 64% rename from src/main/java/com/study/bookcafe/dao/BookRepository.java rename to src/main/java/com/study/bookcafe/repository/BookRepository.java index 6fe945e..7b29044 100644 --- a/src/main/java/com/study/bookcafe/dao/BookRepository.java +++ b/src/main/java/com/study/bookcafe/repository/BookRepository.java @@ -1,4 +1,4 @@ -package com.study.bookcafe.dao; +package com.study.bookcafe.repository; import com.study.bookcafe.domain.Book; @@ -7,5 +7,5 @@ public interface BookRepository { Book findById(long bookId); - List findByIdList(Collection bookIds); + List findByIds(Collection bookIds); } diff --git a/src/main/java/com/study/bookcafe/dao/TestBookRepository.java b/src/main/java/com/study/bookcafe/repository/TestBookRepository.java similarity index 93% rename from src/main/java/com/study/bookcafe/dao/TestBookRepository.java rename to src/main/java/com/study/bookcafe/repository/TestBookRepository.java index 3f8c7ae..1f9535d 100644 --- a/src/main/java/com/study/bookcafe/dao/TestBookRepository.java +++ b/src/main/java/com/study/bookcafe/repository/TestBookRepository.java @@ -1,4 +1,4 @@ -package com.study.bookcafe.dao; +package com.study.bookcafe.repository; import com.study.bookcafe.domain.Book; import com.study.bookcafe.domain.Inventory; @@ -35,7 +35,7 @@ public Book findById(long bookId) { } @Override - public List findByIdList(Collection bookIds) { + public List findByIds(Collection bookIds) { List bookEntities = bookIds.stream() .filter(id -> books.containsKey(id)) .map(id -> books.get(id)).toList(); diff --git a/src/main/java/com/study/bookcafe/service/BookService.java b/src/main/java/com/study/bookcafe/service/BookService.java index 17b254f..49f8092 100644 --- a/src/main/java/com/study/bookcafe/service/BookService.java +++ b/src/main/java/com/study/bookcafe/service/BookService.java @@ -10,5 +10,5 @@ public interface BookService { Book findById(long bookId); // 도서 목록 조회 (id list) - List findByIdList(Collection bookIds); + List findByIds(Collection bookIds); } diff --git a/src/main/java/com/study/bookcafe/service/BookServiceImpl.java b/src/main/java/com/study/bookcafe/service/BookServiceImpl.java index 5d5d57f..b2283f9 100644 --- a/src/main/java/com/study/bookcafe/service/BookServiceImpl.java +++ b/src/main/java/com/study/bookcafe/service/BookServiceImpl.java @@ -1,6 +1,6 @@ package com.study.bookcafe.service; -import com.study.bookcafe.dao.BookRepository; +import com.study.bookcafe.repository.BookRepository; import com.study.bookcafe.domain.Book; import org.springframework.stereotype.Service; @@ -34,7 +34,7 @@ public Book findById(long bookId) { * @return 도서 목록 */ @Override - public List findByIdList(Collection bookIds) { - return bookRepository.findByIdList(bookIds); + public List findByIds(Collection bookIds) { + return bookRepository.findByIds(bookIds); } } diff --git a/src/main/java/com/study/bookcafe/service/MemberServiceImpl.java b/src/main/java/com/study/bookcafe/service/MemberServiceImpl.java index 4e37722..3b7f70a 100644 --- a/src/main/java/com/study/bookcafe/service/MemberServiceImpl.java +++ b/src/main/java/com/study/bookcafe/service/MemberServiceImpl.java @@ -1,6 +1,6 @@ package com.study.bookcafe.service; -import com.study.bookcafe.dao.MemberRepository; +import com.study.bookcafe.repository.MemberRepository; import com.study.bookcafe.domain.Book; import com.study.bookcafe.domain.Borrow; import com.study.bookcafe.domain.Member; @@ -43,7 +43,7 @@ public Member findById(long memberId) { @Override public List borrowBook(long memberId, Collection bookIds) { Member member = findById(memberId); - List books = bookService.findByIdList(bookIds); + List books = bookService.findByIds(bookIds); List borrows = member.borrowBook(books); if(borrows.isEmpty()) return borrows;