Ejemplo n.º 1
0
 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");
 }
Ejemplo n.º 2
0
 public function test_lists()
 {
     $as = XAppSession::begin();
     $bookService = new BookService();
     $bookList = $bookService->lists();
     $as->commit();
     $this->logger->info("Book list number: " . count($bookList));
     $sameBookList = DDA::ins()->list_Book_by_status(Constants::USING);
     $this->assertTrue(count($bookList) == count($sameBookList));
     $as = null;
 }
Ejemplo n.º 3
0
 public function _run($request, $xcontext)
 {
     $authorService = new AuthorService();
     $xcontext->authorList = $authorService->lists();
     $this->logger->info("Get all authors " . count($xcontext->authorList));
     $bookService = new BookService();
     $xcontext->bookList = $bookService->lists();
     $this->logger->info("List all books " . count($xcontext->bookList));
     return XNext::useTpl("book/list.html");
 }