Skip to content

Commit

Permalink
Merge pull request #8 from f-lab-edu/feature/1
Browse files Browse the repository at this point in the history
헝가리안 표기법 제거(메서드, 변수)
  • Loading branch information
shine-17 authored Dec 16, 2024
2 parents d7e5d7c + 4d45df6 commit 5ee5c6f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public ResponseEntity<MemberDto> member(@PathVariable long id) {
@PostMapping("/member/borrow")
@ResponseBody
public ResponseEntity<List<BorrowDto>> borrowBook(@RequestBody RequestBorrowDto requestBorrowDto) {
List<Borrow> borrowList = memberService.borrowBook(requestBorrowDto.getMemberId(), requestBorrowDto.getBookdIdList());
return ResponseEntity.ok(borrowMapper.toBorrowDtoList(borrowList));
List<Borrow> borrows = memberService.borrowBook(requestBorrowDto.getMemberId(), requestBorrowDto.getBookdIdList());
return ResponseEntity.ok(borrowMapper.toBorrowDtoList(borrows));
}

}
8 changes: 4 additions & 4 deletions src/main/java/com/study/bookcafe/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ public boolean canBorrow() {
return this.getLevel().isBookBorrowCountLeft(getBorrowCount());
}

public List<Borrow> borrowBook(List<Book> bookList) {
List<Borrow> borrowList = new ArrayList<>();
public List<Borrow> borrowBook(List<Book> books) {
List<Borrow> 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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.study.bookcafe.dao;
package com.study.bookcafe.repository;

import com.study.bookcafe.domain.Book;

Expand All @@ -7,5 +7,5 @@

public interface BookRepository {
Book findById(long bookId);
List<Book> findByIdList(Collection<Long> bookIds);
List<Book> findByIds(Collection<Long> bookIds);
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -35,7 +35,7 @@ public Book findById(long bookId) {
}

@Override
public List<Book> findByIdList(Collection<Long> bookIds) {
public List<Book> findByIds(Collection<Long> bookIds) {
List<BookEntity> bookEntities = bookIds.stream()
.filter(id -> books.containsKey(id))
.map(id -> books.get(id)).toList();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/study/bookcafe/service/BookService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public interface BookService {
Book findById(long bookId);

// 도서 목록 조회 (id list)
List<Book> findByIdList(Collection<Long> bookIds);
List<Book> findByIds(Collection<Long> bookIds);
}
6 changes: 3 additions & 3 deletions src/main/java/com/study/bookcafe/service/BookServiceImpl.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -34,7 +34,7 @@ public Book findById(long bookId) {
* @return 도서 목록
*/
@Override
public List<Book> findByIdList(Collection<Long> bookIds) {
return bookRepository.findByIdList(bookIds);
public List<Book> findByIds(Collection<Long> bookIds) {
return bookRepository.findByIds(bookIds);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -43,7 +43,7 @@ public Member findById(long memberId) {
@Override
public List<Borrow> borrowBook(long memberId, Collection<Long> bookIds) {
Member member = findById(memberId);
List<Book> books = bookService.findByIdList(bookIds);
List<Book> books = bookService.findByIds(bookIds);
List<Borrow> borrows = member.borrowBook(books);

if(borrows.isEmpty()) return borrows;
Expand Down

0 comments on commit 5ee5c6f

Please sign in to comment.