Commit 028f7a8a authored by xiabin's avatar xiabin

add 404

parent 066dc72f
...@@ -21,6 +21,7 @@ use yii\filters\AccessControl; ...@@ -21,6 +21,7 @@ use yii\filters\AccessControl;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\web\ForbiddenHttpException; use yii\web\ForbiddenHttpException;
use yii\web\HttpException;
class HomeController extends \yii\web\Controller class HomeController extends \yii\web\Controller
{ {
...@@ -60,6 +61,7 @@ class HomeController extends \yii\web\Controller ...@@ -60,6 +61,7 @@ class HomeController extends \yii\web\Controller
* 首页 * 首页
* @param $classId 课堂id * @param $classId 课堂id
* @return string * @return string
* @throws HttpException
*/ */
public function actionIndex($classId) public function actionIndex($classId)
{ {
...@@ -71,7 +73,7 @@ class HomeController extends \yii\web\Controller ...@@ -71,7 +73,7 @@ class HomeController extends \yii\web\Controller
'classInfo' => $classInfo 'classInfo' => $classInfo
]); ]);
} else { } else {
throw new InvalidParamException('参数错误'); throw new HttpException(404,'页面不存在');
} }
} }
...@@ -82,7 +84,7 @@ class HomeController extends \yii\web\Controller ...@@ -82,7 +84,7 @@ class HomeController extends \yii\web\Controller
* @param $classId * @param $classId
* @param $page * @param $page
* @param int $num * @param int $num
* @throws ForbiddenHttpException * @throws HttpException
*/ */
public function actionGetCourseLists($classId, $page, $num = 10) public function actionGetCourseLists($classId, $page, $num = 10)
{ {
...@@ -90,7 +92,7 @@ class HomeController extends \yii\web\Controller ...@@ -90,7 +92,7 @@ class HomeController extends \yii\web\Controller
if ($page >= 0 and $num > 0) { if ($page >= 0 and $num > 0) {
$result = Course::getCourseListsByClassId($classId, $page, $num); $result = Course::getCourseListsByClassId($classId, $page, $num);
} else { } else {
throw new InvalidParamException('参数错误'); throw new HttpException(404,'页面不存在');
} }
} else { } else {
throw new ForbiddenHttpException('非法请求'); throw new ForbiddenHttpException('非法请求');
......
...@@ -43,7 +43,6 @@ $qiniu = \Yii::$app->qiniu; ...@@ -43,7 +43,6 @@ $qiniu = \Yii::$app->qiniu;
target="_blank"><?= $course['name'] ?></a></div> target="_blank"><?= $course['name'] ?></a></div>
<?php endif; ?> <?php endif; ?>
<div class="teacher"> <div class="teacher">
<?php if ($course['teachers']) { ?>讲师:<?= join(', ', array_column($course['teachers'], 'name')) ?><?php } ?> <?php if ($course['teachers']) { ?>讲师:<?= join(', ', array_column($course['teachers'], 'name')) ?><?php } ?>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment