api/src/Topxia/Api/Resource/ClassRoomThreads.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Topxia\Api\Resource;
use Silex\Application;
use AppBundle\Common\ArrayToolkit;
use Symfony\Component\HttpFoundation\Request;
class ClassRoomThreads extends BaseResource
{
public function get(Application $app, Request $request, $classRoomId)
{
$start = $request->query->get('start', 0);
$limit = $request->query->get('limit', 10);
$sort = $request->query->get('sort', 'posted');
$simplify = $request->query->get('simplify', 0);
$conditions = array(
'targetType' => 'classroom',
'targetId' => $classRoomId,
);
$total = $this->getThreadService()->searchThreadCount($conditions);
$threads = $this->getThreadService()->searchThreads($conditions, $sort, $start, $limit);
$userIds = ArrayToolkit::column($threads, 'userId');
$users = $this->getUserService()->findUsersByIds($userIds);
foreach ($threads as $key => $value) {
$threads[$key]['user'] = $this->simpleUser($users[$value['userId']]);
}
$threads = $this->filter($threads);
if ($simplify) {
$threads = $this->simplify($threads);
}
return $this->wrap($threads, $total);
}
public function filter($res)
{
return $this->multicallFilter('ClassRoomThread', $res);
}
protected function simplify($res)
{
return $this->multicallSimplify('ClassRoomThread', $res);
}
protected function getThreadService()
{
return $this->getServiceKernel()->createService('Thread:ThreadService');
}
protected function getUserService()
{
return $this->getServiceKernel()->createService('User:UserService');
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。