Files
cunkebao_v3/Server/application/command/ContentItemOssBackfillCommand.php
Manus AI 5517457929 sync: 以本地为准同步全量变更至 GitHub
含四端需求文档、前端/后端/超管/触客宝迭代及部署脚本更新;未拉取远程。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-30 04:24:56 +08:00

50 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\command;
use app\cunkebao\service\ContentItemMediaService;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\console\input\Option;
/**
* 内容库素材 · 将 resUrls 归档到 ossUrls部署前/素材裂图修复)
*
* 用法:
* php think content:oss-backfill --libraryId=230 --limit=100
* php think content:oss-backfill --itemId=15058
*/
class ContentItemOssBackfillCommand extends Command
{
protected function configure()
{
$this->setName('content:oss-backfill')
->setDescription('内容库素材图片归档 OSS修复素材管理裂图')
->addOption('libraryId', null, Option::VALUE_OPTIONAL, '内容库 ID', 0)
->addOption('itemId', null, Option::VALUE_OPTIONAL, '单条素材 ID', 0)
->addOption('limit', null, Option::VALUE_OPTIONAL, '批量条数', 50);
}
protected function execute(Input $input, Output $output)
{
$itemId = (int)$input->getOption('itemId');
if ($itemId > 0) {
$ok = ContentItemMediaService::backfillItemOss($itemId);
$output->writeln($ok ? "素材 {$itemId} OSS 回填成功" : "素材 {$itemId} 无需更新或下载失败");
return $ok ? 0 : 1;
}
$libraryId = (int)$input->getOption('libraryId');
if ($libraryId <= 0) {
$output->writeln('请指定 --libraryId 或 --itemId');
return 1;
}
$limit = max(1, (int)$input->getOption('limit'));
$count = ContentItemMediaService::backfillLibrary($libraryId, $limit);
$output->writeln("内容库 {$libraryId}:成功回填 OSS {$count}limit={$limit}");
return 0;
}
}