This commit is contained in:
2021-09-29 10:59:55 +08:00
parent 3db192ce0b
commit 1660a94941
2 changed files with 8 additions and 10 deletions
+6 -7
View File
@@ -6,12 +6,8 @@ namespace Gii;
use Exception; use Exception;
use Kiri\Abstracts\Config; use Kiri\Abstracts\Config;
use Kiri\Abstracts\Input;
use Kiri\Exception\ComponentException;
use Kiri\Exception\ConfigException; use Kiri\Exception\ConfigException;
use Kiri\Exception\NotFindClassException;
use Kiri\Kiri; use Kiri\Kiri;
use ReflectionException;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@@ -36,7 +32,7 @@ class GiiCommand extends Command
protected function configure() protected function configure()
{ {
$this->setName('sw:gii') $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'); ->setDescription('./snowflake sw:gii make=model|controller|task|interceptor|limits|middleware name=xxxx');
} }
@@ -48,7 +44,7 @@ class GiiCommand extends Command
* @throws ConfigException * @throws ConfigException
* @throws Exception * @throws Exception
*/ */
public function execute(InputInterface $input, OutputInterface $output): array public function execute(InputInterface $input, OutputInterface $output): int
{ {
/** @var Gii $gii */ /** @var Gii $gii */
$gii = Kiri::app()->get('gii'); $gii = Kiri::app()->get('gii');
@@ -62,7 +58,10 @@ class GiiCommand extends Command
foreach (Config::get('databases.connections') as $key => $connection) { foreach (Config::get('databases.connections') as $key => $connection) {
$array[$key] = $gii->run($connections->get($key), $input); $array[$key] = $gii->run($connections->get($key), $input);
} }
return $array;
$output->writeln(json_encode($array, JSON_UNESCAPED_UNICODE));
return 1;
} }
} }
+2 -3
View File
@@ -306,16 +306,15 @@ use Database\Model;
$e_x = explode(',', $key); $e_x = explode(',', $key);
$key = '\'round\' => ' . $e_x[1] . ', \'maxLength\' => ' . ((int)$e_x[0] + 1); $key = '\'round\' => ' . $e_x[1] . ', \'maxLength\' => ' . ((int)$e_x[0] + 1);
} else if (is_string($key) && str_contains($key, ',')) { } else if (is_string($key) && str_contains($key, ',')) {
$key = '\'between\' => [' . $key . ']';
} else { } else {
$key = '\'maxLength\' => ' . $key; $key = '\'maxLength\' => ' . $key;
} }
if (count($_val) == 1) { if (count($_val) == 1) {
$_tmp = ' $_tmp = '
[\'' . $_val[0][3] . '\', ' . ($_val[0][1] == 'enum' ? '\'enum\' => ' . $key : $key) . ']'; [\'' . $_val[0][3] . '\', ' . ($_val[0][1] == 'enum' ? '\'enum\' => ' . ($key) : $key) . ']';
} else { } else {
$_tmp = ' $_tmp = '
[[\'' . implode('\', \'', array_column($_val, 3)) . '\'], ' . $key . ']'; [[\'' . implode('\', \'', array_column($_val, 3)) . '\'], ' . $key . ']';
} }
$string[] = $_tmp; $string[] = $_tmp;
} }