Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update BookService.java #98

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/main/java/com/libraryman_api/book/BookService.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public BookDto updateBook(int bookId, BookDto bookDtoDetails) {
book.setPublishedYear(bookDtoDetails.getPublishedYear());
book.setGenre(bookDtoDetails.getGenre());
book.setCopiesAvailable(bookDtoDetails.getCopiesAvailable());
book.setKeyword(bookDtoDetails.getKeyword()); // Update keyword field
Book updatedBook = bookRepository.save(book);
return EntityToDto(updatedBook);
}
Expand Down Expand Up @@ -137,7 +138,7 @@ public void deleteBook(int bookId) {
* <p>This method takes a Book entity and transforms it into a BookDto object for
* data transfer between application layers. It maps all relevant book details,
* including book ID, publisher, published year, title, author, genre, ISBN,
* and copies available, from the entity to the DTO.</p>
* copies available, and keyword, from the entity to the DTO.</p>
*
* @param book the entity object containing book information
* @return a BookDto object with data populated from the entity
Expand All @@ -153,6 +154,7 @@ public BookDto EntityToDto(Book book) {
bookDto.setGenre(book.getGenre());
bookDto.setIsbn(book.getIsbn());
bookDto.setCopiesAvailable(book.getCopiesAvailable());
bookDto.setKeyword(book.getKeyword()); // Map keyword field
return bookDto;
}

Expand All @@ -161,14 +163,13 @@ public BookDto EntityToDto(Book book) {
*
* <p>This method takes a BookDto object and converts it into a Book entity for
* use in database operations. It maps all relevant book details, including
* book ID, author, genre, publisher, published year, title, ISBN, and copies
* available, from the DTO to the entity.</p>
* book ID, author, genre, publisher, published year, title, ISBN, copies
* available, and keyword, from the DTO to the entity.</p>
*
* @param bookDto the DTO object containing book information
* @return a Book entity with data populated from the DTO
*/


public Book DtoToEntity(BookDto bookDto) {
Book book = new Book();
book.setBookId(bookDto.getBookId());
Expand All @@ -179,6 +180,7 @@ public Book DtoToEntity(BookDto bookDto) {
book.setTitle(bookDto.getTitle());
book.setCopiesAvailable(bookDto.getCopiesAvailable());
book.setIsbn(bookDto.getIsbn());
book.setKeyword(bookDto.getKeyword()); // Map keyword field
return book;
}
}