Skip to content

Commit

Permalink
Renamed update methode, @repository annotation added
Browse files Browse the repository at this point in the history
  • Loading branch information
viacheslav-torbin committed Oct 20, 2023
1 parent 58ec20b commit b123fdd
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${liquibase.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/bookstore/mapper/BookMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public interface BookMapper {

Book toBook(CreateBookRequestDto bookRequestDto);

void updateBookFromDto(CreateBookRequestDto book, @MappingTarget Book entity);
void updateBook(CreateBookRequestDto book, @MappingTarget Book entity);
}
2 changes: 2 additions & 0 deletions src/main/java/org/bookstore/repository/BookRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.bookstore.model.Book;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface BookRepository extends JpaRepository<Book, Long> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public BookDto findById(Long id) {
public BookDto updateBookById(Long id, CreateBookRequestDto book) {
Book bookFromDb = bookRepository.findById(id)
.orElseThrow(() -> new EntityNotFoundException("Can't update book with id " + id));
bookMapper.updateBookFromDto(book, bookFromDb);
bookMapper.updateBook(book, bookFromDb);
return bookMapper.toDto(bookRepository.save(bookFromDb));
}

Expand Down

0 comments on commit b123fdd

Please sign in to comment.