@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); }
@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); }
@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; }
@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; }