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:
nepiedg
2026-04-03 03:48:25 +00:00
parent 5a9d6090f3
commit be58aac7e7
5 changed files with 778 additions and 0 deletions
+24
View File
@@ -78,4 +78,28 @@ class DyVideoUser extends Model
return $query->select();
}
/**
* 获取视频作品页筛选用的账号列表。
*
* 对齐 acgpmw `video_info::video_list()`
* - 仅返回当前用户启用中的账号
* - 返回平台与昵称,供前端拼出“平台(昵称)#Pid”样式
*
* @param int $userid 用户ID
* @return Collection
*/
public static function getVideoFilterAccountsByUserId(int $userid): Collection
{
return self::where('userid', $userid)
->where('disabled', 0)
->order(['id' => 'desc'])
->field([
'id',
'platform',
'dy_nickname',
'dy_avatar',
])
->select();
}
}
+20
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace app\api\model;
use think\Model;
use think\db\Query;
/**
* 抖音发布日志模型(对应分表 dys_video_log_{userid % 1000}
@@ -41,6 +42,25 @@ class DysVideoLog extends Model
->count();
}
/**
* 构建当前用户的视频作品基础查询。
*
* 作品日志按 `dys_video_log_{userid % 1000}` 分表存储,
* 这里统一返回已定位分表且已限定用户范围的查询对象。
*
* @param int $userid 用户ID
* @return Query
*/
public static function buildUserQuery(int $userid): Query
{
$tableName = self::resolveTableName($userid);
return (new self())
->db()
->name($tableName)
->where('userid', $userid);
}
/**
* 根据用户ID计算分表名。
*