Skip to content

Commit

Permalink
added a method description
Browse files Browse the repository at this point in the history
  • Loading branch information
anishmu20 committed Oct 6, 2024
1 parent e14ee36 commit 4b8c601
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/com/libraryman_api/book/BookService.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ public void deleteBook(int bookId) {
.orElseThrow(() -> new ResourceNotFoundException("Book not found"));
bookRepository.delete(book);
}
/**
* Converts a Book entity to a BookDto object.
*
* <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>
*
* @param book the entity object containing book information
* @return a BookDto object with data populated from the entity
*/

public BookDto EntityToDto(Book book){
BookDto bookDto= new BookDto();
Expand All @@ -125,6 +136,18 @@ public BookDto EntityToDto(Book book){
bookDto.setCopiesAvailable(book.getCopiesAvailable());
return bookDto;
}
/**
* Converts a BookDto object to a Book entity.
*
* <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>
*
* @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();
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/libraryman_api/borrowing/BorrowingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,19 @@ public Page<BorrowingsDto> getAllBorrowingsOfMember(int memberId, Pageable pagea
throw new InvalidSortFieldException("The specified 'sortBy' value is invalid.");
}
}
/**
* Converts a BorrowingsDto object to a Borrowings entity.
*
* <p>This method takes a BorrowingsDto object and transforms it into a Borrowings
* entity for use in database operations. It maps all relevant borrowing details
* from the DTO, including borrow date, member information, fine, return date,
* due date, and book details. It also retrieves and converts related entities
* such as Member and Book using respective service methods.</p>
*
* @param borrowingsDto the DTO object containing borrowing information
* @return a Borrowings entity with data populated from the DTO
*/


public Borrowings DtoToEntity(BorrowingsDto borrowingsDto){
Borrowings borrowings = new Borrowings();
Expand All @@ -303,6 +316,19 @@ public Borrowings DtoToEntity(BorrowingsDto borrowingsDto){
borrowings.setBorrowingId(borrowingsDto.getBorrowingId());
return borrowings;
}
/**
* Converts a Borrowings entity to a BorrowingsDto object.
*
* <p>This method takes a Borrowings entity and converts it into a BorrowingsDto
* object for data transfer between application layers. It maps all necessary
* borrowing details from the entity, including borrowing ID, fine, borrow date,
* return date, due date, and related Member and Book entities, converting them
* into DTOs using respective service methods.</p>
*
* @param borrowings the entity object containing borrowing information
* @return a BorrowingsDto object with data populated from the entity
*/


public BorrowingsDto EntityToDto(Borrowings borrowings){
BorrowingsDto borrowingsDto = new BorrowingsDto();
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/libraryman_api/member/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ public void deleteMember(int memberId) {
notificationService.accountDeletionNotification(member);
memberRepository.delete(member);
}
/**
* Converts a MembersDto object to a Members entity.
*
* <p>This method takes a MembersDto object and transforms it into a Members entity
* to be used in database operations. It maps all relevant member details from
* the DTO, including member ID, role, name, email, password, and membership date.</p>
*
* @param membersDto the DTO object containing member information
* @return a Members entity with data populated from the DTO
*/


public Members DtoEntity(MembersDto membersDto){
Members members= new Members();
Expand All @@ -146,6 +157,18 @@ public Members DtoEntity(MembersDto membersDto){
members.setMembershipDate(membersDto.getMembershipDate());
return members;
}
/**
* Converts a Members entity to a MembersDto object.
*
* <p>This method takes a Members entity object and converts it into a MembersDto
* object to be used for data transfer between layers. It maps all necessary
* member details, including member ID, name, role, email, password, and membership
* date, from the entity to the DTO.</p>
*
* @param members the entity object containing member information
* @return a MembersDto object with data populated from the entity
*/


public MembersDto EntityToDto(Members members){
MembersDto membersDto= new MembersDto();
Expand Down

0 comments on commit 4b8c601

Please sign in to comment.