From 3dfc0a41c770d18b47ca92649ef6b7841dc2526d Mon Sep 17 00:00:00 2001 From: Tanisha Chavan <151942801+Tanisha0708@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:58:37 +0530 Subject: [PATCH] Update BookService.java Added book.setKeyword(bookDtoDetails.getKeyword()); to the updateBook method. included keyword in bookService better access --- src/main/java/com/libraryman_api/book/BookService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/libraryman_api/book/BookService.java b/src/main/java/com/libraryman_api/book/BookService.java index 292684c..fa19cdd 100644 --- a/src/main/java/com/libraryman_api/book/BookService.java +++ b/src/main/java/com/libraryman_api/book/BookService.java @@ -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); } @@ -137,7 +138,7 @@ public void deleteBook(int bookId) { *

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.

+ * copies available, and keyword, from the entity to the DTO.

* * @param book the entity object containing book information * @return a BookDto object with data populated from the entity @@ -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; } @@ -161,14 +163,13 @@ public BookDto EntityToDto(Book book) { * *

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.

+ * book ID, author, genre, publisher, published year, title, ISBN, copies + * available, and keyword, from the DTO to the entity.

* * @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()); @@ -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; } }