handle(); $pager->target = 'comment-list'; $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); $this->view->setVar('pager', $pager); } /** * @Get("/{id:[0-9]+}/replies", name="home.comment.replies") */ public function repliesAction($id) { $service = new ReplyListService(); $pager = $service->handle($id); $pager->target = "reply-list-{$id}"; $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); $this->view->setVar('pager', $pager); } /** * @Get("/{id:[0-9]+}/info", name="home.comment.info") */ public function infoAction($id) { $service = new CommentInfoService(); $comment = $service->handle($id); $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); $this->view->setVar('comment', $comment); } /** * @Post("/create", name="home.comment.create") */ public function createAction() { $service = new CommentCreateService(); $comment = $service->handle(); $service = new CommentInfoService(); $comment = $service->handle($comment->id); return $this->jsonSuccess(['comment' => $comment]); } /** * @Post("/{id:[0-9]+}/reply", name="home.comment.reply") */ public function replyAction($id) { $service = new CommentReplyService(); $comment = $service->handle($id); $service = new CommentInfoService(); $comment = $service->handle($comment->id); return $this->jsonSuccess(['comment' => $comment]); } /** * @Post("/{id:[0-9]+}/like", name="home.comment.like") */ public function likeAction($id) { $service = new CommentLikeService(); $data = $service->handle($id); $msg = $data['action'] == 'do' ? '点赞成功' : '取消点赞成功'; return $this->jsonSuccess(['data' => $data, 'msg' => $msg]); } /** * @Post("/{id:[0-9]+}/delete", name="home.comment.delete") */ public function deleteAction($id) { $service = new CommentDeleteService(); $service->handle($id); return $this->jsonSuccess(['msg' => '删除评论成功']); } /** * @Route("/{id:[0-9]+}/report", name="home.comment.report") */ public function reportAction($id) { } }