api/src/Topxia/Api/Resource/MeChatroomes.php

(开头部分) 2KB

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

<?php

namespace Topxia\Api\Resource;

use Silex\Application;
use AppBundle\Common\ArrayToolkit;
use Biz\Course\Service\CourseService;
use Biz\Course\Service\MemberService;
use Biz\Course\Service\CourseSetService;
use Biz\Classroom\Service\ClassroomService;
use Symfony\Component\HttpFoundation\Request;

class MeChatroomes extends BaseResource
{
    public function get(Application $app, Request $request)
    {
        $start = $request->query->get('start', 0);
        $limit = $request->query->get('limit', 10);

        $user = $this->getCurrentUser();
        $classRoomChatrooms = $this->getClassRoomChatrooms($user['id']);
        $courseChatrooms = $this->getCourseChatrooms($user['id']);

        $chatrooms = array_merge($classRoomChatrooms, $courseChatrooms);

        return $this->wrap($this->filter($chatrooms), count($chatrooms));
    }

    private function getClassRoomChatrooms($userId)
    {
        $conditions = array('userId' => $userId);
        $total = $this->getClassroomService()->searchMemberCount($conditions);
        $members = $this->getClassroomService()->searchMembers($conditions, array('createdTime' => 'DESC'), 0, $total);

        $classroomIds = ArrayToolkit::column($members, 'classroomId');

        $classrooms = $this->getClassroomService()->findClassroomsByIds($classroomIds);

        $chatrooms = array();
        foreach ($classrooms as $classroom) {
            $chatrooms[] = array(
                'type' => 'classroom',
                'id' => $classroom['id'],
                'title' => $classroom['title'],
                'picture' => $this->getFileUrl($classroom['smallPicture'], 'classroom.png'),
            );
        }

        return $chatrooms;
    }

    private function getCourseChatrooms($userId)
    {
        $conditions = array('userId' => $userId);
        $total = $this->getCourseMemberService()->countMembers($conditions);
        $members = $this->getCourseMemberService()->searchMembers(
            $conditions,
            array('createdTime' => 'DESC'),
            0,
            $total

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

AI 解读 AI

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

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