feat(video): add user-specific video query and filter accounts functionality
- Introduced `buildUserQuery` method in `DysVideoLog` model to create a base query for user-specific video logs. - Added `getVideoFilterAccountsByUserId` method in `DyVideoUser` model to retrieve active accounts for a specified user. - Updated routing to include new video work API endpoints under `v1/video-work`, requiring user authentication.
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?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 {
|
||||
$payload = $this->request->payload ?? null;
|
||||
if (!$payload || empty($payload['userid'])) {
|
||||
return Response::error('未登录', 401);
|
||||
}
|
||||
|
||||
$result = $this->videoWorkService->getVideoList((int) $payload['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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user