getKey();
$plan = CleanupPlan::with('contents')->find($planId);
if (!$plan) {
return $this->response()
->error('计划不存在');
}
$contents = $plan->contents;
if ($contents->isEmpty()) {
return $this->response()
->info('该计划暂无内容');
}
$html = '
';
$html .= '| 表名 | 清理类型 | 优先级 | 批处理大小 | 启用状态 | 备份 |
';
$html .= '';
$cleanupTypes = [
1 => '清空表',
2 => '删除所有',
3 => '按时间删除',
4 => '按用户删除',
5 => '按条件删除',
];
foreach ($contents as $content) {
$cleanupType = $cleanupTypes[$content->cleanup_type] ?? '未知';
$enabled = $content->is_enabled ? '启用' : '禁用';
$backup = $content->backup_enabled ? '是' : '否';
$html .= "";
$html .= "| {$content->table_name} | ";
$html .= "{$cleanupType} | ";
$html .= "{$content->priority} | ";
$html .= "" . number_format($content->batch_size) . " | ";
$html .= "{$enabled} | ";
$html .= "{$backup} | ";
$html .= "
";
}
$html .= '
';
return $this->response()
->success('计划内容')
->detail($html);
} catch (\Exception $e) {
return $this->response()
->error('查看失败:' . $e->getMessage());
}
}
/**
* 渲染按钮
*/
public function render()
{
return <<
{$this->title}
HTML;
}
}