public function newComment($document_id, $content)
 {
     $this->requireLogin();
     //调用评论插件写入数据库
     $addon = new LocalCommentAddon();
     $model = $addon->getCommentModel();
     $comment_id = $model->addComment($this->getUid(), $document_id, $content);
     if (!$comment_id) {
         $this->apiError(2301, "评论失败");
     }
     //返回成功消息
     $this->apiSuccess("评论成功", null, array('comment_id' => $comment_id));
 }
Beispiel #2
0
 public function listTakePartIn($uid = 0, $offset = 0, $count = 10, $comment_count = 2)
 {
     //默认UID
     if (!$uid) {
         $this->requireLogin();
         $uid = $this->getUid();
     }
     //确认参数正确
     if ($uid <= 0 || $offset < 0 || $count < 0 || $comment_count < 0) {
         $this->apiError(400, '参数错误');
     }
     //读取指定任务的评论列表
     $addon = new LocalCommentAddon();
     $map = array('uid' => $uid, 'status' => 1);
     $model = $addon->getCommentModel();
     $result = $model->where($map)->order('create_time desc')->field('DISTINCT document_id')->limit("{$offset},{$count}")->select();
     $totalCount = $model->where($map)->order('create_time desc')->count('DISTINCT document_id');
     if (!$result) {
         $result = array();
     }
     //获取主题的详细信息
     foreach ($result as &$e) {
         $e = $this->getTopicStructure($e['document_id'], $comment_count);
     }
     //返回成功结果
     $this->apiSuccess("获取成功", null, array('total_count' => $totalCount, 'list' => $result));
 }