From 1660a94941632cd9e137f72b4c44a44fb81fc464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 29 Sep 2021 10:59:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kiri-gii/GiiCommand.php | 13 ++++++------- kiri-gii/GiiModel.php | 5 ++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/kiri-gii/GiiCommand.php b/kiri-gii/GiiCommand.php index 81cb75ad..f989ef8e 100644 --- a/kiri-gii/GiiCommand.php +++ b/kiri-gii/GiiCommand.php @@ -6,12 +6,8 @@ namespace Gii; use Exception; use Kiri\Abstracts\Config; -use Kiri\Abstracts\Input; -use Kiri\Exception\ComponentException; use Kiri\Exception\ConfigException; -use Kiri\Exception\NotFindClassException; use Kiri\Kiri; -use ReflectionException; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -36,7 +32,7 @@ class GiiCommand extends Command protected function configure() { $this->setName('sw:gii') - ->addArgument('action',InputArgument::REQUIRED) + ->addArgument('action', InputArgument::REQUIRED) ->setDescription('./snowflake sw:gii make=model|controller|task|interceptor|limits|middleware name=xxxx'); } @@ -48,7 +44,7 @@ class GiiCommand extends Command * @throws ConfigException * @throws Exception */ - public function execute(InputInterface $input, OutputInterface $output): array + public function execute(InputInterface $input, OutputInterface $output): int { /** @var Gii $gii */ $gii = Kiri::app()->get('gii'); @@ -62,7 +58,10 @@ class GiiCommand extends Command foreach (Config::get('databases.connections') as $key => $connection) { $array[$key] = $gii->run($connections->get($key), $input); } - return $array; + + $output->writeln(json_encode($array, JSON_UNESCAPED_UNICODE)); + + return 1; } } diff --git a/kiri-gii/GiiModel.php b/kiri-gii/GiiModel.php index c2338a66..4548debc 100644 --- a/kiri-gii/GiiModel.php +++ b/kiri-gii/GiiModel.php @@ -306,16 +306,15 @@ use Database\Model; $e_x = explode(',', $key); $key = '\'round\' => ' . $e_x[1] . ', \'maxLength\' => ' . ((int)$e_x[0] + 1); } else if (is_string($key) && str_contains($key, ',')) { - $key = '\'between\' => [' . $key . ']'; } else { $key = '\'maxLength\' => ' . $key; } if (count($_val) == 1) { $_tmp = ' - [\'' . $_val[0][3] . '\', ' . ($_val[0][1] == 'enum' ? '\'enum\' => ' . $key : $key) . ']'; + [\'' . $_val[0][3] . '\', ' . ($_val[0][1] == 'enum' ? '\'enum\' => ' . ($key) : $key) . ']'; } else { $_tmp = ' - [[\'' . implode('\', \'', array_column($_val, 3)) . '\'], ' . $key . ']'; + [[\'' . implode('\', \'', array_column($_val, 3)) . '\'], ' . $key . ']'; } $string[] = $_tmp; }