qqq
This commit is contained in:
@@ -31,8 +31,8 @@ class Gii
|
|||||||
public string $modelPath = APP_PATH . 'app/Model/';
|
public string $modelPath = APP_PATH . 'app/Model/';
|
||||||
public string $modelNamespace = 'App\Model\\';
|
public string $modelNamespace = 'App\Model\\';
|
||||||
|
|
||||||
public string $controllerPath = APP_PATH . 'app/Controller/';
|
public string $controllerPath = APP_PATH . 'app/AutoController/';
|
||||||
public string $controllerNamespace = 'App\\Controller\\';
|
public string $controllerNamespace = 'App\\AutoController\\';
|
||||||
|
|
||||||
|
|
||||||
public static array $createSqls = [];
|
public static array $createSqls = [];
|
||||||
|
|||||||
+2
-2
@@ -28,8 +28,8 @@ abstract class GiiBase
|
|||||||
public string $modelPath = APP_PATH . 'app/Model/';
|
public string $modelPath = APP_PATH . 'app/Model/';
|
||||||
public string $modelNamespace = 'App\Model\\';
|
public string $modelNamespace = 'App\Model\\';
|
||||||
|
|
||||||
public string $controllerPath = APP_PATH . 'app/Controller/';
|
public string $controllerPath = APP_PATH . 'app/AutoController/';
|
||||||
public string $controllerNamespace = 'App\\Controller\\';
|
public string $controllerNamespace = 'App\\AutoController\\';
|
||||||
|
|
||||||
public ?string $module = null;
|
public ?string $module = null;
|
||||||
|
|
||||||
|
|||||||
+18
-18
@@ -49,24 +49,24 @@ class GiiController extends GiiBase
|
|||||||
$model_namespace = rtrim($modelPath['namespace'], '\\');
|
$model_namespace = rtrim($modelPath['namespace'], '\\');
|
||||||
|
|
||||||
$class = '';
|
$class = '';
|
||||||
$controller = str_replace('\\\\', '\\', "$namespace\\{$managerName}Controller");
|
$controller = str_replace('\\\\', '\\', "$namespace\\{$managerName}AutoController");
|
||||||
|
|
||||||
$html = "<?php
|
$html = "<?php
|
||||||
namespace {$namespace};
|
namespace {$namespace};
|
||||||
|
|
||||||
";
|
";
|
||||||
if (file_exists($path['path'] . '/' . $managerName . 'Controller.php')) {
|
if (file_exists($path['path'] . '/' . $managerName . 'AutoController.php')) {
|
||||||
try {
|
try {
|
||||||
$class = new \ReflectionClass($controller);
|
$class = new \ReflectionClass($controller);
|
||||||
|
|
||||||
$import = $this->getImports($path['path'] . '/' . $managerName . 'Controller.php', $class);
|
$import = $this->getImports($path['path'] . '/' . $managerName . 'AutoController.php', $class);
|
||||||
} catch (\Throwable $Exception) {
|
} catch (\Throwable $Exception) {
|
||||||
error($Exception);
|
error($Exception);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$import = "use Exception;
|
$import = "use Exception;
|
||||||
use " . (str_replace('Controller', 'Form', $namespace)) . "\\{$managerName}Form;
|
use " . (str_replace('AutoController', 'Form', $namespace)) . "\\{$managerName}Form;
|
||||||
use Kiri\Core\Str;
|
use Kiri\Core\Str;
|
||||||
use Kiri\Core\Json;
|
use Kiri\Core\Json;
|
||||||
use Kiri\Router\Base\Controller;
|
use Kiri\Router\Base\Controller;
|
||||||
@@ -92,11 +92,11 @@ use Kiri\Router\Annotate\AutoController;
|
|||||||
$html .= "
|
$html .= "
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class {$controllerName}Controller
|
* Class {$controllerName}AutoController
|
||||||
*
|
*
|
||||||
* @package controller
|
* @package controller
|
||||||
*/
|
*/
|
||||||
#[AutoController] class {$controllerName}Controller extends Controller
|
#[AutoController] class {$controllerName}AutoController extends AutoController
|
||||||
{
|
{
|
||||||
|
|
||||||
";
|
";
|
||||||
@@ -135,27 +135,27 @@ use Kiri\Router\Annotate\AutoController;
|
|||||||
$tableName = str_replace('_', '-', $tableName);
|
$tableName = str_replace('_', '-', $tableName);
|
||||||
|
|
||||||
$addRouter = 'Router::group([\'prefix\' => \'' . $tableName . '\',\'namespace\' => \'' . $namespace . '\'], function () {
|
$addRouter = 'Router::group([\'prefix\' => \'' . $tableName . '\',\'namespace\' => \'' . $namespace . '\'], function () {
|
||||||
Router::post(\'add\', \'' . $controllerName . 'Controller@actionAdd\');
|
Router::post(\'add\', \'' . $controllerName . 'AutoController@actionAdd\');
|
||||||
Router::get(\'list\', \'' . $controllerName . 'Controller@actionList\');
|
Router::get(\'list\', \'' . $controllerName . 'AutoController@actionList\');
|
||||||
Router::post(\'update\', \'' . $controllerName . 'Controller@actionUpdate\');
|
Router::post(\'update\', \'' . $controllerName . 'AutoController@actionUpdate\');
|
||||||
Router::post(\'auditing\', \'' . $controllerName . 'Controller@actionAuditing\');
|
Router::post(\'auditing\', \'' . $controllerName . 'AutoController@actionAuditing\');
|
||||||
Router::post(\'batch-auditing\', \'' . $controllerName . 'Controller@actionBatchAuditing\');
|
Router::post(\'batch-auditing\', \'' . $controllerName . 'AutoController@actionBatchAuditing\');
|
||||||
Router::post(\'batch-delete\', \'' . $controllerName . 'Controller@actionBatchDelete\');
|
Router::post(\'batch-delete\', \'' . $controllerName . 'AutoController@actionBatchDelete\');
|
||||||
Router::post(\'delete\', \'' . $controllerName . 'Controller@actionDelete\');
|
Router::post(\'delete\', \'' . $controllerName . 'AutoController@actionDelete\');
|
||||||
Router::get(\'detail\', \'' . $controllerName . 'Controller@actionDetail\');
|
Router::get(\'detail\', \'' . $controllerName . 'AutoController@actionDetail\');
|
||||||
});
|
});
|
||||||
';
|
';
|
||||||
if (!str_contains($this->clearBlank(file_get_contents($file)), $this->clearBlank($addRouter))) {
|
if (!str_contains($this->clearBlank(file_get_contents($file)), $this->clearBlank($addRouter))) {
|
||||||
file_put_contents($file, $addRouter, FILE_APPEND);
|
file_put_contents($file, $addRouter, FILE_APPEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = $path['path'] . '/' . $controllerName . 'Controller.php';
|
$file = $path['path'] . '/' . $controllerName . 'AutoController.php';
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
unlink($file);
|
unlink($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
Kiri::writeFile($file, $html);
|
Kiri::writeFile($file, $html);
|
||||||
return $controllerName . 'Controller.php';
|
return $controllerName . 'AutoController.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -589,8 +589,8 @@ use Kiri\Router\Annotate\AutoController;
|
|||||||
$this->rules[$val['Field']] = $_field;
|
$this->rules[$val['Field']] = $_field;
|
||||||
}
|
}
|
||||||
|
|
||||||
$namespace = str_replace('Controller', 'Form', $path['namespace']);
|
$namespace = str_replace('AutoController', 'Form', $path['namespace']);
|
||||||
$path = str_replace('Controller', 'Form', $path['path']);
|
$path = str_replace('AutoController', 'Form', $path['path']);
|
||||||
if (!is_dir($_SERVER['PWD'] . '/app/Form/')) {
|
if (!is_dir($_SERVER['PWD'] . '/app/Form/')) {
|
||||||
mkdir($_SERVER['PWD'] . '/app/Form/');
|
mkdir($_SERVER['PWD'] . '/app/Form/');
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -90,7 +90,7 @@ use Rpc\\' . ucfirst($name) . 'RpcInterface;
|
|||||||
|
|
||||||
|
|
||||||
#[JsonRpc(service: \'' . $name . '\', version: \'2.0\')]
|
#[JsonRpc(service: \'' . $name . '\', version: \'2.0\')]
|
||||||
class ' . ucfirst($name) . 'RpcConsumer extends Controller implements ' . ucfirst($name) . 'RpcInterface
|
class ' . ucfirst($name) . 'RpcConsumer extends AutoController implements ' . ucfirst($name) . 'RpcInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ use Kiri\Core\Json;
|
|||||||
* Class ' . $managerName . 'Consumer
|
* Class ' . $managerName . 'Consumer
|
||||||
* @package App\Client\Rpc
|
* @package App\Client\Rpc
|
||||||
*/
|
*/
|
||||||
class ' . $managerName . 'Producer extends Controller
|
class ' . $managerName . 'Producer extends AutoController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user