public function _run($request, $xcontext) { $id = intval(Utils::testInput($request->id)); $this->logger->info("Input id: {$id}"); if (empty($id)) { $this->logger->error("Input id is empty!"); throw new Exception("need id!"); } $bookService = new BookService(); $bookList = $bookService->lists(); foreach ($bookList as $book) { if ($book->getAuthor()->id() == $id) { $nodeletion = "该作者与书籍关联,不能删除"; return XNext::action("listauthor", array("nodeletion" => $nodeletion)); } } $authorService = new AuthorService(); $author = $authorService->delete($id); $this->logger->info("Delete an author whose id is {$id}"); if (!$author || $author->id() <= 0) { $this->logger->error("failed in deleting author!"); throw new Exception("failed in deleting author!"); } return XNext::action("listauthor"); }
public function _run($request, $xcontext) { $id = intval(Utils::testInput($request->id)); $this->logger->info("Delete id: {$id}."); if (empty($id)) { $this->logger->error("Id is empty!"); throw new Exception("Id is empty!"); } $bookService = new BookService(); $book = $bookService->delete($id); $this->logger->info("Delete a book which id is {$id}"); if (!$book || $book->id() <= 0) { $this->logger->error("failed in deleting book!"); throw new Exception("failed in deleting book!"); } return XNext::action("listbook"); }
public function _run($request, $xcontext) { //return XNext::useTpl('index.html'); return XNext::action("listbook"); }