Files
datahub/backend/app/Command/RouteSyncCommand.php
T

32 lines
750 B
PHP
Raw Normal View History

2026-03-09 14:14:42 +08:00
<?php
declare(strict_types=1);
namespace App\Command;
2026-04-02 14:41:47 +08:00
use App\Service\RouteSyncService;
2026-03-09 14:14:42 +08:00
use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as HyperfCommand;
use Psr\Container\ContainerInterface;
#[Command]
class RouteSyncCommand extends HyperfCommand
{
public function __construct(protected ContainerInterface $container)
{
parent::__construct('route:sync');
}
public function configure(): void
{
parent::configure();
$this->setDescription('同步 Hyperf 注解路由到 routes 表');
}
public function handle(): void
{
2026-04-02 14:41:47 +08:00
$result = $this->container->get(RouteSyncService::class)->sync();
$this->info("Synced {$result['synced']} routes to database.");
2026-03-09 14:14:42 +08:00
}
}