first commit
This commit is contained in:
@@ -5,7 +5,7 @@ use think\helper\Arr;
|
||||
|
||||
class CatchAdmin
|
||||
{
|
||||
public const NAME = 'catchAdmin';
|
||||
public const NAME = 'catch';
|
||||
|
||||
/**
|
||||
*
|
||||
|
@@ -16,7 +16,7 @@ class CatchResponse
|
||||
* @param int $code
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public static function success($data = [], $msg = 'success', $code = 10000): \think\response\Json
|
||||
public static function success($data = [], $msg = 'success', $code = Code::SUCCESS): \think\response\Json
|
||||
{
|
||||
return json([
|
||||
'code' => $code,
|
||||
@@ -39,6 +39,7 @@ class CatchResponse
|
||||
'msg' => 'success',
|
||||
'count' => $list->total(),
|
||||
'current' => $list->currentPage(),
|
||||
'limit' => $list->listRows(),
|
||||
'data' => $list->getCollection(),
|
||||
]);
|
||||
}
|
||||
|
13
extend/catcher/Code.php
Normal file
13
extend/catcher/Code.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace catcher;
|
||||
|
||||
class Code
|
||||
{
|
||||
public const SUCCESS = 10000; // 成功
|
||||
public const LOST_LOGIN = 10001; // 登录失效
|
||||
public const VALIDATE_FAILED = 10002; // 验证错误
|
||||
public const PERMISSION_FORBIDDEN = 10003; // 权限禁止
|
||||
public const LOGIN_FAILED = 10004; // 登录失败
|
||||
public const FAILED = 10005; // 操作失败
|
||||
|
||||
}
|
@@ -49,7 +49,7 @@ class CompressPackageCommand extends Command
|
||||
protected function zip($package): void
|
||||
{
|
||||
if (!is_dir(CatchAdmin::directory() . $package)) {
|
||||
$package = $this->output->ask($this->input, sprintf('Can not find [%s] in catchAdmin directory, you should input package again', $package));
|
||||
$package = $this->output->ask($this->input, sprintf('Can not find [%s] in catch directory, you should input package again', $package));
|
||||
}
|
||||
|
||||
if (!is_dir(CatchAdmin::directory() . $package)) {
|
||||
|
@@ -78,7 +78,7 @@ class ModelGeneratorCommand extends Command
|
||||
{
|
||||
return <<<EOT
|
||||
<?php
|
||||
namespace catchAdmin\{Module}\model;
|
||||
namespace catch\{Module}\model;
|
||||
|
||||
use cather\base\BaseModel;
|
||||
|
||||
|
@@ -3,6 +3,7 @@ declare (strict_types = 1);
|
||||
|
||||
namespace catcher\event;
|
||||
|
||||
use catchAdmin\user\AuthTokenMiddleware;
|
||||
use catcher\CatchAdmin;
|
||||
use think\Route;
|
||||
|
||||
@@ -27,14 +28,17 @@ class LoadModuleRoutes
|
||||
foreach ($routes as $route) {
|
||||
include $route;
|
||||
}
|
||||
});
|
||||
})->middleware([AuthTokenMiddleware::class]);
|
||||
} else {
|
||||
$router->group(function () use ($router, $routes) {
|
||||
foreach ($routes as $route) {
|
||||
include $route;
|
||||
}
|
||||
});
|
||||
})->middleware([AuthTokenMiddleware::class]);
|
||||
}
|
||||
|
||||
// 单独加载登录
|
||||
include CatchAdmin::moduleDirectory('login') . 'route.php';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +49,7 @@ class LoadModuleRoutes
|
||||
protected function getRoutes(): array
|
||||
{
|
||||
$routes = CatchAdmin::getRoutes();
|
||||
array_push($routes, CatchAdmin::directory() . 'login' . DIRECTORY_SEPARATOR . 'route.php');
|
||||
|
||||
return $routes;
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,20 @@
|
||||
<?php
|
||||
namespace catcher\exceptions;
|
||||
|
||||
abstract class CatchException extends \Exception
|
||||
{}
|
||||
use Exception;
|
||||
use think\exception\HttpException;
|
||||
|
||||
abstract class CatchException extends HttpException
|
||||
{
|
||||
protected const HTTP_SUCCESS = 200;
|
||||
|
||||
public function __construct(string $message = '', int $code = 0, Exception $previous = null, array $headers = [], $statusCode = 0)
|
||||
{
|
||||
parent::__construct($statusCode, $message, $previous, $headers, $code);
|
||||
}
|
||||
|
||||
public function getStatusCode()
|
||||
{
|
||||
return self::HTTP_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
namespace catcher\exceptions;
|
||||
|
||||
use catcher\Code;
|
||||
|
||||
class FailedException extends CatchException
|
||||
{
|
||||
protected $code = 10010;
|
||||
protected $code = Code::FAILED;
|
||||
}
|
||||
|
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
namespace catcher\exceptions;
|
||||
|
||||
use catcher\Code;
|
||||
|
||||
class LoginFailedException extends CatchException
|
||||
{
|
||||
protected $code = 10010;
|
||||
protected $code = Code::LOGIN_FAILED;
|
||||
}
|
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
namespace catcher\exceptions;
|
||||
|
||||
use catcher\Code;
|
||||
|
||||
class PermissionForbiddenException extends CatchException
|
||||
{
|
||||
protected $code = 10005;
|
||||
protected $code = Code::PERMISSION_FORBIDDEN;
|
||||
|
||||
protected $message = 'permission forbidden';
|
||||
}
|
||||
|
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
namespace catcher\exceptions;
|
||||
|
||||
use catcher\Code;
|
||||
|
||||
class ValidateFailedException extends CatchException
|
||||
{
|
||||
protected $code = 10001;
|
||||
protected $code = Code::VALIDATE_FAILED;
|
||||
}
|
||||
|
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "jaguarjack/think-module",
|
||||
"description": "thinkphp module",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "jaguarjack",
|
||||
"email": "njphper@gmail.com"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"jaguarjack\\think\\module\\": "src"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"require": {}
|
||||
}
|
@@ -1,213 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Nwidart\Modules\Activators\FileActivator;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Module Namespace
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Default module namespace.
|
||||
|
|
||||
*/
|
||||
|
||||
'namespace' => 'module',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Module Stubs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Default module stubs.
|
||||
|
|
||||
*/
|
||||
|
||||
'stubs' => [
|
||||
'enabled' => false,
|
||||
'path' => base_path() . '/vendor/nwidart/laravel-modules/src/Commands/stubs',
|
||||
'files' => [
|
||||
'routes/web' => 'Routes/web.php',
|
||||
'routes/api' => 'Routes/api.php',
|
||||
'views/index' => 'Resources/views/index.blade.php',
|
||||
'views/master' => 'Resources/views/layouts/master.blade.php',
|
||||
'scaffold/config' => 'Config/config.php',
|
||||
'composer' => 'composer.json',
|
||||
'assets/js/app' => 'Resources/assets/js/app.js',
|
||||
'assets/sass/app' => 'Resources/assets/sass/app.scss',
|
||||
'webpack' => 'webpack.mix.js',
|
||||
'package' => 'package.json',
|
||||
],
|
||||
'replacements' => [
|
||||
'routes/web' => ['LOWER_NAME', 'STUDLY_NAME'],
|
||||
'routes/api' => ['LOWER_NAME'],
|
||||
'webpack' => ['LOWER_NAME'],
|
||||
'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE'],
|
||||
'views/index' => ['LOWER_NAME'],
|
||||
'views/master' => ['LOWER_NAME', 'STUDLY_NAME'],
|
||||
'scaffold/config' => ['STUDLY_NAME'],
|
||||
'composer' => [
|
||||
'LOWER_NAME',
|
||||
'STUDLY_NAME',
|
||||
'VENDOR',
|
||||
'AUTHOR_NAME',
|
||||
'AUTHOR_EMAIL',
|
||||
'MODULE_NAMESPACE',
|
||||
'PROVIDER_NAMESPACE',
|
||||
],
|
||||
],
|
||||
'gitkeep' => true,
|
||||
],
|
||||
'paths' => [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Modules path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This path used for save the generated module. This path also will be added
|
||||
| automatically to list of scanned folders.
|
||||
|
|
||||
*/
|
||||
|
||||
'module' => root_path('module'),
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Modules assets path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may update the modules assets path.
|
||||
|
|
||||
*/
|
||||
|
||||
'assets' => public_path('module'),
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| The migrations path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Where you run 'module:publish-migration' command, where do you publish the
|
||||
| the migration files?
|
||||
|
|
||||
*/
|
||||
|
||||
'migration' => root_path('database/migrations'),
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Generator path
|
||||
|--------------------------------------------------------------------------
|
||||
| Customise the paths where the folders will be generated.
|
||||
| Set the generate key to false to not generate that folder
|
||||
*/
|
||||
'generator' => [
|
||||
'config' => ['path' => 'Config', 'generate' => true],
|
||||
'command' => ['path' => 'Console', 'generate' => true],
|
||||
'migration' => ['path' => 'Database/Migrations', 'generate' => true],
|
||||
'seeder' => ['path' => 'Database/Seeders', 'generate' => true],
|
||||
'factory' => ['path' => 'Database/factories', 'generate' => true],
|
||||
'model' => ['path' => 'Entities', 'generate' => true],
|
||||
'routes' => ['path' => 'Routes', 'generate' => true],
|
||||
'controller' => ['path' => 'Http/Controllers', 'generate' => true],
|
||||
'filter' => ['path' => 'Http/Middleware', 'generate' => true],
|
||||
'request' => ['path' => 'Http/Requests', 'generate' => true],
|
||||
'provider' => ['path' => 'Providers', 'generate' => true],
|
||||
'assets' => ['path' => 'Resources/assets', 'generate' => true],
|
||||
'lang' => ['path' => 'Resources/lang', 'generate' => true],
|
||||
'views' => ['path' => 'Resources/views', 'generate' => true],
|
||||
'test' => ['path' => 'Tests/Unit', 'generate' => true],
|
||||
'test-feature' => ['path' => 'Tests/Feature', 'generate' => true],
|
||||
'repository' => ['path' => 'Repositories', 'generate' => false],
|
||||
'event' => ['path' => 'Events', 'generate' => false],
|
||||
'listener' => ['path' => 'Listeners', 'generate' => false],
|
||||
'policies' => ['path' => 'Policies', 'generate' => false],
|
||||
'rules' => ['path' => 'Rules', 'generate' => false],
|
||||
'jobs' => ['path' => 'Jobs', 'generate' => false],
|
||||
'emails' => ['path' => 'Emails', 'generate' => false],
|
||||
'notifications' => ['path' => 'Notifications', 'generate' => false],
|
||||
'resource' => ['path' => 'Transformers', 'generate' => false],
|
||||
],
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Scan Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you define which folder will be scanned. By default will scan vendor
|
||||
| directory. This is useful if you host the package in packagist website.
|
||||
|
|
||||
*/
|
||||
|
||||
'scan' => [
|
||||
'enabled' => false,
|
||||
'paths' => [
|
||||
base_path('vendor/*/*'),
|
||||
],
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Composer File Template
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is the config for composer.json file, generated by this package
|
||||
|
|
||||
*/
|
||||
|
||||
'composer' => [
|
||||
'vendor' => 'nwidart',
|
||||
'author' => [
|
||||
'name' => 'Nicolas Widart',
|
||||
'email' => 'n.widart@gmail.com',
|
||||
],
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Caching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is the config for setting up caching feature.
|
||||
|
|
||||
*/
|
||||
'cache' => [
|
||||
'enabled' => false,
|
||||
'key' => 'laravel-modules',
|
||||
'lifetime' => 60,
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Choose what laravel-modules will register as custom namespaces.
|
||||
| Setting one to false will require you to register that part
|
||||
| in your own Service Provider class.
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'register' => [
|
||||
'translations' => true,
|
||||
/**
|
||||
* load files on boot or register method
|
||||
*
|
||||
* Note: boot not compatible with asgardcms
|
||||
*
|
||||
* @example boot|register
|
||||
*/
|
||||
'files' => 'register',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Activators
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You can define new types of activators here, file, database etc. The only
|
||||
| required parameter is 'class'.
|
||||
| The file activator will store the activation status in storage/installed_modules
|
||||
*/
|
||||
'activators' => [
|
||||
'file' => [
|
||||
'class' => FileActivator::class,
|
||||
'statuses-file' => base_path('modules_statuses.json'),
|
||||
'cache-key' => 'activator.installed',
|
||||
'cache-lifetime' => 604800,
|
||||
],
|
||||
],
|
||||
|
||||
'activator' => 'file',
|
||||
];
|
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
namespace jaguarjack\think\module;
|
||||
|
||||
use jaguarjack\think\module\command\CreateModuleCommand;
|
||||
use jaguarjack\think\module\command\DiscoverModuleServiceCommand;
|
||||
use think\Service;
|
||||
|
||||
class ThinkModuleService extends Service
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
$this->commands([
|
||||
CreateModuleCommand::class,
|
||||
DiscoverModuleServiceCommand::class,
|
||||
]);
|
||||
}
|
||||
}
|
@@ -1,131 +0,0 @@
|
||||
<?php
|
||||
namespace jaguarjack\think\module\command;
|
||||
|
||||
use catcher\CatchAdmin;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Argument;
|
||||
use think\console\Output;
|
||||
|
||||
class CreateModuleCommand extends Command
|
||||
{
|
||||
protected $module;
|
||||
|
||||
protected $moduleDir;
|
||||
|
||||
protected $namespaces;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('module:create')
|
||||
->addArgument('module', Argument::REQUIRED, 'module name')
|
||||
->setDescription('create module service');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$this->module = strtolower($input->getArgument('module'));
|
||||
|
||||
$this->moduleDir = CatchAdmin::moduleDirectory($this->module);
|
||||
|
||||
$this->namespaces = CatchAdmin::NAME . '\\\\' . $this->module . '\\\\';
|
||||
|
||||
$this->createController();
|
||||
$this->createRequest();
|
||||
$this->createModel();
|
||||
// $this->createService();
|
||||
$this->createView();
|
||||
$this->createValidate();
|
||||
$this->createRoute();
|
||||
$this->moduleJson();
|
||||
|
||||
$output->warning('module created');
|
||||
}
|
||||
|
||||
|
||||
protected function createController()
|
||||
{
|
||||
mkdir($this->moduleDir . 'controller' . DIRECTORY_SEPARATOR);
|
||||
return file_put_contents($this->moduleDir . 'controller' . DIRECTORY_SEPARATOR . 'Index.php', str_replace(
|
||||
['{CLASS}', '{NAMESPACE}', '{MODULE}'],
|
||||
['Index', $this->namespaces . 'controller', $this->module],
|
||||
file_get_contents(__DIR__ . DIRECTORY_SEPARATOR .'stubs'.DIRECTORY_SEPARATOR. 'controller.stub')
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
protected function createModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function createView()
|
||||
{
|
||||
mkdir($this->moduleDir . DIRECTORY_SEPARATOR . 'view');
|
||||
|
||||
file_put_contents($this->moduleDir . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'index.html', '');
|
||||
file_put_contents($this->moduleDir . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'create.html', '');
|
||||
file_put_contents($this->moduleDir . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'edit.html', '');
|
||||
}
|
||||
|
||||
protected function createValidate()
|
||||
{
|
||||
$validatePath = $this->moduleDir . DIRECTORY_SEPARATOR . 'validate' . DIRECTORY_SEPARATOR;
|
||||
mkdir($validatePath);
|
||||
file_put_contents($validatePath . 'CreateValidate.php', str_replace(
|
||||
['{Namespace}', '{Class}'],
|
||||
[$this->namespaces . 'validate', 'Create'],
|
||||
file_get_contents(__DIR__ . 'stubs' . DIRECTORY_SEPARATOR . 'validate.stub')));
|
||||
|
||||
file_put_contents($validatePath . 'UpdateValidate.php', str_replace(
|
||||
['{Namespace}', '{Class}'],
|
||||
[$this->namespaces . 'validate', 'Update'],
|
||||
file_get_contents(__DIR__ . 'stubs' . DIRECTORY_SEPARATOR . 'validate.stub')));
|
||||
}
|
||||
|
||||
protected function createRequest()
|
||||
{
|
||||
$requestPath = $this->moduleDir . DIRECTORY_SEPARATOR . 'request' . DIRECTORY_SEPARATOR;
|
||||
mkdir($requestPath);
|
||||
file_put_contents($validatePath . 'CreateRequest.php', str_replace(
|
||||
['{Namespace}', '{Class}'],
|
||||
[$this->namespaces . 'request', 'Create'],
|
||||
file_get_contents(__DIR__ . 'stubs' . DIRECTORY_SEPARATOR . 'request.stub')));
|
||||
|
||||
file_put_contents($validatePath . 'UpdateRequest.php', str_replace(
|
||||
['{Namespace}', '{Class}'],
|
||||
[$this->namespaces . 'request', 'Update'],
|
||||
file_get_contents(__DIR__ . 'stubs' . DIRECTORY_SEPARATOR . 'request.stub')));
|
||||
}
|
||||
|
||||
protected function database()
|
||||
{
|
||||
mkdir($this->moduleDir . DIRECTORY_SEPARATOR . 'database');
|
||||
mkdir($this->moduleDir . DIRECTORY_SEPARATOR . 'database'.DIRECTORY_SEPARATOR.'migrations');
|
||||
mkdir($this->moduleDir . DIRECTORY_SEPARATOR . 'database'.DIRECTORY_SEPARATOR . 'seeds');
|
||||
}
|
||||
|
||||
protected function moduleJson()
|
||||
{
|
||||
file_put_contents($this->moduleDir.DIRECTORY_SEPARATOR .'module.json', str_replace(
|
||||
['{MODULE}', '{SERVICE}'],
|
||||
[$this->module, $this->namespaces. ucfirst($this->module) . 'Service'],
|
||||
file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'module.stub')));
|
||||
}
|
||||
|
||||
protected function createRoute()
|
||||
{
|
||||
file_put_contents($this->moduleDir.DIRECTORY_SEPARATOR .'route.php',
|
||||
file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'route.stub'));
|
||||
}
|
||||
|
||||
protected function createService()
|
||||
{
|
||||
file_put_contents($this->moduleDir.DIRECTORY_SEPARATOR . ucfirst($this->module) . 'Service.php', str_replace(
|
||||
['{CLASS}', '{NAMESPACE}'],
|
||||
[ucfirst($this->module), $this->namespaces . '\\' . $this->module],
|
||||
file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'provider.stub')));
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
namespace jaguarjack\think\module\command;
|
||||
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Argument;
|
||||
use think\console\input\Option;
|
||||
use think\console\Output;
|
||||
|
||||
class DiscoverModuleServiceCommand extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('module:service')
|
||||
->setDescription('discover module service');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$this->getModuleServices();
|
||||
|
||||
$output->writeln('module service generator succeed!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模块
|
||||
*
|
||||
* @time 2019年11月27日
|
||||
* @return bool
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
protected function getModuleServices(): bool
|
||||
{
|
||||
$modules = glob(root_path('module') .'*');
|
||||
$moduleServices = [];
|
||||
|
||||
foreach ($modules as $module) {
|
||||
if (file_exists($module . DIRECTORY_SEPARATOR . 'module.json')) {
|
||||
$moduleJson = file_get_contents($module . DIRECTORY_SEPARATOR . 'module.json');
|
||||
$moduleServices = array_merge($moduleServices, \json_decode($moduleJson, true)['services']);
|
||||
}
|
||||
}
|
||||
|
||||
$moduleServices = $this->checkModuleService($moduleServices);
|
||||
|
||||
$header = '// This file is automatically generated at:' . date('Y-m-d H:i:s') . PHP_EOL . 'declare (strict_types = 1);' . PHP_EOL;
|
||||
|
||||
$content =
|
||||
'<?php ' . PHP_EOL . $header . 'return ' .
|
||||
|
||||
var_export($moduleServices, true) . ';';
|
||||
|
||||
file_put_contents($this->app->getRootPath() . 'module/services.php', $content);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年11月29日
|
||||
* @param $moduleServices
|
||||
* @throws \ReflectionException
|
||||
* @return mixed
|
||||
*/
|
||||
protected function checkModuleService($moduleServices)
|
||||
{
|
||||
$new = [];
|
||||
|
||||
foreach ($moduleServices as $key => $service) {
|
||||
$selfReflection = new \ReflectionClass($service);
|
||||
// if service set property 'cache' && set cache => false
|
||||
// the service will not be cached
|
||||
// finally will boot it
|
||||
if ($selfReflection->hasProperty('cache') && !$selfReflection->getProperty('cache')) {
|
||||
$new[$service] = true;
|
||||
} else {
|
||||
$new[$service] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $new;
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
namespace {NAMESPACE};
|
||||
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Argument;
|
||||
use think\console\input\Option;
|
||||
use think\console\Output;
|
||||
|
||||
class {CLASS}Command extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('')
|
||||
->setDescription('');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"name": "$VENDOR$/$LOWER_NAME$",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "$AUTHOR_NAME$",
|
||||
"email": "$AUTHOR_EMAIL$"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\$PROVIDER_NAMESPACE$\\$STUDLY_NAME$ServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\": ""
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
namespace {NAMESPACE};
|
||||
|
||||
use app\BaseController;
|
||||
|
||||
class {CLASS} extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return $this->fetch('{MODULE}::index');
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return $this->fetch('{MODULE}::create');
|
||||
}
|
||||
|
||||
public function save()
|
||||
{}
|
||||
|
||||
public function read()
|
||||
{}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
return $this->fetch('{MODULE}::edit');
|
||||
}
|
||||
|
||||
public function update()
|
||||
{}
|
||||
|
||||
public function delete()
|
||||
{}
|
||||
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace {NAMESPACE};
|
||||
|
||||
class {CLASS}
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class {CLASS} extends Migrator
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace {NAMESPACE};
|
||||
|
||||
use think\Model;
|
||||
|
||||
class {CLASS} extends Model
|
||||
{
|
||||
protected $fillable = $FILLABLE$;
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"name": "",
|
||||
"alias": "{MODULE}",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"order": 0,
|
||||
"services": [
|
||||
"{SERVICE}"
|
||||
],
|
||||
"aliases": {},
|
||||
"files": [],
|
||||
"requires": []
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
namespace {NAMESPACE};
|
||||
|
||||
use think\Service;
|
||||
|
||||
class {CLASS}Service extends Service
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->loadRoutesFrom(__DIR__ . DIRECTORY_SEPARATOR . 'route.php');
|
||||
|
||||
$this->loadViewFrom();
|
||||
}
|
||||
|
||||
protected function loadViewFrom(): void
|
||||
{
|
||||
moduleViewPathManager()->set('login', __DIR__ . DIRECTORY_SEPARATOR . 'view' .DIRECTORY_SEPARATOR);
|
||||
}
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
namespace {NAMESPACE};
|
||||
|
||||
use catcher\base\BaseRequest;
|
||||
|
||||
class {CLASS}Request extends BaseRequest
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @time 2019年11月27日
|
||||
* @return string
|
||||
*/
|
||||
protected function getValidate()
|
||||
{
|
||||
// TODO: Implement getValidate() method.
|
||||
}
|
||||
}
|
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
|
||||
// you should user `$router`
|
||||
// $router->get('index', 'controller@method');
|
||||
|
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Seeder;
|
||||
|
||||
class {CLASS} extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run Method.
|
||||
*
|
||||
* Write your database seeder using this method.
|
||||
*
|
||||
* More information on writing seeders is available here:
|
||||
* http://docs.phinx.org/en/latest/seeding.html
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
namespace {Namespace};
|
||||
|
||||
use catcher\base\BaseValidate;
|
||||
|
||||
class {Class}Validate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
// todo your rules
|
||||
];
|
||||
}
|
Reference in New Issue
Block a user