Files
zyt/server/app/command/FollowupAudioCleanup.php
T

37 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace app\command;
use app\common\service\followupaudio\FollowupAudioStore;
use think\console\Command;
use think\console\Input;
use think\console\Output;
/** Cleanup runs even while the feature gate is off; active leases remain protected in Store. */
final class FollowupAudioCleanup extends Command
{
protected function configure()
{
$this->setName('followup-audio:cleanup')->setDescription('清理过期音频与全文,不清除已采用的正式记录');
}
protected function execute(Input $input, Output $output): int
{
try {
$counts = FollowupAudioStore::cleanupExpired();
// Count fields only: no patient identifiers, paths, or clinical bodies.
$public = [];
foreach ($counts as $key => $value) {
if (is_int($value) && preg_match('/^[a-z_]+$/D', (string) $key)) { $public[$key] = $value; }
}
$output->writeln('FOLLOWUP_AUDIO_CLEANUP ' . json_encode($public));
return (int) ($counts['errors'] ?? 0) > 0 ? 1 : 0;
} catch (\Throwable $e) {
$output->writeln('FOLLOWUP_AUDIO_CLEANUP storage_or_configuration_error');
return 1;
}
}
}