改名
This commit is contained in:
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Gii;
|
||||||
|
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Snowflake\Abstracts\Input;
|
||||||
|
use Snowflake\Exception\ConfigException;
|
||||||
|
use Snowflake\Snowflake;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Command
|
||||||
|
* @package HttpServer
|
||||||
|
*/
|
||||||
|
class Command extends \Console\Command
|
||||||
|
{
|
||||||
|
|
||||||
|
public $command = 'sw:gii';
|
||||||
|
|
||||||
|
|
||||||
|
public $description = 'server start|stop|reload|restart';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Input $dtl
|
||||||
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function onHandler(Input $dtl)
|
||||||
|
{
|
||||||
|
/** @var Gii $gii */
|
||||||
|
$gii = Snowflake::app()->get('gii');
|
||||||
|
|
||||||
|
$connections = Snowflake::app()->db->get($dtl->get('databases', 'db'));
|
||||||
|
|
||||||
|
return $gii->run($connections, $dtl);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,11 +6,12 @@
|
|||||||
* Time: 17:43
|
* Time: 17:43
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Snowflake\Gii;
|
namespace Gii;
|
||||||
|
|
||||||
use Database\Connection;
|
use Database\Connection;
|
||||||
use Database\Db;
|
use Database\Db;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Snowflake\Abstracts\Input;
|
||||||
use Snowflake\Exception\ComponentException;
|
use Snowflake\Exception\ComponentException;
|
||||||
use Snowflake\Exception\ConfigException;
|
use Snowflake\Exception\ConfigException;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
@@ -27,6 +28,9 @@ class Gii
|
|||||||
/** @var Connection */
|
/** @var Connection */
|
||||||
private $db;
|
private $db;
|
||||||
|
|
||||||
|
/** @var Input */
|
||||||
|
private $input;
|
||||||
|
|
||||||
public $modelPath = APP_PATH . '/models/';
|
public $modelPath = APP_PATH . '/models/';
|
||||||
public $modelNamespace = 'models\\';
|
public $modelNamespace = 'models\\';
|
||||||
|
|
||||||
@@ -45,34 +49,35 @@ class Gii
|
|||||||
/**
|
/**
|
||||||
* @param Connection|null $db
|
* @param Connection|null $db
|
||||||
*
|
*
|
||||||
|
* @param $input
|
||||||
* @return array
|
* @return array
|
||||||
* @throws ComponentException
|
* @throws ComponentException
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function run(Connection $db = NULL)
|
public function run($db, $input)
|
||||||
{
|
{
|
||||||
$gii = new Gii();
|
$this->input = $input;
|
||||||
if (!empty($db)) $gii->db = $db;
|
if (!empty($db)) $this->db = $db;
|
||||||
if (!$gii->db) {
|
if (!$this->db) {
|
||||||
$db = Input()->get('databases', 'db');
|
$db = $this->input->get('databases', 'db');
|
||||||
$gii->db = Snowflake::app()->db->get($db);
|
$this->db = Snowflake::app()->db->get($db);
|
||||||
}
|
}
|
||||||
$redis = Snowflake::app()->getRedis();
|
$redis = Snowflake::app()->getRedis();
|
||||||
if (!empty(Input()->get('t'))) {
|
if (!empty($input->get('t'))) {
|
||||||
$gii->tableName = Input()->get('t');
|
$this->tableName = $input->get('t');
|
||||||
$redis->del('column:' . $gii->tableName);
|
$redis->del('column:' . $this->tableName);
|
||||||
}
|
}
|
||||||
if (Input()->get('m', NULL)) {
|
if ($input->get('m', NULL)) {
|
||||||
$model = 1;
|
$model = 1;
|
||||||
}
|
}
|
||||||
if (Input()->get('c', NULL)) {
|
if ($input->get('c', NULL)) {
|
||||||
$c = 1;
|
$c = 1;
|
||||||
}
|
}
|
||||||
if (Input()->get('isUpdate') == 1) {
|
if ($input->get('isUpdate') == 1) {
|
||||||
$gii->isUpdate = TRUE;
|
$this->isUpdate = TRUE;
|
||||||
}
|
}
|
||||||
return $gii->getTable($c, $model);
|
return $this->getTable($c, $model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,7 +118,8 @@ class Gii
|
|||||||
$controller->setConnection($this->db);
|
$controller->setConnection($this->db);
|
||||||
$controller->setModelPath($this->modelPath);
|
$controller->setModelPath($this->modelPath);
|
||||||
$controller->setModelNamespace($this->modelNamespace);
|
$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->setControllerPath($this->controllerPath);
|
||||||
$controller->setControllerNamespace($this->controllerNamespace);
|
$controller->setControllerNamespace($this->controllerNamespace);
|
||||||
return $controller->generate();
|
return $controller->generate();
|
||||||
@@ -129,9 +135,10 @@ class Gii
|
|||||||
$controller = new GiiController($data['classFileName'], $data['fields']);
|
$controller = new GiiController($data['classFileName'], $data['fields']);
|
||||||
$controller->setConnection($this->db);
|
$controller->setConnection($this->db);
|
||||||
$controller->setModelPath($this->modelPath);
|
$controller->setModelPath($this->modelPath);
|
||||||
|
$controller->setInput($this->input);
|
||||||
$controller->setModelNamespace($this->modelNamespace);
|
$controller->setModelNamespace($this->modelNamespace);
|
||||||
$controller->setControllerPath($this->controllerPath);
|
$controller->setControllerPath($this->controllerPath);
|
||||||
$controller->setModule(Input()->get('module', null));
|
$controller->setModule($this->input->get('module', null));
|
||||||
$controller->setControllerNamespace($this->controllerNamespace);
|
$controller->setControllerNamespace($this->controllerNamespace);
|
||||||
return $controller->generate();
|
return $controller->generate();
|
||||||
}
|
}
|
||||||
@@ -1,20 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Snowflake\Gii;
|
namespace Gii;
|
||||||
|
|
||||||
|
|
||||||
use Database\Connection;
|
use Database\Connection;
|
||||||
|
use Snowflake\Abstracts\Input;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class GiiBase
|
* Class GiiBase
|
||||||
* @package Snowflake\Gii
|
* @package Gii
|
||||||
*/
|
*/
|
||||||
abstract class GiiBase
|
abstract class GiiBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public $fileList = [];
|
public $fileList = [];
|
||||||
|
|
||||||
|
|
||||||
|
/** @var Input */
|
||||||
|
protected $input;
|
||||||
|
|
||||||
public $modelPath = APP_PATH . '/models/';
|
public $modelPath = APP_PATH . '/models/';
|
||||||
public $modelNamespace = 'models\\';
|
public $modelNamespace = 'models\\';
|
||||||
|
|
||||||
@@ -80,6 +85,15 @@ abstract class GiiBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Input $input
|
||||||
|
*/
|
||||||
|
public function setInput(Input $input)
|
||||||
|
{
|
||||||
|
$this->input = $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \ReflectionClass $object
|
* @param \ReflectionClass $object
|
||||||
* @param $className
|
* @param $className
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Snowflake\Gii;
|
namespace Gii;
|
||||||
|
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class GiiController
|
* Class GiiController
|
||||||
* @package Snowflake\Gii
|
* @package Gii
|
||||||
*/
|
*/
|
||||||
class GiiController extends GiiBase
|
class GiiController extends GiiBase
|
||||||
{
|
{
|
||||||
@@ -100,7 +100,7 @@ class {$controllerName}Controller extends ActiveController
|
|||||||
$html .= $this->getFuncLineContent($class, $classFileName, $val->name) . "\n";
|
$html .= $this->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'];
|
$default = ['actionLoadParam', 'actionAdd', 'actionUpdate', 'actionDetail', 'actionDelete', 'actionBatchDelete', 'actionList'];
|
||||||
|
|
||||||
foreach ($default as $key => $val) {
|
foreach ($default as $key => $val) {
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Snowflake\Gii;
|
namespace Gii;
|
||||||
|
|
||||||
use Database\Db;
|
use Database\Db;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
use Swoole\Coroutine\System;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class GiiModel
|
* Class GiiModel
|
||||||
* @package Snowflake\Gii
|
* @package Gii
|
||||||
*/
|
*/
|
||||||
class GiiModel extends GiiBase
|
class GiiModel extends GiiBase
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Gii;
|
||||||
|
|
||||||
|
|
||||||
|
use Console\Console;
|
||||||
|
use Exception;
|
||||||
|
use Snowflake\Abstracts\Providers;
|
||||||
|
use Snowflake\Application;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DatabasesProviders
|
||||||
|
* @package Database
|
||||||
|
*/
|
||||||
|
class GiiProviders extends Providers
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Application $application
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function onImport(Application $application)
|
||||||
|
{
|
||||||
|
$application->set('gii', ['class' => Gii::class]);
|
||||||
|
|
||||||
|
/** @var Console $console */
|
||||||
|
$console = $application->get('console');
|
||||||
|
$console->register(Command::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,6 @@ namespace HttpServer;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Snowflake\Abstracts\Input;
|
use Snowflake\Abstracts\Input;
|
||||||
use Snowflake\Exception\ComponentException;
|
|
||||||
use Snowflake\Exception\ConfigException;
|
use Snowflake\Exception\ConfigException;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
|
|
||||||
@@ -17,7 +16,7 @@ use Snowflake\Snowflake;
|
|||||||
class Command extends \Console\Command
|
class Command extends \Console\Command
|
||||||
{
|
{
|
||||||
|
|
||||||
public $command = 'server';
|
public $command = 'sw:server';
|
||||||
|
|
||||||
|
|
||||||
public $description = 'server start|stop|reload|restart';
|
public $description = 'server start|stop|reload|restart';
|
||||||
|
|||||||
+3
-3
@@ -383,15 +383,15 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY=
|
|||||||
$model = $this->getUserModel();
|
$model = $this->getUserModel();
|
||||||
if (empty($model)) {
|
if (empty($model)) {
|
||||||
return '授权信息已过期!';
|
return '授权信息已过期!';
|
||||||
throw new AuthException('授权信息已过期!');
|
// throw new AuthException('授权信息已过期!');
|
||||||
}
|
}
|
||||||
if (!isset($model['user'])) {
|
if (!isset($model['user'])) {
|
||||||
return '授权信息错误!';
|
return '授权信息错误!';
|
||||||
throw new AuthException('授权信息错误!');
|
// throw new AuthException('授权信息错误!');
|
||||||
}
|
}
|
||||||
if (!$this->check($this->data, $model['user'])) {
|
if (!$this->check($this->data, $model['user'])) {
|
||||||
return '授权信息不合法!';
|
return '授权信息不合法!';
|
||||||
throw new AuthException('授权信息不合法!');
|
// throw new AuthException('授权信息不合法!');
|
||||||
}
|
}
|
||||||
$this->expireRefresh();
|
$this->expireRefresh();
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -33,7 +33,8 @@
|
|||||||
"HttpServer\\": "HttpServer/",
|
"HttpServer\\": "HttpServer/",
|
||||||
"validator\\": "Validator/",
|
"validator\\": "Validator/",
|
||||||
"Console\\": "./Console/",
|
"Console\\": "./Console/",
|
||||||
"Database\\": "./Database/"
|
"Database\\": "./Database/",
|
||||||
|
"Gii\\": "./Gii/"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"error.php",
|
"error.php",
|
||||||
|
|||||||
Reference in New Issue
Block a user