src/ApiBundle/Api/Resource/Course/CourseTrialTask.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace ApiBundle\Api\Resource\Course;
use ApiBundle\Api\Annotation\ApiConf;
use ApiBundle\Api\ApiRequest;
use ApiBundle\Api\Resource\AbstractResource;
use Biz\Common\CommonException;
use Biz\Course\CourseException;
class CourseTrialTask extends AbstractResource
{
/**
* @ApiConf(isRequiredAuth=false)
*/
public function get(ApiRequest $request, $courseId, $indicator)
{
$course = $this->service('Course:CourseService')->getCourse($courseId);
if (!$course) {
throw CourseException::NOTFOUND_COURSE();
}
if ($indicator == 'first') {
return $this->getFirstTrailTask($course);
} else {
throw CommonException::ERROR_PARAMETER();
}
}
private function getFirstTrailTask($course)
{
$freeVideoTasks = $this->service('Task:TaskService')->searchTasks(
array('courseId' => $course['id'], 'isFree' => '1', 'status' => 'published'),
array('seq' => 'ASC'),
0,
1
);
if (!$freeVideoTasks && $course['tryLookable'] && $course['tryLookLength'] > 0) {
$trialVideoTasks = $this->service('Task:TaskService')->searchTasks(
array('courseId' => $course['id'], 'type' => 'video', 'status' => 'published'),
array('seq' => 'ASC'),
0,
1
);
$firstTrailTask = array_pop($trialVideoTasks);
} else {
$firstTrailTask = array_pop($freeVideoTasks);
}
return $firstTrailTask;
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。