feat(platform): add endpoint to retrieve platform accounts for a user

- Introduced `getPlatformAccountsByUserId` method in `DyVideoUser` model to fetch active platform accounts for a specified user.
- Added new API route for accessing platform accounts under `v1/platform/accounts`, requiring user authentication.
This commit is contained in:
nepiedg
2026-04-02 07:39:37 +00:00
parent 6b46767d86
commit c909ebdf88
5 changed files with 476 additions and 0 deletions
+46
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace app\api\model;
use think\Model;
use think\Collection;
/**
* 授权账号模型(对应 dy_video_user 表)
@@ -32,4 +33,49 @@ class DyVideoUser extends Model
->where('disabled', 0)
->count();
}
/**
* 获取当前用户的平台账号列表。
*
* 这里按 acgpmw `platform::index()` 和 `platform::get_zhanghu_list()` 的查询条件对齐:
* - 仅返回当前用户数据
* - 仅返回 `disabled=0` 的有效账号
* - 排序保持 `is_endauth desc, id desc`
*
* @param int $userid 用户ID
* @param int|null $platform 指定平台;为空时返回全部平台
* @return Collection
*/
public static function getPlatformAccountsByUserId(int $userid, ?int $platform = null): Collection
{
$query = self::where('userid', $userid)
->where('disabled', 0)
->order(['is_endauth' => 'desc', 'id' => 'desc'])
->field([
'id',
'userid',
'platform',
'is_lanv',
'is_endauth',
'aa_endauth',
'browser',
'is_qyh',
'proviceid',
'info_shouji',
'dy_avatar',
'dy_nickname',
'dy_intro',
'dy_account',
'dy_openid',
'dy_unique_id',
'addtime',
'updatetime',
]);
if ($platform !== null) {
$query->where('platform', $platform);
}
return $query->select();
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace app\api\model;
use think\Model;
/**
* TikTok 账号附表模型(对应 dy_video_user_titk 表)
*
* 该表在 acgpmw 平台账号管理页用于补充 TikTok 账号的国家信息。
*/
class DyVideoUserTitk extends Model
{
protected $connection = 'dbmember';
protected $name = 'dy_video_user_titk';
protected $pk = 'id';
protected $autoWriteTimestamp = false;
/**
* 根据授权账号 ID 获取 TikTok 附加信息。
*
* @param int $vuid 授权账号主表 ID
* @return self|null
*/
public static function findByVuid(int $vuid): ?self
{
return self::where('vuid', $vuid)->find();
}
}