112 lines
2.4 KiB
PHP
112 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\BaseApp\BaseController;
|
|
use App\Service\OssConfigService;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
/**
|
|
* OSS 存储配置控制器:驱动选项 / 启用切换 / 配置 CRUD
|
|
*/
|
|
class OssConfigController extends BaseController
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->service = OssConfigService::getInstance();
|
|
}
|
|
|
|
/**
|
|
* 配置列表(卡片,无密钥明文)
|
|
* @Method GET
|
|
*/
|
|
public function list(): JsonResponse
|
|
{
|
|
return jok($this->service->listConfigs(), '获取成功');
|
|
}
|
|
|
|
/**
|
|
* @Method NO
|
|
*/
|
|
public function option(): mixed
|
|
{
|
|
return jerr('不支持');
|
|
}
|
|
|
|
/**
|
|
* @Method NO
|
|
*/
|
|
public function detail(): JsonResponse
|
|
{
|
|
return jerr('不支持');
|
|
}
|
|
|
|
/**
|
|
* 新增配置(覆盖基类,走加密逻辑)
|
|
* @Method POST
|
|
*/
|
|
public function create(): JsonResponse
|
|
{
|
|
return jok($this->service->createConfig(request()->post()), '创建成功');
|
|
}
|
|
|
|
/**
|
|
* 更新配置
|
|
* @Method POST
|
|
*/
|
|
public function update(): JsonResponse
|
|
{
|
|
$params = request()->post();
|
|
$id = (int) ($params['id'] ?? 0);
|
|
if ($id <= 0) {
|
|
return jerr('参数错误');
|
|
}
|
|
unset($params['id']);
|
|
return jok($this->service->updateConfig($id, $params), '更新成功');
|
|
}
|
|
|
|
/**
|
|
* 删除配置
|
|
* @Method POST
|
|
*/
|
|
public function delete(): JsonResponse
|
|
{
|
|
$ids = request()->post('ids');
|
|
if (empty($ids)) {
|
|
return jerr('参数错误');
|
|
}
|
|
if (!is_array($ids)) {
|
|
$ids = [$ids];
|
|
}
|
|
return jok($this->service->deleteConfigs($ids), '删除成功');
|
|
}
|
|
|
|
/**
|
|
* 驱动枚举选项
|
|
* @Method GET
|
|
*/
|
|
public function driverOptions(): JsonResponse
|
|
{
|
|
return jok($this->service->driverOptions(), '获取成功');
|
|
}
|
|
|
|
/**
|
|
* 运行时选项(卡片 + 当前启用)
|
|
* @Method GET
|
|
*/
|
|
public function runtimeOptions(): JsonResponse
|
|
{
|
|
return jok($this->service->getRuntimeOptions(), '获取成功');
|
|
}
|
|
|
|
/**
|
|
* 启用指定配置
|
|
* @Method POST
|
|
*/
|
|
public function saveRuntime(): JsonResponse
|
|
{
|
|
return jok($this->service->saveRuntime(request()->post()), '保存成功');
|
|
}
|
|
}
|