diff --git a/app/Http/Api/Controllers/ChapterController.php b/app/Http/Api/Controllers/ChapterController.php index 1b96f7c5..dedc7caa 100644 --- a/app/Http/Api/Controllers/ChapterController.php +++ b/app/Http/Api/Controllers/ChapterController.php @@ -12,7 +12,6 @@ use App\Services\Logic\Chapter\ChapterLike as ChapterLikeService; use App\Services\Logic\Chapter\CommentList as CommentListService; use App\Services\Logic\Chapter\ConsultList as ConsultListService; use App\Services\Logic\Chapter\Learning as LearningService; -use App\Services\Logic\Chapter\ResourceList as ResourceListService; /** * @RoutePrefix("/api/chapter") @@ -44,18 +43,6 @@ class ChapterController extends Controller return $this->jsonPaginate($pager); } - /** - * @Get("/{id:[0-9]+}/resources", name="api.chapter.resourses") - */ - public function resourcesAction($id) - { - $service = new ResourceListService(); - - $resources = $service->handle($id); - - return $this->jsonSuccess(['resources' => $resources]); - } - /** * @Get("/{id:[0-9]+}/info", name="api.chapter.info") */ @@ -73,6 +60,10 @@ class ChapterController extends Controller $this->notFound(); } + if ($chapter['me']['logged'] == 0) { + $this->unauthorized(); + } + if ($chapter['me']['owned'] == 0) { $this->forbidden(); } diff --git a/app/Http/Home/Views/course/show_meta.volt b/app/Http/Home/Views/course/show_meta.volt index e480730d..ee90ff71 100644 --- a/app/Http/Home/Views/course/show_meta.volt +++ b/app/Http/Home/Views/course/show_meta.volt @@ -92,7 +92,7 @@
{{ model_type(course.model) }} - {{ course.title }} + {{ course.title }}
{% if course.model == 1 %} diff --git a/app/Services/ChapterVod.php b/app/Services/ChapterVod.php index 6b2e174e..51b55431 100644 --- a/app/Services/ChapterVod.php +++ b/app/Services/ChapterVod.php @@ -50,7 +50,7 @@ class ChapterVod extends Service $result = []; - foreach ($vod->file_transcode as $key => $file) { + foreach ($vod->file_transcode as $file) { $file['url'] = $vodService->getPlayUrl($file['url']); $type = $this->getDefinitionType($file['height']); $result[$type] = $file; diff --git a/app/Traits/Response.php b/app/Traits/Response.php index 9ba736c2..270fa081 100644 --- a/app/Traits/Response.php +++ b/app/Traits/Response.php @@ -9,14 +9,20 @@ namespace App\Traits; use App\Exceptions\Forbidden as ForbiddenException; use App\Exceptions\NotFound as NotFoundException; -use Phalcon\Config; -use Phalcon\Di; +use App\Exceptions\Unauthorized as UnauthorizedException; +use Phalcon\Config as Config; +use Phalcon\Di as Di; use Phalcon\Http\Request as HttpRequest; use Phalcon\Http\Response as HttpResponse; trait Response { + public function unauthorized() + { + throw new UnauthorizedException('sys.unauthorized'); + } + public function forbidden() { throw new ForbiddenException('sys.forbidden'); diff --git a/db/migrations/20210324064239.php b/db/migrations/20210324064239.php index 81725855..4320717a 100644 --- a/db/migrations/20210324064239.php +++ b/db/migrations/20210324064239.php @@ -2138,7 +2138,7 @@ final class V20210324064239 extends AbstractMigration ->addColumn('open_avatar', 'string', [ 'null' => false, 'default' => '', - 'limit' => 150, + 'limit' => 255, 'collation' => 'utf8mb4_general_ci', 'encoding' => 'utf8mb4', 'comment' => '开放头像',