diff --git a/Gii/Command.php b/Gii/Command.php new file mode 100644 index 00000000..d06b5207 --- /dev/null +++ b/Gii/Command.php @@ -0,0 +1,40 @@ +get('gii'); + + $connections = Snowflake::app()->db->get($dtl->get('databases', 'db')); + + return $gii->run($connections, $dtl); + } + +} diff --git a/System/Gii/Gii.php b/Gii/Gii.php similarity index 90% rename from System/Gii/Gii.php rename to Gii/Gii.php index f61d923f..1fb68486 100644 --- a/System/Gii/Gii.php +++ b/Gii/Gii.php @@ -6,11 +6,12 @@ * Time: 17:43 */ -namespace Snowflake\Gii; +namespace Gii; use Database\Connection; use Database\Db; use Exception; +use Snowflake\Abstracts\Input; use Snowflake\Exception\ComponentException; use Snowflake\Exception\ConfigException; use Snowflake\Snowflake; @@ -27,6 +28,9 @@ class Gii /** @var Connection */ private $db; + /** @var Input */ + private $input; + public $modelPath = APP_PATH . '/models/'; public $modelNamespace = 'models\\'; @@ -45,34 +49,35 @@ class Gii /** * @param Connection|null $db * + * @param $input * @return array * @throws ComponentException * @throws ConfigException * @throws Exception */ - public static function run(Connection $db = NULL) + public function run($db, $input) { - $gii = new Gii(); - if (!empty($db)) $gii->db = $db; - if (!$gii->db) { - $db = Input()->get('databases', 'db'); - $gii->db = Snowflake::app()->db->get($db); + $this->input = $input; + if (!empty($db)) $this->db = $db; + if (!$this->db) { + $db = $this->input->get('databases', 'db'); + $this->db = Snowflake::app()->db->get($db); } $redis = Snowflake::app()->getRedis(); - if (!empty(Input()->get('t'))) { - $gii->tableName = Input()->get('t'); - $redis->del('column:' . $gii->tableName); + if (!empty($input->get('t'))) { + $this->tableName = $input->get('t'); + $redis->del('column:' . $this->tableName); } - if (Input()->get('m', NULL)) { + if ($input->get('m', NULL)) { $model = 1; } - if (Input()->get('c', NULL)) { + if ($input->get('c', NULL)) { $c = 1; } - if (Input()->get('isUpdate') == 1) { - $gii->isUpdate = TRUE; + if ($input->get('isUpdate') == 1) { + $this->isUpdate = TRUE; } - return $gii->getTable($c, $model); + return $this->getTable($c, $model); } /** @@ -113,7 +118,8 @@ class Gii $controller->setConnection($this->db); $controller->setModelPath($this->modelPath); $controller->setModelNamespace($this->modelNamespace); - $controller->setModule(Input()->get('module', null)); + $controller->setInput($this->input); + $controller->setModule($this->input->get('module', null)); $controller->setControllerPath($this->controllerPath); $controller->setControllerNamespace($this->controllerNamespace); return $controller->generate(); @@ -129,9 +135,10 @@ class Gii $controller = new GiiController($data['classFileName'], $data['fields']); $controller->setConnection($this->db); $controller->setModelPath($this->modelPath); + $controller->setInput($this->input); $controller->setModelNamespace($this->modelNamespace); $controller->setControllerPath($this->controllerPath); - $controller->setModule(Input()->get('module', null)); + $controller->setModule($this->input->get('module', null)); $controller->setControllerNamespace($this->controllerNamespace); return $controller->generate(); } diff --git a/System/Gii/GiiBase.php b/Gii/GiiBase.php similarity index 95% rename from System/Gii/GiiBase.php rename to Gii/GiiBase.php index 741573da..a01a978d 100644 --- a/System/Gii/GiiBase.php +++ b/Gii/GiiBase.php @@ -1,20 +1,25 @@ input = $input; + } + + /** * @param \ReflectionClass $object * @param $className diff --git a/System/Gii/GiiController.php b/Gii/GiiController.php similarity index 99% rename from System/Gii/GiiController.php rename to Gii/GiiController.php index 3749b9fe..fd81f2ab 100644 --- a/System/Gii/GiiController.php +++ b/Gii/GiiController.php @@ -1,13 +1,13 @@ getFuncLineContent($class, $classFileName, $val->name) . "\n"; } } - if (!Input()->get('--controller-empty', false)) { + if (!$this->input->get('--controller-empty', false)) { $default = ['actionLoadParam', 'actionAdd', 'actionUpdate', 'actionDetail', 'actionDelete', 'actionBatchDelete', 'actionList']; foreach ($default as $key => $val) { diff --git a/System/Gii/GiiModel.php b/Gii/GiiModel.php similarity index 99% rename from System/Gii/GiiModel.php rename to Gii/GiiModel.php index e5a27a20..71982879 100644 --- a/System/Gii/GiiModel.php +++ b/Gii/GiiModel.php @@ -1,15 +1,14 @@ set('gii', ['class' => Gii::class]); + + /** @var Console $console */ + $console = $application->get('console'); + $console->register(Command::class); + } +} diff --git a/HttpServer/Command.php b/HttpServer/Command.php index 4f3afb5b..3f5c073e 100644 --- a/HttpServer/Command.php +++ b/HttpServer/Command.php @@ -6,7 +6,6 @@ namespace HttpServer; use Exception; use Snowflake\Abstracts\Input; -use Snowflake\Exception\ComponentException; use Snowflake\Exception\ConfigException; use Snowflake\Snowflake; @@ -17,7 +16,7 @@ use Snowflake\Snowflake; class Command extends \Console\Command { - public $command = 'server'; + public $command = 'sw:server'; public $description = 'server start|stop|reload|restart'; diff --git a/System/Jwt/Jwt.php b/System/Jwt/Jwt.php index e6c359c4..8243dfd2 100644 --- a/System/Jwt/Jwt.php +++ b/System/Jwt/Jwt.php @@ -383,15 +383,15 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY= $model = $this->getUserModel(); if (empty($model)) { return '授权信息已过期!'; - throw new AuthException('授权信息已过期!'); +// throw new AuthException('授权信息已过期!'); } if (!isset($model['user'])) { return '授权信息错误!'; - throw new AuthException('授权信息错误!'); +// throw new AuthException('授权信息错误!'); } if (!$this->check($this->data, $model['user'])) { return '授权信息不合法!'; - throw new AuthException('授权信息不合法!'); +// throw new AuthException('授权信息不合法!'); } $this->expireRefresh(); diff --git a/composer.json b/composer.json index 444723e8..9b42afa3 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,8 @@ "HttpServer\\": "HttpServer/", "validator\\": "Validator/", "Console\\": "./Console/", - "Database\\": "./Database/" + "Database\\": "./Database/", + "Gii\\": "./Gii/" }, "files": [ "error.php",