初始化本地仓库
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\command;
|
||||
|
||||
use core\tool\ApiEncryptService;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
#[AsCommand(
|
||||
name: 'api-encrypt:generate-keypair',
|
||||
description: 'Generate API encryption RSA keypair',
|
||||
aliases: ['api-encrypt:generate-keypair'],
|
||||
hidden: false
|
||||
)]
|
||||
class ApiEncryptGenerateKeypairCommand extends BaseCommand
|
||||
{
|
||||
public function __construct(protected ApiEncryptService $service)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function __invoke(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
try {
|
||||
$keys = $this->service->generateKeyPair();
|
||||
$this->service->persistKeyPair($keys);
|
||||
$io->success('接口加密密钥对生成成功');
|
||||
return Command::SUCCESS;
|
||||
} catch (\Throwable $exception) {
|
||||
$io->error($exception->getMessage());
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user