初始化
缺陷:主题配色需要优化整体的同风格
This commit is contained in:
@@ -6,6 +6,7 @@ use App\BaseApp\BaseService;
|
||||
use App\Models\oss\OssConfigModel;
|
||||
use App\Service\common\FieldEncryptService;
|
||||
use App\Service\SystemConfigService;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* OSS 运行时配置:解析当前启用的存储配置并解密密钥,供上传工厂使用
|
||||
@@ -74,6 +75,32 @@ class OssRuntimeConfigService extends BaseService
|
||||
'extra_json' => null,
|
||||
];
|
||||
}
|
||||
return $this->formatConfig($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按 ID 获取明文配置
|
||||
*
|
||||
* 素材库要对指定 bucket 做列举与删除,不能只认「当前启用」那一份:
|
||||
* 换过存储之后老素材仍然躺在旧配置的 bucket 里,回收时必须拿旧配置去删。
|
||||
* 也因此这里不校验 status —— 配置被禁用不代表里面的对象不用管了。
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getConfigById(int $id): array
|
||||
{
|
||||
$row = OssConfigModel::where('id', $id)->where('deleted_at', 0)->first();
|
||||
if (!$row) {
|
||||
$this->utils->notFound('存储配置不存在');
|
||||
}
|
||||
return $this->formatConfig($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* 库行转明文配置数组
|
||||
*/
|
||||
private function formatConfig(OssConfigModel $row): array
|
||||
{
|
||||
$enc = FieldEncryptService::getInstance();
|
||||
$extra = $row->extra_json;
|
||||
if (is_string($extra) && $extra !== '') {
|
||||
|
||||
@@ -31,4 +31,24 @@ interface OssStorageInterface
|
||||
* @return array{key:string,url:string}|false
|
||||
*/
|
||||
public function uploadVideo($filePath, string $key): bool|array;
|
||||
|
||||
/**
|
||||
* 分页列举对象
|
||||
*
|
||||
* 素材库靠 marker 一页一页往回补:bucket 上万对象时一次拉全量必然打穿
|
||||
* PHP 的执行时限,所以约定「调用方拿着 next_marker 继续要下一页」。
|
||||
*
|
||||
* @param string $prefix 只列举该前缀,留空时退回配置里的 path_prefix
|
||||
* @param string $marker 上一页返回的 next_marker,首页传空串
|
||||
* @param int $limit 单页条数
|
||||
* @return array{items: array<int, array{key:string,size:int,hash:string,last_modified:int,url:string}>, next_marker: string, finished: bool}
|
||||
*/
|
||||
public function listObjects(string $prefix = '', string $marker = '', int $limit = 100): array;
|
||||
|
||||
/**
|
||||
* 删除对象
|
||||
*
|
||||
* @param string $key 对象键(缺 path_prefix 时由实现补齐)
|
||||
*/
|
||||
public function deleteObject(string $key): bool;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user