bizzcuit

BookService

Sep 25th, 2019
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. package com.rewe.exercise.bookstore.book;
  2.  
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.stereotype.Service;
  5.  
  6. import java.util.List;
  7.  
  8. @Service
  9. public class BookService {
  10.  
  11. private final BookRepository bookRepository;
  12.  
  13. @Autowired
  14. public BookService(BookRepository bookRepository) {
  15. this.bookRepository = bookRepository;
  16. }
  17.  
  18. List<BookEntity> getAllBooks() {
  19. return bookRepository.findAll();
  20. }
  21.  
  22. List<BookEntity> getBooksByTitle(String title) {
  23. return bookRepository.findBooksByTitleContainingIgnoreCase(title);
  24. }
  25.  
  26. List<BookEntity> getBooksByAuthorsName(String name) {
  27. return bookRepository.findAllByFirstNameOrLastName(name);
  28. }
  29.  
  30. }
Add Comment
Please, Sign In to add comment