64 lines
1.8 KiB
PHP
64 lines
1.8 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\PlatformService;
|
|
use think\App;
|
|
|
|
/**
|
|
* 平台账号管理控制器。
|
|
*
|
|
* 本控制器仅提供小程序“平台账号管理”所需的最基础只读接口,
|
|
* 关键字段和状态含义按 acgpmw `platform.php` 列表逻辑对齐。
|
|
*/
|
|
class Platform extends BaseController
|
|
{
|
|
protected PlatformService $platformService;
|
|
|
|
public function __construct(App $app)
|
|
{
|
|
parent::__construct($app);
|
|
$this->platformService = new PlatformService();
|
|
}
|
|
|
|
/**
|
|
* 平台账号列表。
|
|
*
|
|
* GET /api/v1/platform/accounts
|
|
*
|
|
* 请求参数:
|
|
* - `platform`:平台编号,可选;为空时返回全部平台
|
|
*
|
|
* 返回结构:
|
|
* - `filters`:当前平台筛选项
|
|
* - `summary`:当前筛选结果统计
|
|
* - `list`:账号列表,含账号授权、数据授权、异常状态
|
|
*/
|
|
public function accounts()
|
|
{
|
|
try {
|
|
$userid = $this->getLoginUserId();
|
|
|
|
$platformInput = $this->request->get('platform');
|
|
$platform = null;
|
|
|
|
if ($platformInput !== null && $platformInput !== '' && $platformInput !== 'all') {
|
|
if (!is_numeric((string) $platformInput)) {
|
|
return Response::error('平台参数格式错误', 400);
|
|
}
|
|
|
|
$platform = (int) $platformInput;
|
|
}
|
|
|
|
$result = $this->platformService->getAccountList($userid, $platform);
|
|
|
|
return Response::success($result);
|
|
} catch (\Exception $exception) {
|
|
return Response::error($exception->getMessage(), $exception->getCode() ?: 500);
|
|
}
|
|
}
|
|
}
|