1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-30 22:24:55 +08:00
course-tencent-cloud/app/Http/Api/Controllers/ChapterController.php
koogua 4cae5ece11 !16 v1.2.0阶段性合并
* 更换README.md中的简书图床为gitee本地
* 修复编辑器图片上传,增加上传文件身份认证,markdown内容解析
* 移除Mobile模块,修复API请求章节信息权限问题
2020-11-27 09:38:54 +08:00

84 lines
1.9 KiB
PHP

<?php
namespace App\Http\Api\Controllers;
use App\Services\Logic\Chapter\ChapterInfo as ChapterInfoService;
use App\Services\Logic\Chapter\ChapterLike as ChapterLikeService;
use App\Services\Logic\Chapter\ConsultList as ChapterConsultListService;
use App\Services\Logic\Chapter\Learning as ChapterLearningService;
use App\Services\Logic\Chapter\ResourceList as ChapterResourceListService;
/**
* @RoutePrefix("/api/chapter")
*/
class ChapterController extends Controller
{
/**
* @Get("/{id:[0-9]+}/consults", name="api.chapter.consults")
*/
public function consultsAction($id)
{
$service = new ChapterConsultListService();
$pager = $service->handle($id);
return $this->jsonSuccess(['pager' => $pager]);
}
/**
* @Get("/{id:[0-9]+}/resources", name="api.chapter.resourses")
*/
public function resourcesAction($id)
{
$service = new ChapterResourceListService();
$resources = $service->handle($id);
return $this->jsonSuccess(['resources' => $resources]);
}
/**
* @Get("/{id:[0-9]+}/info", name="api.chapter.info")
*/
public function infoAction($id)
{
$service = new ChapterInfoService();
$chapter = $service->handle($id);
$owned = $chapter['me']['owned'] ?? false;
if (!$owned) {
return $this->jsonError(['msg' => '没有访问章节权限']);
}
return $this->jsonSuccess(['chapter' => $chapter]);
}
/**
* @Post("/{id:[0-9]+}/like", name="api.chapter.like")
*/
public function likeAction($id)
{
$service = new ChapterLikeService();
$service->handle($id);
return $this->jsonSuccess();
}
/**
* @Post("/{id:[0-9]+}/learning", name="api.chapter.learning")
*/
public function learningAction($id)
{
$service = new ChapterLearningService();
$service->handle($id);
return $this->jsonSuccess();
}
}