Exemplo n.º 1
0
 @RequestMapping(value = "/book/update", method = RequestMethod.POST)
 public ModelAndView doUpdate(Book book) {
   if (bookService.getBookByIsbn(book.getIsbn()) == null) {
     return getErrorView("This book is not exist.");
   }
   return saveBook(book);
 }
Exemplo n.º 2
0
 @RequestMapping(value = "/book/add", method = RequestMethod.POST)
 public ModelAndView doAdd(Book book) {
   if (bookService.getBookByIsbn(book.getIsbn()) != null) {
     return getErrorView("This Book is exist.");
   }
   return saveBook(book);
 }
Exemplo n.º 3
0
 @RequestMapping(value = "/book/delete/{isbn}", method = RequestMethod.GET)
 public ModelAndView delete(@PathVariable String isbn) {
   if (bookService.getBookByIsbn(isbn) == null) {
     return getErrorView("This book is not exist");
   }
   bookService.delete(isbn);
   ModelAndView modelAndView = new ModelAndView("books");
   modelAndView.getModel().put("books", bookService.findAll());
   return modelAndView;
 }
Exemplo n.º 4
0
 @RequestMapping(value = "/book/update/{isbn}", method = RequestMethod.GET)
 public ModelAndView update(@PathVariable String isbn) {
   Book book = bookService.getBookByIsbn(isbn);
   if (book == null) {
     return getErrorView("This book is not exist.");
   }
   ModelAndView modelAndView = new ModelAndView("updateBook");
   modelAndView.getModel().put("book", book);
   return modelAndView;
 }