64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace app\api\controller\v1;
|
|
|
|
use app\api\common\Response;
|
|
use app\api\controller\BaseController;
|
|
use app\api\service\VideoWorkService;
|
|
use think\App;
|
|
|
|
/**
|
|
* 视频作品控制器。
|
|
*
|
|
* 本控制器用于给小程序“视频作品”页面提供只读数据:
|
|
* 1. 平台筛选
|
|
* 2. 账号筛选
|
|
* 3. 作品列表与分页
|
|
*/
|
|
class VideoWork extends BaseController
|
|
{
|
|
protected VideoWorkService $videoWorkService;
|
|
|
|
public function __construct(App $app)
|
|
{
|
|
parent::__construct($app);
|
|
$this->videoWorkService = new VideoWorkService();
|
|
}
|
|
|
|
/**
|
|
* 视频作品列表。
|
|
*
|
|
* GET /api/v1/video-work/list
|
|
*
|
|
* 请求参数:
|
|
* - `platform`:平台编号,传 `all` 时不过滤
|
|
* - `vuid`:账号ID,传 `all` 时不过滤
|
|
* - `page`:页码
|
|
* - `page_size`:每页数量
|
|
*
|
|
* 返回结构:
|
|
* - `filters`:平台与账号筛选项
|
|
* - `summary`:顶部统计卡片
|
|
* - `pagination`:分页信息
|
|
* - `list`:作品卡片列表
|
|
*/
|
|
public function index()
|
|
{
|
|
try {
|
|
$userid = $this->getLoginUserId();
|
|
|
|
$result = $this->videoWorkService->getVideoList($userid, [
|
|
'platform' => $this->request->get('platform', 'all'),
|
|
'vuid' => $this->request->get('vuid', 'all'),
|
|
'page' => (int) $this->request->get('page', 1),
|
|
'page_size' => (int) $this->request->get('page_size', 12),
|
|
]);
|
|
|
|
return Response::success($result);
|
|
} catch (\Exception $exception) {
|
|
return Response::error($exception->getMessage(), $exception->getCode() ?: 500);
|
|
}
|
|
}
|
|
}
|