Exemple #1
0
  @RequestMapping(value = "{bookId}", method = RequestMethod.DELETE)
  public String deleteBook(@PathVariable long bookId, ModelMap model) {
    Book book = bookService.getBook(bookId);
    bookService.deleteBook(bookId);

    return "redirect:/categories/" + book.getCategoryId();
  }
  @RequestMapping(method = RequestMethod.POST)
  public String submitForm(@ModelAttribute BookSearch search, Model m) {
    List<Book> books = null;

    if (StringUtils.isNotBlank(search.getTitle())) {
      books = bookService.getBooksByTitle(search.getTitle());
    } else if (StringUtils.isNotBlank(search.getAuthor())) {
      books = bookService.getBooksByAuthorSurname(search.getAuthor());
    } else if (StringUtils.isNotBlank(search.getIsbn())) {
      books = bookService.getBooksByISBN(search.getIsbn());
    }

    m.addAttribute("books", books);

    return "viewBooks";
  }
Exemple #3
0
  @RequestMapping(value = "author/{authorId}", method = RequestMethod.GET)
  public String getBooksByAuthor(@PathVariable long authorId, ModelMap model) {
    List<Book> books = bookService.getBooksByAuthor(authorId);
    model.addAttribute("books", books);

    return "viewBooks";
  }
Exemple #4
0
  @RequestMapping(value = "{bookId}", method = RequestMethod.GET)
  public String getBook(@PathVariable long bookId, ModelMap model) {
    Book book = bookService.getBook(bookId);
    model.addAttribute("book", book);

    return "viewBook";
  }