1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-21 03:17:05 +08:00
course-tencent-cloud/app/Http/Home/Controllers/TeacherConsoleController.php
xiaochong0302 0a1c64d2b6 1.简化部分路由地址
2.优化账户安全以及登录页面
2020-09-29 18:34:47 +08:00

102 lines
2.4 KiB
PHP

<?php
namespace App\Http\Home\Controllers;
use App\Services\Logic\Teacher\Console\ConsultList as ConsultListService;
use App\Services\Logic\Teacher\Console\CourseList as CourseListService;
use App\Services\Logic\Teacher\Console\LiveList as LiveListService;
use App\Services\Logic\Teacher\Console\LivePushUrl as LivePushUrlService;
use Phalcon\Mvc\Dispatcher;
/**
* @RoutePrefix("/tc")
*/
class TeacherConsoleController extends Controller
{
public function beforeExecuteRoute(Dispatcher $dispatcher)
{
parent::beforeExecuteRoute($dispatcher);
if ($this->authUser->id == 0) {
$this->response->redirect(['for' => 'home.account.login']);
return false;
}
return true;
}
/**
* @Get("/", name="home.tc.index")
*/
public function indexAction()
{
$this->dispatcher->forward(['action' => 'courses']);
}
/**
* @Get("/courses", name="home.tc.courses")
*/
public function coursesAction()
{
$service = new CourseListService();
$pager = $service->handle();
$this->view->pick('teacher/console/courses');
$this->view->setVar('pager', $pager);
}
/**
* @Get("/lives", name="home.tc.lives")
*/
public function livesAction()
{
$service = new LiveListService();
$pager = $service->handle();
$this->view->pick('teacher/console/lives');
$this->view->setVar('pager', $pager);
}
/**
* @Get("/consults", name="home.tc.consults")
*/
public function consultsAction()
{
$service = new ConsultListService();
$pager = $service->handle();
$this->view->pick('teacher/console/consults');
$this->view->setVar('pager', $pager);
}
/**
* @Get("/live/{id:[0-9]+}", name="home.tc.live")
*/
public function liveAction($id)
{
$service = new LivePushUrlService();
$pushUrl = $service->handle($id);
$qrcode = $this->url->get(
['for' => 'home.qrcode'],
['text' => urlencode($pushUrl)]
);
$pos = strrpos($pushUrl, '/');
$obs = [
'fms_url' => substr($pushUrl, 0, $pos + 1),
'stream_code' => substr($pushUrl, $pos + 1),
];
$this->view->pick('teacher/console/live');
$this->view->setVar('qrcode', $qrcode);
$this->view->setVar('obs', $obs);
}
}