src/AppBundle/Controller/Callback/CloudSearch/Resource/Courses.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace AppBundle\Controller\Callback\CloudSearch\Resource;

use AppBundle\Controller\Callback\CloudSearch\BaseProvider;
use AppBundle\Common\ArrayToolkit;
use Symfony\Component\HttpFoundation\Request;

/**
 * 课程资源集合(对应course_set表).
 */
class Courses extends BaseProvider
{
    public function get(Request $request)
    {
        $conditions = $request->query->all();
        $cursor = $request->query->get('cursor', time());
        $start = $request->query->get('start', 0);
        $limit = $request->query->get('limit', 20);

        $conditions['status'] = 'published';
        $conditions['parentId'] = 0;
        $conditions['updatedTime_GE'] = $cursor;

        $courseSets = $this->getCourseSetService()->searchCourseSets($conditions, array('updatedTime' => 'ASC'), $start, $limit);
        $courseSets = $this->build($courseSets);
        $next = $this->nextCursorPaging($cursor, $start, $limit, $courseSets);

        return $this->wrap($this->filter($courseSets), $next);
    }

    public function filter($res)
    {
        return $this->multicallFilter('course', $res);
    }

    public function build($courseSets)
    {
        $courseSets = $this->buildCategories($courseSets);
        $courseSets = $this->buildTags($courseSets);
        $courseSets = $this->buildCourses($courseSets);

        return $courseSets;
    }

    protected function buildCategories($courseSets)
    {
        $categoryIds = ArrayToolkit::column($courseSets, 'categoryId');
        $categories = $this->getCategoryService()->findCategoriesByIds($categoryIds);

        foreach ($courseSets as &$courseSet) {
            if (isset($categories[$courseSet['categoryId']])) {
                $courseSet['category'] = array(
                    'id' => $categories[$courseSet['categoryId']]['id'],
                    'name' => $categories[$courseSet['categoryId']]['name'],
                );
            } else {
                $courseSet['category'] = array();
            }
        }

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。