api/src/Topxia/Api/Resource/ThreadPosts.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Topxia\Api\Resource;
use Silex\Application;
use AppBundle\Common\ArrayToolkit;
use Symfony\Component\HttpFoundation\Request;
class ThreadPosts extends BaseResource
{
public function get(Application $app, Request $request, $threadId)
{
$type = $request->query->get('type', 'course');
$courseId = $request->query->get('courseId', 0);
$posts = array();
if ($type == 'course') {
if ($courseId == 0) {
$thread = $this->getCourseThreadService()->getThread($courseId, $threadId);
$courseId = $thread['courseId'];
}
$conditions = array(
'threadId' => $threadId,
);
$total = $this->getCourseThreadService()->getThreadPostCount($courseId, $threadId);
$posts = $this->getCourseThreadService()->searchThreadPosts(
$conditions,
'elite',
0,
$total
);
} else {
$conditions = array(
'threadId' => $threadId,
'parentId' => 0,
);
$total = $this->getThreadService()->searchPostsCount($conditions);
$posts = $this->getThreadService()->searchPosts(
$conditions,
array('createdTime' => 'ASC'),
0,
$total
);
}
$userIds = ArrayToolkit::column($posts, 'userId');
$users = $this->getUserService()->findUsersByIds($userIds);
foreach ($posts as $key => $value) {
$posts[$key]['user'] = $this->simpleUser($users[$value['userId']]);
}
return $this->wrap($this->filter($posts), $total);
}
public function filter($res)
{
return $this->multicallFilter('ThreadPost', $res);
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。