From dbd2a36a9e57e98820ba761a9862b7037eef8892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sun, 5 Jul 2020 23:03:44 +0800 Subject: [PATCH 01/82] init --- Dockerfile | 14 +- README.md | 22 +-- app/Controller/IndexController.php | 45 +---- app/Controller/SwaggerController.php | 69 ------- app/Exception/Handler/AppExceptionHandler.php | 32 +--- app/Model/Model.php | 3 +- app/Model/User.php | 50 ------ app/swagger/error.php | 169 ------------------ app/swagger/login-definition.php | 50 ------ app/swagger/login.php | 44 ----- app/swagger/swagger.php | 31 ---- app/swagger/tag.php | 47 ----- backend/Controller/IndexController.php | 46 ----- .../Handler/BackendExceptionHandler.php | 44 ----- backend/Model/User.php | 50 ------ backend/View/index/index.blade.php | 13 -- backend/View/layouts/base.blade.php | 16 -- backend/View/layouts/main.blade.php | 0 bin/hyperf.php | 2 +- common/Controller/AbstractController.php | 58 ------ common/Controller/RestController.php | 52 ------ common/Controller/WebController.php | 133 -------------- common/Helper/ConstantHelper.php | 13 -- common/Helper/DictHelper.php | 19 -- common/Listener/ActiveRecordListener.php | 45 ----- composer.json | 75 +++----- config/autoload/annotations.php | 6 +- config/autoload/aspects.php | 3 +- config/autoload/auth.php | 71 -------- config/autoload/cache.php | 3 +- config/autoload/commands.php | 3 +- config/autoload/databases.php | 3 +- config/autoload/dependencies.php | 38 +--- config/autoload/devtool.php | 3 +- config/autoload/exceptions.php | 11 +- config/autoload/jwt.php | 21 --- config/autoload/listeners.php | 3 +- config/autoload/logger.php | 3 +- config/autoload/middlewares.php | 10 +- config/autoload/processes.php | 3 +- config/autoload/rbac.php | 39 ---- config/autoload/redis.php | 3 +- config/autoload/server.php | 27 +-- config/autoload/session.php | 22 --- config/autoload/snowflake.php | 25 --- config/autoload/swagger.php | 127 ------------- config/autoload/view.php | 23 --- config/config.php | 5 +- config/container.php | 3 +- config/routes.php | 5 +- public/.gitignore | 0 service/Demo/Demo.php | 73 -------- service/Demo/DemoImpl.php | 32 ---- service/Demo/DemoInterface.php | 22 --- test/Cases/ExampleTest.php | 3 +- test/HttpTestCase.php | 3 +- test/bootstrap.php | 3 +- 57 files changed, 77 insertions(+), 1661 deletions(-) delete mode 100644 app/Controller/SwaggerController.php delete mode 100644 app/Model/User.php delete mode 100644 app/swagger/error.php delete mode 100644 app/swagger/login-definition.php delete mode 100644 app/swagger/login.php delete mode 100644 app/swagger/swagger.php delete mode 100644 app/swagger/tag.php delete mode 100644 backend/Controller/IndexController.php delete mode 100644 backend/Exception/Handler/BackendExceptionHandler.php delete mode 100644 backend/Model/User.php delete mode 100644 backend/View/index/index.blade.php delete mode 100644 backend/View/layouts/base.blade.php delete mode 100644 backend/View/layouts/main.blade.php delete mode 100644 common/Controller/AbstractController.php delete mode 100644 common/Controller/RestController.php delete mode 100644 common/Controller/WebController.php delete mode 100755 common/Helper/ConstantHelper.php delete mode 100755 common/Helper/DictHelper.php delete mode 100644 common/Listener/ActiveRecordListener.php delete mode 100644 config/autoload/auth.php delete mode 100644 config/autoload/jwt.php delete mode 100644 config/autoload/rbac.php delete mode 100644 config/autoload/session.php delete mode 100644 config/autoload/snowflake.php delete mode 100644 config/autoload/swagger.php delete mode 100644 config/autoload/view.php delete mode 100644 public/.gitignore delete mode 100644 service/Demo/Demo.php delete mode 100644 service/Demo/DemoImpl.php delete mode 100644 service/Demo/DemoInterface.php diff --git a/Dockerfile b/Dockerfile index d104a6f..fda28e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,8 @@ # @contact group@hyperf.io # @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE -FROM hyperf/hyperf:7.2-alpine-cli -LABEL maintainer="Hyperf Developers " version="1.0" license="MIT" +FROM hyperf/hyperf:7.2-alpine-v3.9-cli +LABEL maintainer="Hyperf Developers " version="1.0" license="MIT" app.name="Hyperf" ## # ---------- env settings ---------- @@ -15,8 +15,9 @@ LABEL maintainer="Hyperf Developers " version="1.0" license="MI ARG timezone ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \ - COMPOSER_VERSION=1.9.0 \ - APP_ENV=prod + COMPOSER_VERSION=1.9.1 \ + APP_ENV=prod \ + SCAN_CACHEABLE=(true) # update RUN set -ex \ @@ -29,6 +30,7 @@ RUN set -ex \ # show php version and extensions && php -v \ && php -m \ + && php --ri swoole \ # ---------- some config ---------- && cd /etc/php7 \ # - config PHP @@ -37,7 +39,7 @@ RUN set -ex \ echo "post_max_size=108M"; \ echo "memory_limit=1024M"; \ echo "date.timezone=${TIMEZONE}"; \ - } | tee conf.d/99-overrides.ini \ + } | tee conf.d/99_overrides.ini \ # - config timezone && ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \ && echo "${TIMEZONE}" > /etc/timezone \ @@ -52,7 +54,7 @@ WORKDIR /opt/www # RUN composer install --no-dev --no-scripts COPY . /opt/www -RUN composer install --no-dev -o +RUN composer install --no-dev -o && php bin/hyperf.php EXPOSE 9501 diff --git a/README.md b/README.md index 8210a2b..d770625 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ If You Like This Please Give Me Star -基于 yii 扩展的高级hyerf框架 +基于 yii3.0 扩展 的 高级 hyperf 2.0 框架 目前还在研发中,请慎用 @@ -20,25 +20,13 @@ The preferred way to install this extension is through [composer](http://getcomp Either run ``` -git clone https://github.com/ice-leng/hyperf-advanced.git +git clone -b 2.0 https://github.com/ice-leng/hyperf-advanced.git ``` 使用扩展 -------------- - - [ ] API - - [x] [接口文档](https://github.com/ice-leng/hyperf-swagger) - - [x] [帮助类](https://github.com/ice-leng/hyperf-helper) - - [x] [token机制](https://github.com/ice-leng/hyperf-jwt) - - [x] [auth访问权限](https://github.com/ice-leng/hyperf-auth) - - [x] [Yii Db](https://github.com/ice-leng/hyperf-yii-db) - - [ ] ActiveRecode 文件生成脚手架 - - [ ] elk 接入日志分析系统 - - [ ] jaeger tracing - - [ ] Backend - - [x] [permission 权限](https://github.com/ice-leng/hyperf-yii-rbac) - - [ ] [session访问权限](https://github.com/ice-leng/hyperf-auth) - - [ ] 导航menu - - [ ] 混编模版 - +感谢 +-------------- +Yii 团队 diff --git a/app/Controller/IndexController.php b/app/Controller/IndexController.php index 9201cdd..60c3235 100644 --- a/app/Controller/IndexController.php +++ b/app/Controller/IndexController.php @@ -7,57 +7,20 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - namespace App\Controller; -use Common\Controller\RestController; -use Hyperf\HttpServer\Annotation\Controller; -use Hyperf\HttpServer\Annotation\GetMapping; -use Hyperf\HttpServer\Annotation\RequestMapping; -use Lengbin\Hyperf\Auth\AuthAnnotation; - -/** - * Class IndexController - * @package App\Controller - * @Controller() - */ -class IndexController extends RestController +class IndexController extends AbstractController { - - /** - * @RequestMapping(path="/", methods={"get", "post"}) - * @AuthAnnotation(isPublic=true) - * @return array - */ public function index() { $user = $this->request->input('user', 'Hyperf'); $method = $this->request->getMethod(); - return [ - 'method' => $method, - 'message' => "Hello {$user}.", - ]; - } - - /** - * @GetMapping(path="/test/{id:\d{1,3}}") - * @AuthAnnotation(isWhitelist=true) - */ - public function test($id) - { - return ['11' => $id]; - } - /** - * @GetMapping(path="/test2") - */ - public function test2() - { return [ - 'id' => $this->getAuth()->getId() + 'method' => $method, + 'message' => "Hello {$user}.", ]; } - } diff --git a/app/Controller/SwaggerController.php b/app/Controller/SwaggerController.php deleted file mode 100644 index 69c8b5e..0000000 --- a/app/Controller/SwaggerController.php +++ /dev/null @@ -1,69 +0,0 @@ -swagger->html(); - } - - /** - * @GetMapping(path="/swagger/api") - * @AuthAnnotation(isPublic=true, isJsonFormat=false) - */ - public function api() - { - // 扫码目录path - $path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'swagger'; - return $this->swagger->api([ - $path, - ]); - } - - /** - * @GetMapping(path="/swagger/generator") - * @AuthAnnotation(isPublic=true) - */ - public function generator() - { - return $this->swagger->generator($this->request); - } - - /** - * @RequestMapping(path="/swagger/annotation", methods={"GET", "POST"}) - * @AuthAnnotation(isPublic=true) - */ - public function annotation() - { - // 扫码目录path, 生成注释文档目录 - $path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'swagger'; - return $this->swagger->annotation($this->request, $path); - } - -} diff --git a/app/Exception/Handler/AppExceptionHandler.php b/app/Exception/Handler/AppExceptionHandler.php index f1f809c..af29dfc 100644 --- a/app/Exception/Handler/AppExceptionHandler.php +++ b/app/Exception/Handler/AppExceptionHandler.php @@ -7,16 +7,13 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - namespace App\Exception\Handler; use Hyperf\Contract\StdoutLoggerInterface; use Hyperf\ExceptionHandler\ExceptionHandler; -use Hyperf\ExceptionHandler\Formatter\FormatterInterface; use Hyperf\HttpMessage\Stream\SwooleStream; -use Nette\Utils\Json; use Psr\Http\Message\ResponseInterface; use Throwable; @@ -27,35 +24,16 @@ class AppExceptionHandler extends ExceptionHandler */ protected $logger; - protected $formatter; - - public function __construct(StdoutLoggerInterface $logger, FormatterInterface $formatter) + public function __construct(StdoutLoggerInterface $logger) { $this->logger = $logger; - $this->formatter = $formatter; } public function handle(Throwable $throwable, ResponseInterface $response) { -// $this->logger->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile())); -// $this->logger->error($throwable->getTraceAsString()); -// return $response->withStatus(500)->withBody(new SwooleStream('Internal Server Error.')); - - $this->logger->error($this->formatter->format($throwable)); - - //格式化输出 - $code = $throwable->getCode(); - $results = [ - 'code' => $code === 0 ? 500 : $code, - 'type' => get_class($throwable), - 'message' => $throwable->getMessage(), - ]; - if ($code === 0) { - $results['file'] = $throwable->getFile(); - $results['line'] = $throwable->getLine(); - } - $data = Json::encode($results); - return $response->withStatus(200)->withAddedHeader('content-type', 'application/json; charset=utf-8')->withBody(new SwooleStream($data)); + $this->logger->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile())); + $this->logger->error($throwable->getTraceAsString()); + return $response->withHeader('Server', 'Hyperf')->withStatus(500)->withBody(new SwooleStream('Internal Server Error.')); } public function isValid(Throwable $throwable): bool diff --git a/app/Model/Model.php b/app/Model/Model.php index d20bac8..57f71ba 100644 --- a/app/Model/Model.php +++ b/app/Model/Model.php @@ -7,9 +7,8 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - namespace App\Model; use Hyperf\DbConnection\Model\Model as BaseModel; diff --git a/app/Model/User.php b/app/Model/User.php deleted file mode 100644 index a23b23b..0000000 --- a/app/Model/User.php +++ /dev/null @@ -1,50 +0,0 @@ -id; - } - - public function findIdentity(string $id): ?IdentityInterface - { - return $this; - } - - /** - * @inheritDoc - */ - public function findIdentityByToken(string $token, string $type): ?IdentityInterface - { - if (!$this->jwt->verify($token)) { - throw new BusinessException(CodeHelper::TOKEN_INVALID); - } - $data = $this->jwt->getParams(); - $this->id = $data['jti']; - return $this; - } -} diff --git a/app/swagger/error.php b/app/swagger/error.php deleted file mode 100644 index d71c7b5..0000000 --- a/app/swagger/error.php +++ /dev/null @@ -1,169 +0,0 @@ -render(['name' => '我是谁']); - } - -} diff --git a/backend/Exception/Handler/BackendExceptionHandler.php b/backend/Exception/Handler/BackendExceptionHandler.php deleted file mode 100644 index 63ff83f..0000000 --- a/backend/Exception/Handler/BackendExceptionHandler.php +++ /dev/null @@ -1,44 +0,0 @@ -logger = $logger; - } - - public function handle(Throwable $throwable, ResponseInterface $response) - { - $this->logger->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile())); - $this->logger->error($throwable->getTraceAsString()); - return $response->withStatus(500)->withBody(new SwooleStream('Internal Server Error.')); - } - - public function isValid(Throwable $throwable): bool - { - return true; - } -} diff --git a/backend/Model/User.php b/backend/Model/User.php deleted file mode 100644 index ae9ec59..0000000 --- a/backend/Model/User.php +++ /dev/null @@ -1,50 +0,0 @@ -id; - } - - public function findIdentity(string $id): ?IdentityInterface - { - return $this; - } - - /** - * @inheritDoc - */ - public function findIdentityByToken(string $token, string $type): ?IdentityInterface - { - if (!$this->jwt->verify($token)) { - throw new BusinessException(CodeHelper::TOKEN_INVALID); - } - $data = $this->jwt->getParams(); - $this->id = $data['jti']; - return $this; - } -} diff --git a/backend/View/index/index.blade.php b/backend/View/index/index.blade.php deleted file mode 100644 index 2018063..0000000 --- a/backend/View/index/index.blade.php +++ /dev/null @@ -1,13 +0,0 @@ -@extends('layouts.base') - -@section('title', $name) - -@section('sidebar') - @parent -

-----this is sidebar -------

-@endsection - -@section('content') -

this is content

- {{$name}} -@endsection diff --git a/backend/View/layouts/base.blade.php b/backend/View/layouts/base.blade.php deleted file mode 100644 index 8daa518..0000000 --- a/backend/View/layouts/base.blade.php +++ /dev/null @@ -1,16 +0,0 @@ - - - - @yield('title') - - - -@section('sidebar') - this is sidebar -@show - -
- @yield('content') -
- - diff --git a/backend/View/layouts/main.blade.php b/backend/View/layouts/main.blade.php deleted file mode 100644 index e69de29..0000000 diff --git a/bin/hyperf.php b/bin/hyperf.php index d3c9b58..dedd1dc 100644 --- a/bin/hyperf.php +++ b/bin/hyperf.php @@ -5,7 +5,6 @@ ini_set('display_startup_errors', 'on'); error_reporting(E_ALL); -date_default_timezone_set('Asia/Shanghai'); ! defined('BASE_PATH') && define('BASE_PATH', dirname(__DIR__, 1)); ! defined('SWOOLE_HOOK_FLAGS') && define('SWOOLE_HOOK_FLAGS', SWOOLE_HOOK_ALL); @@ -14,6 +13,7 @@ // Self-called anonymous function that creates its own scope and keep the global namespace clean. (function () { + Hyperf\Di\ClassLoader::init(); /** @var \Psr\Container\ContainerInterface $container */ $container = require BASE_PATH . '/config/container.php'; diff --git a/common/Controller/AbstractController.php b/common/Controller/AbstractController.php deleted file mode 100644 index 0063ab4..0000000 --- a/common/Controller/AbstractController.php +++ /dev/null @@ -1,58 +0,0 @@ -request->input('page', 1)); - } -} diff --git a/common/Controller/RestController.php b/common/Controller/RestController.php deleted file mode 100644 index c9a76ee..0000000 --- a/common/Controller/RestController.php +++ /dev/null @@ -1,52 +0,0 @@ -config->get('auth.api.requestName'); - return $this->request->getAttribute($requestName); - } - - /** - * 参数无效异常 - * - * @param string|null $message - * @param int $code - */ - protected function invalidParamException(?string $message = null, $code = CodeHelper::SYS_PARAMS_ERROR) - { - throw new BusinessException($code, $message); - } - - /** - * 表单无效异常 - * - * @param ActiveRecord $activeRecord - */ - protected function invalidFormException(ActiveRecord $activeRecord) - { - $message = $activeRecord->getFirstErrors(false); - $this->invalidParamException($message); - } -} diff --git a/common/Controller/WebController.php b/common/Controller/WebController.php deleted file mode 100644 index b70bf7d..0000000 --- a/common/Controller/WebController.php +++ /dev/null @@ -1,133 +0,0 @@ -config->get('auth.web.requestName'); - return $this->request->getAttribute($requestName); - } - - /** - * set flash - * - * @param $type - * @param $message - */ - public function setFlash($type, $message) - { - // todo -// \Yii::$app->session->setFlash($type, $message); - } - - /** - * success alert - * - * @param string $message - */ - public function successAlert($message = '保存成功') - { - $this->setFlash('success', $message); - } - - /** - * - * info alert - * - * @param string $message - */ - public function infoAlert($message) - { - $this->setFlash('info', $message); - } - - /** - * warning alert - * - * @param string $message - */ - public function warningAlert($message) - { - $this->setFlash('warning', $message); - } - - /** - * error alert - * - * @param string $message - */ - public function errorAlert($message = '保存失败') - { - $this->setFlash('error', $message); - } - - /** - * get view template path by controller - * - * $template - * eg: - * null - * 'index' - * '/index' - * - * @param string|null $template - * - * @return string - */ - public function getTemplate(?string $template = null): string - { - if ($template === null || strncmp($template, '/', 1) !== 0) { - [$class, $method] = $this->request->getAttribute(Dispatched::class)->handler->callback; - $name = 'Controller'; - $path = StringHelper::substr($class, 1 + strpos($class, $name) + StringHelper::strlen($name)); - $paths = StringHelper::explode($path, "\\"); - $controllerName = array_pop($paths); - $template = implode(DIRECTORY_SEPARATOR, - array_map('strtolower', $paths)) . DIRECTORY_SEPARATOR . FormatHelper::uncamelize(StringHelper::basename($controllerName, $name), - '-') . DIRECTORY_SEPARATOR . ($template ?? $method); - } - return $template; - } - - /** - * render template - * - * eg: - * - * $this->container->get(RenderInterface::class)->render($this->getTemplate(), []); - * - * @param string|null $template - * @param array $data - * - * @return \Psr\Http\Message\ResponseInterface - */ - public function render(array $data = [], ?string $template = null) - { - $template = $this->getTemplate($template); - $render = $this->container->get(RenderInterface::class); - return $render->render($template, $data); - } - -} diff --git a/common/Helper/ConstantHelper.php b/common/Helper/ConstantHelper.php deleted file mode 100755 index cd11e2f..0000000 --- a/common/Helper/ConstantHelper.php +++ /dev/null @@ -1,13 +0,0 @@ -logger = $container->get(LoggerFactory::class)->get('db'); - } - - /** - * @inheritDoc - */ - public function listen(): array - { - return [ - Event::class - ]; - } - - /** - * @inheritDoc - */ - public function process(object $event) - { - $this->logger->info('class: ' . get_class($event) . ' eventName: ' . $event->name . ' table ' . $event->sender->tableName(), $event->sender->getAttributes()); - } -} diff --git a/composer.json b/composer.json index 4c20e11..0ff9568 100644 --- a/composer.json +++ b/composer.json @@ -13,54 +13,30 @@ "license": "Apache-2.0", "require": { "php": ">=7.2", - "ext-swoole": ">=4.4", - "hyperf/cache": "~1.1.13", - "hyperf/command": "~1.1.8", - "hyperf/config": "~1.1.7", - "hyperf/contract": "~1.1.9", - "hyperf/database": "~1.1.17", - "hyperf/db-connection": "~1.1.11", - "hyperf/devtool": "~1.1.17", - "hyperf/di": "~1.1.14", - "hyperf/dispatcher": "~1.1.3", - "hyperf/event": "~1.1.3", - "hyperf/exception-handler": "~1.1.6", - "hyperf/framework": "~1.1.16", - "hyperf/guzzle": "~1.1.10", - "hyperf/http-server": "~1.1.13", - "hyperf/logger": "~1.1.16", - "hyperf/memory": "~1.1.3", - "hyperf/paginator": "~1.1.17", - "hyperf/pool": "~1.1.17", - "hyperf/process": "~1.1.16", - "hyperf/redis": "~1.1.8", - "hyperf/utils": "~1.1.17", - "hyperf/tracer": "~1.1.16", - "hyperf/rate-limit": "^1.1.11", - "hyperf/constants": "^1.1.13", - "ext-json": "*", - "ext-pdo": "*", - "hyperf/retry": "^1.1", - "hyperf/snowflake": "^1.1", - "lengbin/hyperf-helper": "dev-master", - "lengbin/hyperf-swagger": "dev-master", - "lengbin/hyperf-jwt": "dev-master", - "lengbin/hyperf-auth": "dev-master", - "lengbin/hyperf-yii-db": "dev-master", - "lengbin/hyperf-yii-rbac": "dev-master", - "hyperf/task": "^1.1", - "hyperf/view": "^1.1", - "duncan3dc/blade": "^4.8", - "hyperf/session": "^1.1" + "ext-swoole": ">=4.5", + "hyperf/cache": "~2.0.0", + "hyperf/command": "~2.0.0", + "hyperf/config": "~2.0.0", + "hyperf/db-connection": "~2.0.0", + "hyperf/framework": "~2.0.0", + "hyperf/guzzle": "~2.0.0", + "hyperf/http-server": "~2.0.0", + "hyperf/logger": "~2.0.0", + "hyperf/memory": "~2.0.0", + "hyperf/process": "~2.0.0", + "hyperf/redis": "~2.0.0", + "hyperf/constants": "~2.0.0", + "hyperf/elasticsearch": "~2.0.0" }, "require-dev": { - "swoft/swoole-ide-helper": "^4.4.8", - "phpmd/phpmd": "^2.8.1", - "friendsofphp/php-cs-fixer": "^2.16.1", - "mockery/mockery": "^1.3.1", - "doctrine/common": "^2.12.0", - "phpstan/phpstan": "^0.11.19", - "hyperf/testing": "~1.1.4" + "swoole/ide-helper": "^4.4", + "phpmd/phpmd": "^2.6", + "friendsofphp/php-cs-fixer": "^2.14", + "mockery/mockery": "^1.0", + "doctrine/common": "^2.9", + "phpstan/phpstan": "^0.12", + "hyperf/devtool": "~2.0.0", + "hyperf/testing": "~2.0.0" }, "suggest": { "ext-openssl": "Required to use HTTPS.", @@ -71,10 +47,7 @@ }, "autoload": { "psr-4": { - "App\\": "app/", - "Common\\": "common/", - "Backend\\": "backend/", - "Service\\": "service/" + "App\\": "app/" }, "files": [] }, @@ -91,7 +64,7 @@ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-autoload-dump": [ - "init-proxy.sh" + "rm -rf runtime/container" ], "test": "co-phpunit -c phpunit.xml --colors=always", "cs-fix": "php-cs-fixer fix $1", diff --git a/config/autoload/annotations.php b/config/autoload/annotations.php index 2d59909..1e2f0b4 100644 --- a/config/autoload/annotations.php +++ b/config/autoload/annotations.php @@ -7,16 +7,12 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - return [ 'scan' => [ 'paths' => [ BASE_PATH . '/app', - BASE_PATH . '/common', - BASE_PATH . '/backend', - BASE_PATH . '/service' ], 'ignore_annotations' => [ 'mixin', diff --git a/config/autoload/aspects.php b/config/autoload/aspects.php index aee47ca..55b80d5 100644 --- a/config/autoload/aspects.php +++ b/config/autoload/aspects.php @@ -7,8 +7,7 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - return [ ]; diff --git a/config/autoload/auth.php b/config/autoload/auth.php deleted file mode 100644 index a8f3620..0000000 --- a/config/autoload/auth.php +++ /dev/null @@ -1,71 +0,0 @@ - [ - // 全局变量 名称 - 'requestName' => 'api', - // 实现类,请实现接口 \Lengbin\Auth\IdentityRepositoryInterface::class - 'identityClass' => \App\Model\User::class, - // 验证器方法,支持 - // header: \Lengbin\Auth\Method\HttpHeaderAuth::class //默认接收参数名称:X-Api-Token - // query : \Lengbin\Auth\Method\QueryParamAuth::class //默认接收参数名称:access-token - // sign : \Lengbin\Auth\Method\SignAuth::class - // 单个 - // 'method' => \Lengbin\Auth\Method\QueryParamAuth::class, - // 如果为 数组 则为 混合验证 - // key => val 接收参数名称 => 验证类 - 'method' => [ - \Lengbin\Auth\Method\HttpHeaderAuth::class, - 'token' => \Lengbin\Auth\Method\QueryParamAuth::class, - ], - //路由白名单。列如 /test/{id}, 可以使用*来通配, /test/* - 'whitelist' => [], - //公共访问,不走验证。列如 /test/{id}, 可以使用*来通赔, /test/* - 'public' => [], - ], - * ]; - */ - -return [ - 'api' => [ - // 全局变量 名称 - 'requestName' => 'api', - // 实现类,请实现接口 \Lengbin\Auth\IdentityRepositoryInterface::class - 'identityClass' => \App\Model\User::class, - // 验证器方法,支持 - // header: \Lengbin\Auth\Method\HttpHeaderAuth::class //默认接收参数名称:X-Api-Token - // query : \Lengbin\Auth\Method\QueryParamAuth::class //默认接收参数名称:access-token - // sign : \Lengbin\Auth\Method\SignAuth::class - // 单个 - // 'method' => \Lengbin\Auth\Method\QueryParamAuth::class, - // 如果为 数组 则为 混合验证 - // key => val 接收参数名称 => 验证类 - 'method' => [ - \Lengbin\Auth\Method\HttpHeaderAuth::class, - \Lengbin\Auth\Method\QueryParamAuth::class, - ], - //路由白名单。列如 /test/{id}, 可以使用*来通配, /test/* - 'whitelist' => [], - //公共访问,不走验证。列如 /test/{id}, 可以使用*来通配, /test/* - 'public' => [], - ], - 'web' => [ - // 全局变量 名称 - 'requestName' => 'web', - 'identityClass' => \Backend\Model\User::class, - // 过期时间 - 'timeout' => 8 * 60 * 60, - // 跳转页面 - 'redirect' => '/', - 'public' => [], - ], - 'sign' => [ - 'requestName' => 'auth', - 'identityClass' => \App\Model\User::class, - 'method' => \Lengbin\Auth\Method\QueryParamAuth::class, - 'whitelist' => [], - 'public' => [], - ], -]; diff --git a/config/autoload/cache.php b/config/autoload/cache.php index 375c2e9..42d7a8a 100644 --- a/config/autoload/cache.php +++ b/config/autoload/cache.php @@ -7,9 +7,8 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - return [ 'default' => [ 'driver' => Hyperf\Cache\Driver\RedisDriver::class, diff --git a/config/autoload/commands.php b/config/autoload/commands.php index aee47ca..55b80d5 100644 --- a/config/autoload/commands.php +++ b/config/autoload/commands.php @@ -7,8 +7,7 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - return [ ]; diff --git a/config/autoload/databases.php b/config/autoload/databases.php index c61e9b6..b3ef0a4 100644 --- a/config/autoload/databases.php +++ b/config/autoload/databases.php @@ -7,9 +7,8 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - return [ 'default' => [ 'driver' => env('DB_DRIVER', 'mysql'), diff --git a/config/autoload/dependencies.php b/config/autoload/dependencies.php index b67ec2c..55b80d5 100644 --- a/config/autoload/dependencies.php +++ b/config/autoload/dependencies.php @@ -1,45 +1,13 @@ Hyperf\HttpServer\Server::class, -], value(function () { - $data = []; - $rootDir = BASE_PATH . '/service'; - $paths = [$rootDir]; - $interfaceName = 'Interface'; - while (1) { - if (empty($paths)) { - break; - } - $dir = []; - foreach ($paths as $path) { - foreach (array_diff(scandir($path), ['.', '..']) as $item) { - $file = $path . DIRECTORY_SEPARATOR . $item; - if (is_dir($file)) { - $dir[] = $file; - } else { - $fileName = basename($file, '.php'); - if (\Lengbin\Helper\YiiSoft\StringHelper::matchWildcard('*' . $interfaceName, $fileName)) { - $namespace = 'Service' . substr($path, (strlen($rootDir))); - $namespace = str_replace('/', '\\', $namespace); - $data[$namespace . '\\' . $fileName] = $namespace . '\\' . str_replace($interfaceName, 'Impl', $fileName); - } - } - } - } - $paths = $dir; - } - return $data; -})); - +return [ +]; diff --git a/config/autoload/devtool.php b/config/autoload/devtool.php index 5be2655..0db04bf 100644 --- a/config/autoload/devtool.php +++ b/config/autoload/devtool.php @@ -7,9 +7,8 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - return [ 'generator' => [ 'amqp' => [ diff --git a/config/autoload/exceptions.php b/config/autoload/exceptions.php index 656ead2..895bda9 100644 --- a/config/autoload/exceptions.php +++ b/config/autoload/exceptions.php @@ -7,18 +7,13 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - return [ 'handler' => [ - 'http' => [ - \Lengbin\Hyperf\Helper\Exception\Handler\InvalidTokenExceptionHandler::class, - \Lengbin\Hyperf\Helper\Exception\Handler\BusinessExceptionHandler::class, + 'http' => [ + Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler::class, App\Exception\Handler\AppExceptionHandler::class, ], - 'backend' => [ - \Backend\Exception\Handler\BackendExceptionHandler::class, - ], ], ]; diff --git a/config/autoload/jwt.php b/config/autoload/jwt.php deleted file mode 100644 index 0843fec..0000000 --- a/config/autoload/jwt.php +++ /dev/null @@ -1,21 +0,0 @@ - 256, - //私钥,可以是字符串也可以是文件路径 - 'privateKey' => '', - //公钥,可以是字符串也可以是文件路径 - 'publicKey' => '', - //key, - 'key' => 'ice', - //发行人 - 'iss' => '', - //接受者 - 'aud' => '', - //在多少秒之前不可使用 - 'nbf' => 0, - //过期时间 - 'exp' => 7200, - // 黑名单缓存类, - 'cache' => \Hyperf\Cache\Cache::class, -]; diff --git a/config/autoload/listeners.php b/config/autoload/listeners.php index aee47ca..55b80d5 100644 --- a/config/autoload/listeners.php +++ b/config/autoload/listeners.php @@ -7,8 +7,7 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - return [ ]; diff --git a/config/autoload/logger.php b/config/autoload/logger.php index 3bf7c54..332145b 100644 --- a/config/autoload/logger.php +++ b/config/autoload/logger.php @@ -7,9 +7,8 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - return [ 'default' => [ 'handler' => [ diff --git a/config/autoload/middlewares.php b/config/autoload/middlewares.php index 559e8bf..81b1887 100644 --- a/config/autoload/middlewares.php +++ b/config/autoload/middlewares.php @@ -7,17 +7,9 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - return [ 'http' => [ - \Lengbin\Hyperf\Auth\Middleware\CorsMiddleware::class, - \Lengbin\Hyperf\Auth\Middleware\ApiMiddleware::class, - \Lengbin\Hyperf\Helper\Middleware\ServerMiddleware::class - ], - 'backend' => [ - \Hyperf\Session\Middleware\SessionMiddleware::class, - \Lengbin\Hyperf\Auth\Middleware\WebMiddleware::class, ], ]; diff --git a/config/autoload/processes.php b/config/autoload/processes.php index aee47ca..55b80d5 100644 --- a/config/autoload/processes.php +++ b/config/autoload/processes.php @@ -7,8 +7,7 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - return [ ]; diff --git a/config/autoload/rbac.php b/config/autoload/rbac.php deleted file mode 100644 index e6ec0c6..0000000 --- a/config/autoload/rbac.php +++ /dev/null @@ -1,39 +0,0 @@ - \Lengbin\YiiDb\Rbac\Manager\DbManager::class, - * 'connection' => null, // 连接db ,可以不需要 - * 'cache' => \Hyperf\Cache\Cache::class, //缓存类,可以不需要 - * 'log' => null // log key 名称 - * 'defaultRoles' => [], // 默认路由,可以不需要 - * 'item' => null, // item 表名称,可以不需要 - * 'assignment' => null, // assignment 表名称,可以不需要 - * 'rule' => null, // rule 表名称,可以不需要 - * 'itemChild' => null, // itemChild 表名称,可以不需要 - * ]; - * - * PhpManager - * return [ - * 'driver' => \Lengbin\YiiDb\Rbac\Manager\PhpManager::class, - * 'cache' => \Hyperf\Cache\Cache::class, //缓存类,可以不需要 - * 'defaultRoles' => [], // 默认路由,可以不需要 - * 'item' => null, // item 缓存名称,可以不需要 - * 'assignment' => null, // assignment 缓存名称,可以不需要 - * 'rule' => null, // rule 缓存名称,可以不需要 - * ]; - * - * PhpManagerFile - * return [ - * 'driver' => \Lengbin\YiiDb\Rbac\Manager\PhpManagerFile::class, - * 'directory' => './cache', //保存文件路径,可以不需要 - * 'defaultRoles' => [], // 默认路由,可以不需要 - * 'item' => null, // item 保存文件名称,可以不需要 - * 'assignment' => null, // assignment 保存文件名称,可以不需要 - * 'rule' => null ,// rule 保存文件名称,可以不需要 - * ]; - */ -return [ - 'driver' => \Lengbin\YiiDb\Rbac\Manager\DbManager::class, -]; diff --git a/config/autoload/redis.php b/config/autoload/redis.php index 1ddfadc..026a480 100644 --- a/config/autoload/redis.php +++ b/config/autoload/redis.php @@ -7,9 +7,8 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - return [ 'default' => [ 'host' => env('REDIS_HOST', 'localhost'), diff --git a/config/autoload/server.php b/config/autoload/server.php index cc6895f..d6211cc 100644 --- a/config/autoload/server.php +++ b/config/autoload/server.php @@ -7,9 +7,8 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - use Hyperf\Server\Server; use Hyperf\Server\SwooleEvent; @@ -26,16 +25,6 @@ SwooleEvent::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'], ], ], - [ - 'name' => 'backend', - 'type' => Server::SERVER_HTTP, - 'host' => '0.0.0.0', - 'port' => 9502, - 'sock_type' => SWOOLE_SOCK_TCP, - 'callbacks' => [ - SwooleEvent::ON_REQUEST => ['BackendServer', 'onRequest'], - ], - ], ], 'settings' => [ 'enable_coroutine' => true, @@ -46,21 +35,11 @@ 'open_http2_protocol' => true, 'max_request' => 100000, 'socket_buffer_size' => 2 * 1024 * 1024, - // 静态资源 - 'document_root' => BASE_PATH . '/public', - 'static_handler_locations' => ['/'], - 'enable_static_handler' => true, - // Task Worker 数量,根据您的服务器配置而配置适当的数量 - 'task_worker_num' => 8, - // 因为 `Task` 主要处理无法协程化的方法,所以这里推荐设为 `false`,避免协程下出现数据混淆的情况 - 'task_enable_coroutine' => false, + 'buffer_output_size' => 2 * 1024 * 1024, ], 'callbacks' => [ - SwooleEvent::ON_BEFORE_START => [Hyperf\Framework\Bootstrap\ServerStartCallback::class, 'beforeStart'], SwooleEvent::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'], SwooleEvent::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'], - // Task callbacks - SwooleEvent::ON_TASK => [Hyperf\Framework\Bootstrap\TaskCallback::class, 'onTask'], - SwooleEvent::ON_FINISH => [Hyperf\Framework\Bootstrap\FinishCallback::class, 'onFinish'], + SwooleEvent::ON_WORKER_EXIT => [Hyperf\Framework\Bootstrap\WorkerExitCallback::class, 'onWorkerExit'], ], ]; diff --git a/config/autoload/session.php b/config/autoload/session.php deleted file mode 100644 index 28dc5f2..0000000 --- a/config/autoload/session.php +++ /dev/null @@ -1,22 +0,0 @@ - Handler\FileHandler::class, - 'options' => [ - 'connection' => 'default', - 'path' => BASE_PATH . '/runtime/session', - 'gc_maxlifetime' => 1200, - ], -]; diff --git a/config/autoload/snowflake.php b/config/autoload/snowflake.php deleted file mode 100644 index 2a9ee03..0000000 --- a/config/autoload/snowflake.php +++ /dev/null @@ -1,25 +0,0 @@ - MetaGeneratorInterface::DEFAULT_BEGIN_SECOND, - RedisMilliSecondMetaGenerator::class => [ - 'pool' => 'default', - ], - RedisSecondMetaGenerator::class => [ - 'pool' => 'default', - ], -]; diff --git a/config/autoload/swagger.php b/config/autoload/swagger.php deleted file mode 100644 index b57f275..0000000 --- a/config/autoload/swagger.php +++ /dev/null @@ -1,127 +0,0 @@ - 'swagger', - // generator annotation file path - 'filePath' => BASE_PATH . '/app/swagger', - //api url - 'url' => '/swagger/api', - // swagger version , support 2, 3, default 3 - 'version' => \Lengbin\Hyperf\Swagger\Swagger::SWAGGER_VERSION_TWO, - // The OAuth Configration - 'oauthConfiguration' => [], - // generator config - 'generator' => [ - // http method , eg: get, post, delete put - 'httpMethods' => [], - // content-type, eg: "application/json", "application/x-www-form-urlencoded" - 'contentTypes' => [], - //Parameters of the position, eg: "formData", "path", "query", "header", "body" - 'parameterIns' => [], - // Parameter type, eg: "string", "number", "integer", "boolean", "file" - 'parameterTypes' => [], - // definition type, eg: "array" , "object" , "string", "number", "integer", "boolean" - 'definitionTypes' => [], - // default value - 'default' => [ - // open response template - "openResponseTemplate" => false, - /** - * response default definition template, eg: - *'responseTemplate' => [ - * 'code' => 0, - * 'message' => 'Success', - * 'data' => '{{replace}}', - *], - */ - 'responseTemplate' => [], - /** - * parameters - * [ - * [ - * "name" => "token", - * "description" => "Token", - * "in" => "header", - * "type" => "string", - * "ref" => "", - * "required" => "yes", // "yes" or "no" - * "default" => "1", - * ] - * ] - */ - 'parameters' => [], - /** - * responses - * [ - * [ - * "status" => 200, - * "description" => "success", - * "type" => "object", - * "ref" => "SuccessDefault", - * "example" => '', - * ] - * ] - */ - 'responses' => [ - [ - "status" => 200, - "description" => "success", - "type" => "object", - "ref" => "SuccessDefault", - "example" => '', - ], - [ - "status" => "default", - "description" => "请求失败, http status 强行转为200, 通过code判断", - "type" => "object", - "ref" => "ErrorDefault", - "example" => '', - ], - ], - /** - * definition select template, eg: - */ - 'definitionTemplate' => [ - 'default' => [], - 'page' => [ - [ - 'property' => 'list', - 'description' => '列表', - 'type' => 'array', - 'ref' => '', - 'example' => '', - ], - [ - 'property' => 'currentPage', - 'description' => '当前分页', - 'type' => 'integer', - 'ref' => '', - 'example' => 1, - ], - [ - 'property' => 'pageSize', - 'description' => '分页大小', - 'type' => 'integer', - 'ref' => '', - 'example' => 10, - ], - [ - 'property' => 'totalPage', - 'description' => '总分页', - 'type' => 'integer', - 'ref' => '', - 'example' => 1, - ], - [ - 'property' => 'totalCount', - 'description' => '总条数', - 'type' => 'integer', - 'ref' => '', - 'example' => 11, - ], - ], - ], - ], - ], -]; diff --git a/config/autoload/view.php b/config/autoload/view.php deleted file mode 100644 index a0c2251..0000000 --- a/config/autoload/view.php +++ /dev/null @@ -1,23 +0,0 @@ - BladeEngine::class, - 'mode' => Mode::TASK, - 'config' => [ - 'view_path' => BASE_PATH . '/backend/View/', - 'cache_path' => BASE_PATH . '/runtime/view/', - ], -]; diff --git a/config/config.php b/config/config.php index 01b6261..7d0c07e 100644 --- a/config/config.php +++ b/config/config.php @@ -7,14 +7,15 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - use Hyperf\Contract\StdoutLoggerInterface; use Psr\Log\LogLevel; return [ 'app_name' => env('APP_NAME', 'skeleton'), + 'app_env' => env('APP_ENV', 'dev'), + 'scan_cacheable' => env('SCAN_CACHEABLE', false), StdoutLoggerInterface::class => [ 'log_level' => [ LogLevel::ALERT, diff --git a/config/container.php b/config/container.php index d54d8d8..aab53b5 100644 --- a/config/container.php +++ b/config/container.php @@ -10,9 +10,8 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - use Hyperf\Di\Container; use Hyperf\Di\Definition\DefinitionSourceFactory; use Hyperf\Utils\ApplicationContext; diff --git a/config/routes.php b/config/routes.php index e8ec5f9..e89c357 100644 --- a/config/routes.php +++ b/config/routes.php @@ -7,9 +7,8 @@ * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io - * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - use Hyperf\HttpServer\Router\Router; -//Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@index'); +Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@index'); diff --git a/public/.gitignore b/public/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/service/Demo/Demo.php b/service/Demo/Demo.php deleted file mode 100644 index cb04d07..0000000 --- a/service/Demo/Demo.php +++ /dev/null @@ -1,73 +0,0 @@ - 0], - [['id', 'created_at', 'updated_at'], 'integer'], - ]; - } - - /** - * {@inheritdoc} - */ - public function attributeLabels() - { - return [ - 'id' => 'ID', - 'name' => '标题', - 'is_delete' => '是否删除', - 'created_at' => '创建时间', - 'updated_at' => '更新时间', - ]; - } - - /** - * - * @param array $params - * @param bool $isAll - * - * @return array - * @throws \Lengbin\YiiDb\Exception\Exception - * @throws \Lengbin\YiiDb\Exception\InvalidConfigException - * @throws \Lengbin\YiiDb\Exception\NotSupportedException - * @throws \Psr\SimpleCache\InvalidArgumentException - * @throws \Throwable - */ - public function getDemo(array $params = [], $isAll = false): array - { - $query = new Query(); - $query->from($this->tableName())->where([ - 'is_delete' => ConstantHelper::NOT_DELETE, - ]); - - if (ArrayHelper::isValidValue($params, 'name')) { - $query->andWhere(['like', 'name', $params['name']]); - } - - return $isAll ? $query->all() : $this->page($query); - } - -} diff --git a/service/Demo/DemoImpl.php b/service/Demo/DemoImpl.php deleted file mode 100644 index 8082cee..0000000 --- a/service/Demo/DemoImpl.php +++ /dev/null @@ -1,32 +0,0 @@ -demo->getDemo($params, $isAll); - } -} diff --git a/service/Demo/DemoInterface.php b/service/Demo/DemoInterface.php deleted file mode 100644 index eda76b4..0000000 --- a/service/Demo/DemoInterface.php +++ /dev/null @@ -1,22 +0,0 @@ - Date: Sun, 5 Jul 2020 23:06:48 +0800 Subject: [PATCH 02/82] init --- app/Constants/ErrorCode.php | 26 ++++++++++ app/Controller/AbstractController.php | 38 +++++++++++++++ app/Exception/BusinessException.php | 28 +++++++++++ app/Listener/DbQueryExecutedListener.php | 61 ++++++++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 app/Constants/ErrorCode.php create mode 100644 app/Controller/AbstractController.php create mode 100644 app/Exception/BusinessException.php create mode 100644 app/Listener/DbQueryExecutedListener.php diff --git a/app/Constants/ErrorCode.php b/app/Constants/ErrorCode.php new file mode 100644 index 0000000..0651e85 --- /dev/null +++ b/app/Constants/ErrorCode.php @@ -0,0 +1,26 @@ +logger = $container->get(LoggerFactory::class)->get('sql'); + } + + public function listen(): array + { + return [ + QueryExecuted::class, + ]; + } + + /** + * @param QueryExecuted $event + */ + public function process(object $event) + { + if ($event instanceof QueryExecuted) { + $sql = $event->sql; + if (! Arr::isAssoc($event->bindings)) { + foreach ($event->bindings as $key => $value) { + $sql = Str::replaceFirst('?', "'{$value}'", $sql); + } + } + + $this->logger->info(sprintf('[%s] %s', $event->time, $sql)); + } + } +} From fce8399291491a80ea1dd2a0db70a9da4e860052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sun, 23 Aug 2020 15:15:06 +0800 Subject: [PATCH 03/82] add hyperf-common --- app/Controller/AbstractController.php | 38 --------------------------- app/Controller/IndexController.php | 11 +++++--- composer.json | 6 ++++- config/autoload/jwt.php | 12 +++++++++ config/autoload/server.php | 2 +- 5 files changed, 25 insertions(+), 44 deletions(-) delete mode 100644 app/Controller/AbstractController.php create mode 100644 config/autoload/jwt.php diff --git a/app/Controller/AbstractController.php b/app/Controller/AbstractController.php deleted file mode 100644 index be3a537..0000000 --- a/app/Controller/AbstractController.php +++ /dev/null @@ -1,38 +0,0 @@ -request->input('user', 'Hyperf'); $method = $this->request->getMethod(); - return [ - 'method' => $method, + return $this->success([ + 'method' => $method, 'message' => "Hello {$user}.", - ]; + ]); } } diff --git a/composer.json b/composer.json index 0ff9568..fcfd9b6 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,11 @@ "hyperf/process": "~2.0.0", "hyperf/redis": "~2.0.0", "hyperf/constants": "~2.0.0", - "hyperf/elasticsearch": "~2.0.0" + "hyperf/elasticsearch": "~2.0.0", + "hyperf/snowflake": "^1.1", + "lengbin/hyperf-jwt": "dev-master", + "lengbin/hyperf-auth": "dev-master", + "lengbin/hyperf-common": "dev-master" }, "require-dev": { "swoole/ide-helper": "^4.4", diff --git a/config/autoload/jwt.php b/config/autoload/jwt.php new file mode 100644 index 0000000..0bb1412 --- /dev/null +++ b/config/autoload/jwt.php @@ -0,0 +1,12 @@ + 'HMACSHA256', + 'key' => 'ice', + // jwt 过期时间 + 'exp' => 2 * 3600, + // 刷新token 过期时间 + 'ttl' => 24 * 3600 * 30, + // 是否 单点登录 + 'sso' => true, + 'ssoKey' => 'user_id' +]; diff --git a/config/autoload/server.php b/config/autoload/server.php index d6211cc..7c4666a 100644 --- a/config/autoload/server.php +++ b/config/autoload/server.php @@ -19,7 +19,7 @@ 'name' => 'http', 'type' => Server::SERVER_HTTP, 'host' => '0.0.0.0', - 'port' => 9501, + 'port' => 9511, 'sock_type' => SWOOLE_SOCK_TCP, 'callbacks' => [ SwooleEvent::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'], From 5aed9b0e8e7a4f2fe03811f4b2ba0dc303fa18f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sun, 30 Aug 2020 01:57:49 +0800 Subject: [PATCH 04/82] add auth --- app/Controller/AuthController.php | 21 ++++++++++++ app/Controller/IndexController.php | 46 +++++++++++++++++++++++-- app/Model/Model.php | 18 ---------- app/Model/UserModel.php | 27 +++++++++++++++ config/autoload/auth.php | 54 ++++++++++++++++++++++++++++++ config/autoload/middlewares.php | 2 ++ config/routes.php | 2 +- 7 files changed, 148 insertions(+), 22 deletions(-) create mode 100644 app/Controller/AuthController.php delete mode 100644 app/Model/Model.php create mode 100644 app/Model/UserModel.php create mode 100644 config/autoload/auth.php diff --git a/app/Controller/AuthController.php b/app/Controller/AuthController.php new file mode 100644 index 0000000..9bd44e0 --- /dev/null +++ b/app/Controller/AuthController.php @@ -0,0 +1,21 @@ +container->get(ConfigInterface::class); + $requestName = $config->get('auth.api.requestName', 'api'); + return $this->request->getAttribute($requestName); + } +} diff --git a/app/Controller/IndexController.php b/app/Controller/IndexController.php index 1282998..9265fe6 100644 --- a/app/Controller/IndexController.php +++ b/app/Controller/IndexController.php @@ -12,18 +12,58 @@ namespace App\Controller; -use Lengbin\Hyperf\Common\Framework\BaseController; +use Hyperf\Di\Annotation\Inject; +use Hyperf\HttpServer\Annotation\Controller; +use Hyperf\HttpServer\Annotation\RequestMapping; +use Lengbin\Hyperf\Auth\RouterAuthAnnotation; +use Lengbin\Jwt\JwtInterface; -class IndexController extends BaseController +/** + * Class IndexController + * @package App\Controller + * @Controller() + */ +class IndexController extends AuthController { + + /** + * @Inject() + * @var JwtInterface + */ + public $jwt; + + /** + * @RequestMapping(path="/", methods={"get"}) + * + * @return mixed + */ public function index() { $user = $this->request->input('user', 'Hyperf'); $method = $this->request->getMethod(); - + $token = $this->jwt->generate(['user_id' => 1, 'a' => 1]); return $this->success([ 'method' => $method, 'message' => "Hello {$user}.", + 'token' => $token, ]); } + + /** + * @RequestMapping(path="/user", methods={"get"}) + */ + public function user() + { + return $this->success($this->getAuth()->getId()); + } + + /** + * @RequestMapping(path="/test", methods={"get"}) + * @RouterAuthAnnotation(isWhitelist=true) + */ + public function test() + { + return $this->success([]); + } + } diff --git a/app/Model/Model.php b/app/Model/Model.php deleted file mode 100644 index 57f71ba..0000000 --- a/app/Model/Model.php +++ /dev/null @@ -1,18 +0,0 @@ - [ + // 全局变量 名称 + 'requestName' => 'api', + // 实现类,请实现接口 \Lengbin\Auth\IdentityRepositoryInterface::class + 'identityClass' => \App\Model\User::class, + // 验证器方法,支持 + // header: \Lengbin\Auth\Method\HttpHeaderAuth::class //默认接收参数名称:X-Api-Token + // query : \Lengbin\Auth\Method\QueryParamAuth::class //默认接收参数名称:access-token + // sign : \Lengbin\Auth\Method\SignAuth::class + // 单个 + // 'method' => \Lengbin\Auth\Method\QueryParamAuth::class, + // 如果为 数组 则为 混合验证 + // key => val 接收参数名称 => 验证类 + 'method' => [ + \Lengbin\Auth\Method\HttpHeaderAuth::class, + 'token' => \Lengbin\Auth\Method\QueryParamAuth::class, + ], + //路由白名单。列如 /test/{id}, 可以使用*来通配, /test/* + 'whitelist' => [], + //公共访问,不走验证。列如 /test/{id}, 可以使用*来通赔, /test/* + 'public' => [], + ], + * ]; + */ + +return [ + 'api' => [ + // 全局变量 名称 + 'requestName' => 'api', + // 实现类,请实现接口 \Lengbin\Auth\IdentityRepositoryInterface::class + 'identityClass' => \App\Model\UserModel::class, + // 验证器方法,支持 + // header: \Lengbin\Auth\Method\HttpHeaderAuth::class //默认接收参数名称:X-Api-Token + // query : \Lengbin\Auth\Method\QueryParamAuth::class //默认接收参数名称:access-token + // sign : \Lengbin\Auth\Method\SignAuth::class + // 单个 + // 'method' => \Lengbin\Auth\Method\QueryParamAuth::class, + // 如果为 数组 则为 混合验证 + // key => val 接收参数名称 => 验证类 + 'method' => [ + \Lengbin\Auth\Method\HttpHeaderAuth::class, + \Lengbin\Auth\Method\QueryParamAuth::class, + ], + //路由白名单。列如 /test/{id}, 可以使用*来通配, /test/* + 'whitelist' => [], + //公共访问,不走验证。列如 /test/{id}, 可以使用*来通配, /test/* + 'public' => [], + ], +]; diff --git a/config/autoload/middlewares.php b/config/autoload/middlewares.php index 81b1887..9787a5a 100644 --- a/config/autoload/middlewares.php +++ b/config/autoload/middlewares.php @@ -11,5 +11,7 @@ */ return [ 'http' => [ + \Lengbin\Hyperf\Common\Middleware\CorsMiddleware::class, + \Lengbin\Hyperf\Auth\Middleware\ApiMiddleware::class, ], ]; diff --git a/config/routes.php b/config/routes.php index e89c357..f3ec5ce 100644 --- a/config/routes.php +++ b/config/routes.php @@ -11,4 +11,4 @@ */ use Hyperf\HttpServer\Router\Router; -Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@index'); +//Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@index'); From 9f288220b81a5ca00c54043e37ec222a543f66b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sat, 5 Sep 2020 00:16:42 +0800 Subject: [PATCH 05/82] add exception handle --- app/Controller/IndexController.php | 19 +++----- app/Exception/BusinessException.php | 28 ------------ app/Exception/Handler/AppExceptionHandler.php | 43 ------------------- .../Handler/TokenExceptionHandler.php | 30 +++++++++++++ config/autoload/exceptions.php | 10 ++++- server.sh | 11 +++++ 6 files changed, 56 insertions(+), 85 deletions(-) delete mode 100644 app/Exception/BusinessException.php delete mode 100644 app/Exception/Handler/AppExceptionHandler.php create mode 100644 app/Exception/Handler/TokenExceptionHandler.php create mode 100644 server.sh diff --git a/app/Controller/IndexController.php b/app/Controller/IndexController.php index 9265fe6..ed0e692 100644 --- a/app/Controller/IndexController.php +++ b/app/Controller/IndexController.php @@ -12,11 +12,9 @@ namespace App\Controller; -use Hyperf\Di\Annotation\Inject; use Hyperf\HttpServer\Annotation\Controller; use Hyperf\HttpServer\Annotation\RequestMapping; use Lengbin\Hyperf\Auth\RouterAuthAnnotation; -use Lengbin\Jwt\JwtInterface; /** * Class IndexController @@ -26,14 +24,9 @@ class IndexController extends AuthController { - /** - * @Inject() - * @var JwtInterface - */ - public $jwt; - /** * @RequestMapping(path="/", methods={"get"}) + * @RouterAuthAnnotation(isPublic=true) * * @return mixed */ @@ -41,11 +34,9 @@ public function index() { $user = $this->request->input('user', 'Hyperf'); $method = $this->request->getMethod(); - $token = $this->jwt->generate(['user_id' => 1, 'a' => 1]); return $this->success([ 'method' => $method, 'message' => "Hello {$user}.", - 'token' => $token, ]); } @@ -54,7 +45,9 @@ public function index() */ public function user() { - return $this->success($this->getAuth()->getId()); + return $this->success([ + 'abc' => $this->getAuth()->getId(), + ]); } /** @@ -63,7 +56,9 @@ public function user() */ public function test() { - return $this->success([]); + return $this->success([ + 'abc' => $this->getAuth()->getId(), + ]); } } diff --git a/app/Exception/BusinessException.php b/app/Exception/BusinessException.php deleted file mode 100644 index 7380502..0000000 --- a/app/Exception/BusinessException.php +++ /dev/null @@ -1,28 +0,0 @@ -logger = $logger; - } - - public function handle(Throwable $throwable, ResponseInterface $response) - { - $this->logger->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile())); - $this->logger->error($throwable->getTraceAsString()); - return $response->withHeader('Server', 'Hyperf')->withStatus(500)->withBody(new SwooleStream('Internal Server Error.')); - } - - public function isValid(Throwable $throwable): bool - { - return true; - } -} diff --git a/app/Exception/Handler/TokenExceptionHandler.php b/app/Exception/Handler/TokenExceptionHandler.php new file mode 100644 index 0000000..34f57a3 --- /dev/null +++ b/app/Exception/Handler/TokenExceptionHandler.php @@ -0,0 +1,30 @@ +stopPropagation(); + $this->formatLog($throwable); + $code = $throwable instanceof ExpiredJwtException ? CommentErrorCode::TOKEN_EXPIRED : CommentErrorCode::INVALID_TOKEN; + return $this->response->fail($code); + } + + public function isValid(Throwable $throwable): bool + { + return $throwable instanceof InvalidTokenException || $throwable instanceof InvalidJwtException || $throwable instanceof ExpiredJwtException; + } +} diff --git a/config/autoload/exceptions.php b/config/autoload/exceptions.php index 895bda9..2ef7aa4 100644 --- a/config/autoload/exceptions.php +++ b/config/autoload/exceptions.php @@ -9,11 +9,17 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + +use App\Exception\Handler\TokenExceptionHandler; +use Lengbin\Hyperf\Common\Exception\Handler\AppExceptionHandler; +use Lengbin\Hyperf\Common\Exception\Handler\BusinessExceptionHandler; + return [ 'handler' => [ 'http' => [ - Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler::class, - App\Exception\Handler\AppExceptionHandler::class, + TokenExceptionHandler::class, + BusinessExceptionHandler::class, + AppExceptionHandler::class, ], ], ]; diff --git a/server.sh b/server.sh new file mode 100644 index 0000000..f07d7d9 --- /dev/null +++ b/server.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +pidFile="runtime/hyperf.pid" + +if [ -f "$pidFile" ]; then + kill -15 `cat $pidFile` +fi + +rm -rf runtime/container +php bin/hyperf.php start + From a564966725872ad5ea108b13022a7eb1d4c2d32d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Mon, 21 Sep 2020 17:27:15 +0800 Subject: [PATCH 06/82] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20favicon.ico=20not=20?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/autoload/auth.php | 4 +++- config/routes.php | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config/autoload/auth.php b/config/autoload/auth.php index 457cf87..e7d3f76 100644 --- a/config/autoload/auth.php +++ b/config/autoload/auth.php @@ -49,6 +49,8 @@ //路由白名单。列如 /test/{id}, 可以使用*来通配, /test/* 'whitelist' => [], //公共访问,不走验证。列如 /test/{id}, 可以使用*来通配, /test/* - 'public' => [], + 'public' => [ + '/favicon.ico' + ], ], ]; diff --git a/config/routes.php b/config/routes.php index f3ec5ce..4efb174 100644 --- a/config/routes.php +++ b/config/routes.php @@ -12,3 +12,7 @@ use Hyperf\HttpServer\Router\Router; //Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@index'); + +Router::get('/favicon.ico', function () { + return ''; +}); From 6f770a176bba7162d2fef4846f4f0aec6f7400a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Mon, 5 Oct 2020 23:56:06 +0800 Subject: [PATCH 07/82] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=A0=81=20=E7=B1=BB=20=E6=B7=BB=E5=8A=A0=20=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=A0=81=20=E5=90=88=E5=B9=B6=E7=B1=BB=E7=94=9F=E6=88=90?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constants/{ => Errors}/ErrorCode.php | 10 +++------- composer.json | 4 ++-- config/autoload/errorCode.php | 15 +++++++++++++++ server.sh | 1 + 4 files changed, 21 insertions(+), 9 deletions(-) rename app/Constants/{ => Errors}/ErrorCode.php (65%) create mode 100644 config/autoload/errorCode.php diff --git a/app/Constants/ErrorCode.php b/app/Constants/Errors/ErrorCode.php similarity index 65% rename from app/Constants/ErrorCode.php rename to app/Constants/Errors/ErrorCode.php index 0651e85..7507b11 100644 --- a/app/Constants/ErrorCode.php +++ b/app/Constants/Errors/ErrorCode.php @@ -9,15 +9,11 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ -namespace App\Constants; +namespace App\Constants\Errors; -use Hyperf\Constants\AbstractConstants; -use Hyperf\Constants\Annotation\Constants; +use Lengbin\ErrorCode\BaseEnum; -/** - * @Constants - */ -class ErrorCode extends AbstractConstants +class ErrorCode extends BaseEnum { /** * @Message("Server Error!") diff --git a/composer.json b/composer.json index fcfd9b6..aa2d7aa 100644 --- a/composer.json +++ b/composer.json @@ -25,12 +25,12 @@ "hyperf/memory": "~2.0.0", "hyperf/process": "~2.0.0", "hyperf/redis": "~2.0.0", - "hyperf/constants": "~2.0.0", "hyperf/elasticsearch": "~2.0.0", "hyperf/snowflake": "^1.1", "lengbin/hyperf-jwt": "dev-master", "lengbin/hyperf-auth": "dev-master", - "lengbin/hyperf-common": "dev-master" + "lengbin/hyperf-common": "dev-master", + "lengbin/hyperf-error-code": "dev-main" }, "require-dev": { "swoole/ide-helper": "^4.4", diff --git a/config/autoload/errorCode.php b/config/autoload/errorCode.php new file mode 100644 index 0000000..d81a1bc --- /dev/null +++ b/config/autoload/errorCode.php @@ -0,0 +1,15 @@ + [ + BASE_PATH . '/vendor/lengbin/hyperf-common/src/Error', + BASE_PATH . '/app/Constants/Errors' + ], + // 合并生成 类 文件名称 + 'classname' => 'Error', + // 合并生成 类 命名空间 + 'classNamespace' => 'App\\Constants', + // 合并生成 类 文件输出目录 + 'output' => BASE_PATH . '/app/Constants', +]; diff --git a/server.sh b/server.sh index f07d7d9..7066213 100644 --- a/server.sh +++ b/server.sh @@ -9,3 +9,4 @@ fi rm -rf runtime/container php bin/hyperf.php start +php bin/hyperf.php gen:error-code From e0911c6b6faeb3ababdf7dff65c8feb2cc22d280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Mon, 5 Oct 2020 23:57:39 +0800 Subject: [PATCH 08/82] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20sh=20=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/server.sh b/server.sh index 7066213..5729460 100644 --- a/server.sh +++ b/server.sh @@ -2,11 +2,6 @@ pidFile="runtime/hyperf.pid" -if [ -f "$pidFile" ]; then - kill -15 `cat $pidFile` -fi - -rm -rf runtime/container -php bin/hyperf.php start - php bin/hyperf.php gen:error-code + +#php bin/hyperf.php start From f0cdecf537aa0783d3bbcaf31b78c78b5dafe022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Tue, 6 Oct 2020 00:22:47 +0800 Subject: [PATCH 09/82] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20sh=20=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server.sh b/server.sh index 5729460..c92579c 100644 --- a/server.sh +++ b/server.sh @@ -1,6 +1,12 @@ #!/bin/sh -pidFile="runtime/hyperf.pid" +#pidFile="runtime/hyperf.pid" +# +#if [ -f "$pidFile" ]; then +# kill -15 `cat $pidFile` +#fi +# +#rm -rf runtime/container php bin/hyperf.php gen:error-code From d3b9191c536b60467aee50cd20a5177d4dbebd76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Thu, 22 Oct 2020 17:22:24 +0800 Subject: [PATCH 10/82] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E5=9F=BA=E7=A1=80da?= =?UTF-8?q?tabase=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/{Constants => Constant}/Errors/ErrorCode.php | 2 +- config/autoload/databases.php | 3 ++- config/autoload/errorCode.php | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) rename app/{Constants => Constant}/Errors/ErrorCode.php (92%) diff --git a/app/Constants/Errors/ErrorCode.php b/app/Constant/Errors/ErrorCode.php similarity index 92% rename from app/Constants/Errors/ErrorCode.php rename to app/Constant/Errors/ErrorCode.php index 7507b11..87705c6 100644 --- a/app/Constants/Errors/ErrorCode.php +++ b/app/Constant/Errors/ErrorCode.php @@ -9,7 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ -namespace App\Constants\Errors; +namespace App\Constant\Errors; use Lengbin\ErrorCode\BaseEnum; diff --git a/config/autoload/databases.php b/config/autoload/databases.php index b3ef0a4..40a71a5 100644 --- a/config/autoload/databases.php +++ b/config/autoload/databases.php @@ -32,7 +32,8 @@ 'gen:model' => [ 'path' => 'app/Model', 'force_casts' => true, - 'inheritance' => 'Model', + 'inheritance' => 'BaseModel', + 'uses' => 'Lengbin\Hyperf\Common\Framework\BaseModel', ], ], ], diff --git a/config/autoload/errorCode.php b/config/autoload/errorCode.php index d81a1bc..43e69a2 100644 --- a/config/autoload/errorCode.php +++ b/config/autoload/errorCode.php @@ -4,12 +4,12 @@ // 错误码文件 目录 'path' => [ BASE_PATH . '/vendor/lengbin/hyperf-common/src/Error', - BASE_PATH . '/app/Constants/Errors' + BASE_PATH . '/app/Constant/Errors' ], // 合并生成 类 文件名称 'classname' => 'Error', // 合并生成 类 命名空间 - 'classNamespace' => 'App\\Constants', + 'classNamespace' => 'App\\Constant', // 合并生成 类 文件输出目录 - 'output' => BASE_PATH . '/app/Constants', + 'output' => BASE_PATH . '/app/Constant', ]; From 91bf1d8a6d15b9bbd53b45994f01d6cff51437f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Fri, 23 Oct 2020 01:01:38 +0800 Subject: [PATCH 11/82] fix bug --- app/Constant/Errors/ErrorCode.php | 2 +- config/config.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Constant/Errors/ErrorCode.php b/app/Constant/Errors/ErrorCode.php index 87705c6..e865a76 100644 --- a/app/Constant/Errors/ErrorCode.php +++ b/app/Constant/Errors/ErrorCode.php @@ -11,7 +11,7 @@ */ namespace App\Constant\Errors; -use Lengbin\ErrorCode\BaseEnum; +use Lengbin\Hyperf\ErrorCode\BaseEnum; class ErrorCode extends BaseEnum { diff --git a/config/config.php b/config/config.php index 7d0c07e..1a900f2 100644 --- a/config/config.php +++ b/config/config.php @@ -16,6 +16,7 @@ 'app_name' => env('APP_NAME', 'skeleton'), 'app_env' => env('APP_ENV', 'dev'), 'scan_cacheable' => env('SCAN_CACHEABLE', false), + 'image_url' => env('IMAGE_URL', ''), StdoutLoggerInterface::class => [ 'log_level' => [ LogLevel::ALERT, From 6db041b2846982df1e5238a917be813cfe9ee574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sun, 25 Oct 2020 22:14:31 +0800 Subject: [PATCH 12/82] README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d770625..a8e672f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ If You Like This Please Give Me Star -基于 yii3.0 扩展 的 高级 hyperf 2.0 框架 +基于 hyperf 2.0 框架 目前还在研发中,请慎用 @@ -24,8 +24,9 @@ git clone -b 2.0 https://github.com/ice-leng/hyperf-advanced.git ``` 使用扩展 -------------- - - +- [jwt](https://github.com/ice-leng/hyperf-jwt) +- [授权验证](https://github.com/ice-leng/hyperf-auth) +- [枚举,错误码合并生成](https://github.com/ice-leng/hyperf-error-code) 感谢 -------------- From c27a1db609063b3de3280c9ef46ea86e642b0365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sat, 31 Oct 2020 01:19:54 +0800 Subject: [PATCH 13/82] fix bug --- README.md | 7 +++-- .../Handler/TokenExceptionHandler.php | 30 ------------------- config/autoload/errorCode.php | 13 ++++---- config/autoload/exceptions.php | 4 +-- 4 files changed, 15 insertions(+), 39 deletions(-) delete mode 100644 app/Exception/Handler/TokenExceptionHandler.php diff --git a/README.md b/README.md index a8e672f..6689b83 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ If You Like This Please Give Me Star -基于 hyperf 2.0 框架 +基于 Hyperf 2.0 && YII3.0 框架 目前还在研发中,请慎用 @@ -25,9 +25,12 @@ git clone -b 2.0 https://github.com/ice-leng/hyperf-advanced.git 使用扩展 -------------- - [jwt](https://github.com/ice-leng/hyperf-jwt) -- [授权验证](https://github.com/ice-leng/hyperf-auth) +- [授权验证-yii](https://github.com/ice-leng/hyperf-auth) - [枚举,错误码合并生成](https://github.com/ice-leng/hyperf-error-code) +- [swagger](https://github.com/daodao97/apidog) 感谢 -------------- Yii 团队 + +Hyperf 团队 diff --git a/app/Exception/Handler/TokenExceptionHandler.php b/app/Exception/Handler/TokenExceptionHandler.php deleted file mode 100644 index 34f57a3..0000000 --- a/app/Exception/Handler/TokenExceptionHandler.php +++ /dev/null @@ -1,30 +0,0 @@ -stopPropagation(); - $this->formatLog($throwable); - $code = $throwable instanceof ExpiredJwtException ? CommentErrorCode::TOKEN_EXPIRED : CommentErrorCode::INVALID_TOKEN; - return $this->response->fail($code); - } - - public function isValid(Throwable $throwable): bool - { - return $throwable instanceof InvalidTokenException || $throwable instanceof InvalidJwtException || $throwable instanceof ExpiredJwtException; - } -} diff --git a/config/autoload/errorCode.php b/config/autoload/errorCode.php index 43e69a2..e4708e6 100644 --- a/config/autoload/errorCode.php +++ b/config/autoload/errorCode.php @@ -2,14 +2,17 @@ return [ // 错误码文件 目录 - 'path' => [ + 'path' => [ BASE_PATH . '/vendor/lengbin/hyperf-common/src/Error', - BASE_PATH . '/app/Constant/Errors' + BASE_PATH . '/app/Constant/Errors', ], // 合并生成 类 文件名称 - 'classname' => 'Error', + 'classname' => 'Error', // 合并生成 类 命名空间 - 'classNamespace' => 'App\\Constant', + 'classNamespace' => 'App\\Constant', // 合并生成 类 文件输出目录 - 'output' => BASE_PATH . '/app/Constant', + 'output' => BASE_PATH . '/app/Constant', + // 多语言 文件名称 + 'translate_enable' => false, + 'translate' => 'errorCode', ]; diff --git a/config/autoload/exceptions.php b/config/autoload/exceptions.php index 2ef7aa4..b786b1d 100644 --- a/config/autoload/exceptions.php +++ b/config/autoload/exceptions.php @@ -10,14 +10,14 @@ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ -use App\Exception\Handler\TokenExceptionHandler; use Lengbin\Hyperf\Common\Exception\Handler\AppExceptionHandler; use Lengbin\Hyperf\Common\Exception\Handler\BusinessExceptionHandler; +use Lengbin\Hyperf\Exception\Handler\AuthTokenExceptionHandler; return [ 'handler' => [ 'http' => [ - TokenExceptionHandler::class, + AuthTokenExceptionHandler::class, BusinessExceptionHandler::class, AppExceptionHandler::class, ], From ff2bce8a2352210b4a546295bb1107d164b5a4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Tue, 10 Nov 2020 21:19:59 +0800 Subject: [PATCH 14/82] add apidog and fix apidog bug --- .gitignore | 3 +- app/Controller/V1/DemoController.php | 164 ++++++++++++++++ .../Handler/ApiDogExceptionHandler.php | 27 +++ composer.json | 4 +- config/autoload/apidog.php | 50 +++++ config/autoload/exceptions.php | 4 +- config/autoload/middlewares.php | 10 +- config/autoload/translation.php | 16 ++ storage/languages/en/validation.php | 177 ++++++++++++++++++ storage/languages/zh_CN/validation.php | 177 ++++++++++++++++++ 10 files changed, 626 insertions(+), 6 deletions(-) create mode 100644 app/Controller/V1/DemoController.php create mode 100644 app/Exception/Handler/ApiDogExceptionHandler.php create mode 100644 config/autoload/apidog.php create mode 100644 config/autoload/translation.php create mode 100644 storage/languages/en/validation.php create mode 100644 storage/languages/zh_CN/validation.php diff --git a/.gitignore b/.gitignore index c867e8f..25154e8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ vendor/ .env .DS_Store *.lock -.phpunit* \ No newline at end of file +.phpunit* +public diff --git a/app/Controller/V1/DemoController.php b/app/Controller/V1/DemoController.php new file mode 100644 index 0000000..3ee3237 --- /dev/null +++ b/app/Controller/V1/DemoController.php @@ -0,0 +1,164 @@ + 0, + 'id' => 1, + 'params' => $this->request->post(), + ]; + } + + // 自定义的校验方法 rule 中 cb_*** 方式调用 + public function checkName($attribute, $value) + { + if ($value === 'a') { + return "拒绝添加 " . $value; + } + + return true; + } + + /** + * 请注意 body 类型 rules 为数组类型 + * @DeleteApi(path="/demo", description="删除用户") + * @Body(rules={ + * "id|用户id":"required|integer|max:10", + * "deepAssoc|深层关联":{ + * "name_1|名称": "required|integer|max:20" + * }, + * "deepUassoc|深层索引":{{ + * "name_2|名称": "required|integer|max:20" + * }}, + * "a.b.c.*.e|aa":"required|integer|max:10", + * }) + * @ApiResponse(code="-1", description="参数错误") + * @ApiResponse(code="0", description="删除成功", schema={"id":1}) + */ + public function delete() + { + $body = $this->request->getBody()->getContents(); + return [ + 'code' => 0, + 'query' => $this->request->getQueryParams(), + 'body' => json_decode($body, true), + ]; + } + + /** + * @GetApi(path="/demo", description="获取用户详情") + * @Query(key="id", rule="required|integer|max:0") + * @ApiResponse(code="-1", description="参数错误") + * @ApiResponse(code="0", schema={"id":1,"name":"张三","age":1}, template="success") + */ + public function get() + { + return [ + 'code' => 0, + 'id' => 1, + 'name' => '张三', + 'age' => 1, + ]; + } + + /** + * schema中可以指定$ref属性引用定义好的definition + * @GetApi(path="/demo/info", description="获取用户详情") + * @Query(key="id", rule="required|integer|max:0") + * @ApiResponse(code="-1", description="参数错误") + * @ApiResponse(code="0", schema={"$ref": "DemoOkResponse"}) + */ + public function info() + { + return [ + 'code' => 0, + 'id' => 1, + 'name' => '张三', + 'age' => 1, + ]; + } + + /** + * @GetApi(path="/demos", summary="用户列表") + * @ApiResponse(code="200", description="ok", schema={{ + * "a|aa": {{ + * "a|aaa":"b","c|ccc":5.2 + * }}, + * "b|ids": {1,2,3}, + * "c|strings": {"a","b","c"}, + * "d|dd": {"a":"b","c":"d"}, + * "e|ee": "f" + * }}) + */ + public function list() + { + return [ + [ + "a" => [ + ["a" => "b", "c" => "d"], + ], + "b" => [1, 2, 3], + "c" => ["a", "b", "c"], + "d" => [ + "a" => "b", + "c" => "d", + ], + "e" => "f", + ], + ]; + } + +} diff --git a/app/Exception/Handler/ApiDogExceptionHandler.php b/app/Exception/Handler/ApiDogExceptionHandler.php new file mode 100644 index 0000000..ad36026 --- /dev/null +++ b/app/Exception/Handler/ApiDogExceptionHandler.php @@ -0,0 +1,27 @@ +stopPropagation(); + $this->formatLog($throwable); + return $this->response->fail(CommentErrorCode::INVALID_PARAMS, $throwable->getMessage()); + } + + public function isValid(Throwable $throwable): bool + { + return $throwable instanceof ApiDogException; + } +} diff --git a/composer.json b/composer.json index aa2d7aa..f0e44ea 100644 --- a/composer.json +++ b/composer.json @@ -30,14 +30,14 @@ "lengbin/hyperf-jwt": "dev-master", "lengbin/hyperf-auth": "dev-master", "lengbin/hyperf-common": "dev-master", - "lengbin/hyperf-error-code": "dev-main" + "lengbin/hyperf-error-code": "dev-main", + "daodao97/apidog": "^1.5" }, "require-dev": { "swoole/ide-helper": "^4.4", "phpmd/phpmd": "^2.6", "friendsofphp/php-cs-fixer": "^2.14", "mockery/mockery": "^1.0", - "doctrine/common": "^2.9", "phpstan/phpstan": "^0.12", "hyperf/devtool": "~2.0.0", "hyperf/testing": "~2.0.0" diff --git a/config/autoload/apidog.php b/config/autoload/apidog.php new file mode 100644 index 0000000..9654f3b --- /dev/null +++ b/config/autoload/apidog.php @@ -0,0 +1,50 @@ + env('APP_ENV') !== 'production', + // swagger 配置的输出文件 + // 当你有多个 http server 时, 可以在输出文件的名称中增加 {server} 字面变量 + // 比如 /public/swagger/swagger_{server}.json + 'output_file' => BASE_PATH . '/public/swagger/swagger.json', + // 忽略的hook, 非必须 用于忽略符合条件的接口, 将不会输出到上定义的文件中 + 'ignore' => function ($controller, $action) { + return false; + }, + // 自定义验证器错误码、错误描述字段 + 'error_code' => 400, + 'http_status_code' => 200, + 'field_error_code' => 'code', + 'field_error_message' => 'message', + 'exception_enable' => true, + // swagger 的基础配置 + 'swagger' => [ + 'swagger' => '2.0', + 'info' => [ + 'description' => 'hyperf swagger api desc', + 'version' => '1.0.0', + 'title' => 'HYPERF API DOC', + ], + 'host' => '127.0.0.1:9511', + 'schemes' => ['http'], + ], + 'templates' => [ + 'success' => [ + "code|code" => '0', + "result" => '{template}', + "message|message" => 'Success', + ], + 'page' => [ + "code|code" => '0', + "result" => [ + 'pageSize' => 10, + 'total' => 1, + 'totalPage' => 1, + 'list' => '{template}' + ], + "message|message" => 'Success', + ], + ], +]; diff --git a/config/autoload/exceptions.php b/config/autoload/exceptions.php index b786b1d..cc1ae64 100644 --- a/config/autoload/exceptions.php +++ b/config/autoload/exceptions.php @@ -10,14 +10,16 @@ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use App\Exception\Handler\ApiDogExceptionHandler; use Lengbin\Hyperf\Common\Exception\Handler\AppExceptionHandler; use Lengbin\Hyperf\Common\Exception\Handler\BusinessExceptionHandler; -use Lengbin\Hyperf\Exception\Handler\AuthTokenExceptionHandler; +use Lengbin\Hyperf\Auth\Exception\Handler\AuthTokenExceptionHandler; return [ 'handler' => [ 'http' => [ AuthTokenExceptionHandler::class, + ApiDogExceptionHandler::class, BusinessExceptionHandler::class, AppExceptionHandler::class, ], diff --git a/config/autoload/middlewares.php b/config/autoload/middlewares.php index 9787a5a..af06d5f 100644 --- a/config/autoload/middlewares.php +++ b/config/autoload/middlewares.php @@ -9,9 +9,15 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + +use Hyperf\Apidog\Middleware\ApiValidationMiddleware; +use Lengbin\Hyperf\Auth\Middleware\ApiMiddleware; +use Lengbin\Hyperf\Common\Middleware\CorsMiddleware; + return [ 'http' => [ - \Lengbin\Hyperf\Common\Middleware\CorsMiddleware::class, - \Lengbin\Hyperf\Auth\Middleware\ApiMiddleware::class, + CorsMiddleware::class, + ApiMiddleware::class, + ApiValidationMiddleware::class ], ]; diff --git a/config/autoload/translation.php b/config/autoload/translation.php new file mode 100644 index 0000000..35b9f06 --- /dev/null +++ b/config/autoload/translation.php @@ -0,0 +1,16 @@ + 'zh_CN', + 'fallback_locale' => 'en', + 'path' => BASE_PATH . '/storage/languages', +]; diff --git a/storage/languages/en/validation.php b/storage/languages/en/validation.php new file mode 100644 index 0000000..5e128a6 --- /dev/null +++ b/storage/languages/en/validation.php @@ -0,0 +1,177 @@ + 'The :attribute must be accepted.', + 'active_url' => 'The :attribute is not a valid URL.', + 'after' => 'The :attribute must be a date after :date.', + 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', + 'alpha' => 'The :attribute may only contain letters.', + 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', + 'alpha_num' => 'The :attribute may only contain letters and numbers.', + 'array' => 'The :attribute must be an array.', + 'before' => 'The :attribute must be a date before :date.', + 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', + 'between' => [ + 'numeric' => 'The :attribute must be between :min and :max.', + 'file' => 'The :attribute must be between :min and :max kilobytes.', + 'string' => 'The :attribute must be between :min and :max characters.', + 'array' => 'The :attribute must have between :min and :max items.', + ], + 'boolean' => 'The :attribute field must be true or false.', + 'confirmed' => 'The :attribute confirmation does not match.', + 'date' => 'The :attribute is not a valid date.', + 'date_format' => 'The :attribute does not match the format :format.', + 'different' => 'The :attribute and :other must be different.', + 'digits' => 'The :attribute must be :digits digits.', + 'digits_between' => 'The :attribute must be between :min and :max digits.', + 'dimensions' => 'The :attribute has invalid image dimensions.', + 'distinct' => 'The :attribute field has a duplicate value.', + 'email' => 'The :attribute must be a valid email address.', + 'exists' => 'The selected :attribute is invalid.', + 'file' => 'The :attribute must be a file.', + 'filled' => 'The :attribute field is required.', + 'gt' => [ + 'numeric' => 'The :attribute must be greater than :value', + 'file' => 'The :attribute must be greater than :value kb', + 'string' => 'The :attribute must be greater than :value characters', + 'array' => 'The :attribute must be greater than :value items', + ], + 'gte' => [ + 'numeric' => 'The :attribute must be great than or equal to :value', + 'file' => 'The :attribute must be great than or equal to :value kb', + 'string' => 'The :attribute must be great than or equal to :value characters', + 'array' => 'The :attribute must be great than or equal to :value items', + ], + 'image' => 'The :attribute must be an image.', + 'in' => 'The selected :attribute is invalid.', + 'in_array' => 'The :attribute field does not exist in :other.', + 'integer' => 'The :attribute must be an integer.', + 'ip' => 'The :attribute must be a valid IP address.', + 'ipv4' => 'The :attribute must be a valid IPv4 address.', + 'ipv6' => 'The :attribute must be a valid IPv6 address.', + 'json' => 'The :attribute must be a valid JSON string.', + 'lt' => [ + 'numeric' => 'The :attribute must be less than :value', + 'file' => 'The :attribute must be less than :value kb', + 'string' => 'The :attribute must be less than :value characters', + 'array' => 'The :attribute must be less than :value items', + ], + 'lte' => [ + 'numeric' => 'The :attribute must be less than or equal to :value', + 'file' => 'The :attribute must be less than or equal to :value kb', + 'string' => 'The :attribute must be less than or equal to :value characters', + 'array' => 'The :attribute must be less than or equal to :value items', + ], + 'max' => [ + 'numeric' => 'The :attribute may not be greater than :max.', + 'file' => 'The :attribute may not be greater than :max kilobytes.', + 'string' => 'The :attribute may not be greater than :max characters.', + 'array' => 'The :attribute may not have more than :max items.', + ], + 'mimes' => 'The :attribute must be a file of type: :values.', + 'mimetypes' => 'The :attribute must be a file of type: :values.', + 'min' => [ + 'numeric' => 'The :attribute must be at least :min.', + 'file' => 'The :attribute must be at least :min kilobytes.', + 'string' => 'The :attribute must be at least :min characters.', + 'array' => 'The :attribute must have at least :min items.', + ], + 'not_in' => 'The selected :attribute is invalid.', + 'not_regex' => 'The :attribute cannot match a given regular rule.', + 'numeric' => 'The :attribute must be a number.', + 'present' => 'The :attribute field must be present.', + 'regex' => 'The :attribute format is invalid.', + 'required' => 'The :attribute field is required.', + 'required_if' => 'The :attribute field is required when :other is :value.', + 'required_unless' => 'The :attribute field is required unless :other is in :values.', + 'required_with' => 'The :attribute field is required when :values is present.', + 'required_with_all' => 'The :attribute field is required when :values is present.', + 'required_without' => 'The :attribute field is required when :values is not present.', + 'required_without_all' => 'The :attribute field is required when none of :values are present.', + 'same' => 'The :attribute and :other must match.', + 'size' => [ + 'numeric' => 'The :attribute must be :size.', + 'file' => 'The :attribute must be :size kilobytes.', + 'string' => 'The :attribute must be :size characters.', + 'array' => 'The :attribute must contain :size items.', + ], + 'starts_with' => 'The :attribute must be start with :values ', + 'string' => 'The :attribute must be a string.', + 'timezone' => 'The :attribute must be a valid zone.', + 'unique' => 'The :attribute has already been taken.', + 'uploaded' => 'The :attribute failed to upload.', + 'url' => 'The :attribute format is invalid.', + 'uuid' => 'The :attribute is invalid UUID.', + 'max_if' => [ + 'numeric' => 'The :attribute may not be greater than :max when :other is :value.', + 'file' => 'The :attribute may not be greater than :max kilobytes when :other is :value.', + 'string' => 'The :attribute may not be greater than :max characters when :other is :value.', + 'array' => 'The :attribute may not have more than :max items when :other is :value.', + ], + 'min_if' => [ + 'numeric' => 'The :attribute must be at least :min when :other is :value.', + 'file' => 'The :attribute must be at least :min kilobytes when :other is :value.', + 'string' => 'The :attribute must be at least :min characters when :other is :value.', + 'array' => 'The :attribute must have at least :min items when :other is :value.', + ], + 'between_if' => [ + 'numeric' => 'The :attribute must be between :min and :max when :other is :value.', + 'file' => 'The :attribute must be between :min and :max kilobytes when :other is :value.', + 'string' => 'The :attribute must be between :min and :max characters when :other is :value.', + 'array' => 'The :attribute must have between :min and :max items when :other is :value.', + ], + /* + |-------------------------------------------------------------------------- + | Custom Validation Language Lines + |-------------------------------------------------------------------------- + | + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. + | + */ + + 'custom' => [ + 'attribute-name' => [ + 'rule-name' => 'custom-message', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Custom Validation Attributes + |-------------------------------------------------------------------------- + | + | The following language lines are used to swap attribute place-holders + | with something more reader friendly such as E-Mail Address instead + | of "email". This simply helps us make messages a little cleaner. + | + */ + + 'attributes' => [], + 'phone_number' => 'The :attribute must be a valid phone number', + 'telephone_number' => 'The :attribute must be a valid telephone number', + + 'chinese_word' => 'The :attribute must contain valid characters(chinese/english character, number, underscore)', + 'sequential_array' => 'The :attribute must be sequential array', +]; diff --git a/storage/languages/zh_CN/validation.php b/storage/languages/zh_CN/validation.php new file mode 100644 index 0000000..8093224 --- /dev/null +++ b/storage/languages/zh_CN/validation.php @@ -0,0 +1,177 @@ + ':attribute 必须接受', + 'active_url' => ':attribute 必须是一个合法的 URL', + 'after' => ':attribute 必须是 :date 之后的一个日期', + 'after_or_equal' => ':attribute 必须是 :date 之后或相同的一个日期', + 'alpha' => ':attribute 只能包含字母', + 'alpha_dash' => ':attribute 只能包含字母、数字、中划线或下划线', + 'alpha_num' => ':attribute 只能包含字母和数字', + 'array' => ':attribute 必须是一个数组', + 'before' => ':attribute 必须是 :date 之前的一个日期', + 'before_or_equal' => ':attribute 必须是 :date 之前或相同的一个日期', + 'between' => [ + 'numeric' => ':attribute 必须在 :min 到 :max 之间', + 'file' => ':attribute 必须在 :min 到 :max kb 之间', + 'string' => ':attribute 必须在 :min 到 :max 个字符之间', + 'array' => ':attribute 必须在 :min 到 :max 项之间', + ], + 'boolean' => ':attribute 字符必须是 true 或 false, 1 或 0', + 'confirmed' => ':attribute 二次确认不匹配', + 'date' => ':attribute 必须是一个合法的日期', + 'date_format' => ':attribute 与给定的格式 :format 不符合', + 'different' => ':attribute 必须不同于 :other', + 'digits' => ':attribute 必须是 :digits 位', + 'digits_between' => ':attribute 必须在 :min 和 :max 位之间', + 'dimensions' => ':attribute 具有无效的图片尺寸', + 'distinct' => ':attribute 字段具有重复值', + 'email' => ':attribute 必须是一个合法的电子邮件地址', + 'exists' => '选定的 :attribute 是无效的', + 'file' => ':attribute 必须是一个文件', + 'filled' => ':attribute 的字段是必填的', + 'gt' => [ + 'numeric' => ':attribute 必须大于 :value', + 'file' => ':attribute 必须大于 :value kb', + 'string' => ':attribute 必须大于 :value 个字符', + 'array' => ':attribute 必须大于 :value 项', + ], + 'gte' => [ + 'numeric' => ':attribute 必须大于等于 :value', + 'file' => ':attribute 必须大于等于 :value kb', + 'string' => ':attribute 必须大于等于 :value 个字符', + 'array' => ':attribute 必须大于等于 :value 项', + ], + 'image' => ':attribute 必须是 jpg, jpeg, png, bmp 或者 gif 格式的图片', + 'in' => '选定的 :attribute 是无效的', + 'in_array' => ':attribute 字段不存在于 :other', + 'integer' => ':attribute 必须是个整数', + 'ip' => ':attribute 必须是一个合法的 IP 地址', + 'ipv4' => ':attribute 必须是一个合法的 IPv4 地址', + 'ipv6' => ':attribute 必须是一个合法的 IPv6 地址', + 'json' => ':attribute 必须是一个合法的 JSON 字符串', + 'lt' => [ + 'numeric' => ':attribute 必须小于 :value', + 'file' => ':attribute 必须小于 :value kb', + 'string' => ':attribute 必须小于 :value 个字符', + 'array' => ':attribute 必须小于 :value 项', + ], + 'lte' => [ + 'numeric' => ':attribute 必须小于等于 :value', + 'file' => ':attribute 必须小于等于 :value kb', + 'string' => ':attribute 必须小于等于 :value 个字符', + 'array' => ':attribute 必须小于等于 :value 项', + ], + 'max' => [ + 'numeric' => ':attribute 的最大值为 :max', + 'file' => ':attribute 的最大为 :max kb', + 'string' => ':attribute 的最大长度为 :max 字符', + 'array' => ':attribute 至多有 :max 项', + ], + 'mimes' => ':attribute 的文件类型必须是 :values', + 'mimetypes' => ':attribute 的文件MIME必须是 :values', + 'min' => [ + 'numeric' => ':attribute 的最小值为 :min', + 'file' => ':attribute 大小至少为 :min kb', + 'string' => ':attribute 的最小长度为 :min 字符', + 'array' => ':attribute 至少有 :min 项', + ], + 'not_in' => '选定的 :attribute 是无效的', + 'not_regex' => ':attribute 不能匹配给定的正则', + 'numeric' => ':attribute 必须是数字', + 'present' => ':attribute 字段必须存在', + 'regex' => ':attribute 格式是无效的', + 'required' => ':attribute 字段是必须的', + 'required_if' => ':attribute 字段是必须的当 :other 是 :value', + 'required_unless' => ':attribute 字段是必须的,除非 :other 是在 :values 中', + 'required_with' => ':attribute 字段是必须的当 :values 是存在的', + 'required_with_all' => ':attribute 字段是必须的当 :values 是存在的', + 'required_without' => ':attribute 字段是必须的当 :values 是不存在的', + 'required_without_all' => ':attribute 字段是必须的当 没有一个 :values 是存在的', + 'same' => ':attribute 和 :other 必须匹配', + 'size' => [ + 'numeric' => ':attribute 必须是 :size', + 'file' => ':attribute 必须是 :size kb', + 'string' => ':attribute 必须是 :size 个字符', + 'array' => ':attribute 必须包括 :size 项', + ], + 'starts_with' => ':attribute 必须以 :values 为开头', + 'string' => ':attribute 必须是一个字符串', + 'timezone' => ':attribute 必须是个有效的时区', + 'unique' => ':attribute 已存在', + 'uploaded' => ':attribute 上传失败', + 'url' => ':attribute 无效的格式', + 'uuid' => ':attribute 无效的UUID格式', + 'max_if' => [ + 'numeric' => '当 :other 为 :value 时 :attribute 不能大于 :max', + 'file' => '当 :other 为 :value 时 :attribute 不能大于 :max kb', + 'string' => '当 :other 为 :value 时 :attribute 不能大于 :max 个字符', + 'array' => '当 :other 为 :value 时 :attribute 最多只有 :max 个单元', + ], + 'min_if' => [ + 'numeric' => '当 :other 为 :value 时 :attribute 必须大于等于 :min', + 'file' => '当 :other 为 :value 时 :attribute 大小不能小于 :min kb', + 'string' => '当 :other 为 :value 时 :attribute 至少为 :min 个字符', + 'array' => '当 :other 为 :value 时 :attribute 至少有 :min 个单元', + ], + 'between_if' => [ + 'numeric' => '当 :other 为 :value 时 :attribute 必须介于 :min - :max 之间', + 'file' => '当 :other 为 :value 时 :attribute 必须介于 :min - :max kb 之间', + 'string' => '当 :other 为 :value 时 :attribute 必须介于 :min - :max 个字符之间', + 'array' => '当 :other 为 :value 时 :attribute 必须只有 :min - :max 个单元', + ], + /* + |-------------------------------------------------------------------------- + | Custom Validation Language Lines + |-------------------------------------------------------------------------- + | + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. + | + */ + + 'custom' => [ + 'attribute-name' => [ + 'rule-name' => 'custom-message', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Custom Validation Attributes + |-------------------------------------------------------------------------- + | + | The following language lines are used to swap attribute place-holders + | with something more reader friendly such as E-Mail Address instead + | of "email". This simply helps us make messages a little cleaner. + | + */ + + 'attributes' => [], + 'phone_number' => ':attribute 必须为一个有效的电话号码', + 'telephone_number' => ':attribute 必须为一个有效的手机号码', + + 'chinese_word' => ':attribute 必须包含以下有效字符 (中文/英文,数字, 下划线)', + 'sequential_array' => ':attribute 必须是一个有序数组', +]; From 251105847616c73b3cfb9158e2f67dcbaa5ee0a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sat, 14 Nov 2020 17:36:11 +0800 Subject: [PATCH 15/82] rbac --- .env | 4 ++-- README.md | 13 ++++++----- app/Constant/Error.php | 46 ++++++++++++++++++++++++++++++++++++++ composer.json | 3 ++- config/autoload/rbac.php | 48 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 106 insertions(+), 8 deletions(-) create mode 100644 app/Constant/Error.php create mode 100644 config/autoload/rbac.php diff --git a/.env b/.env index 41be784..6de2e60 100644 --- a/.env +++ b/.env @@ -3,7 +3,7 @@ APP_NAME=skeleton DB_DRIVER=mysql DB_HOST=localhost DB_PORT=3306 -DB_DATABASE=hyperf +DB_DATABASE=hyperf_admin DB_USERNAME=root DB_PASSWORD= DB_CHARSET=utf8mb4 @@ -13,4 +13,4 @@ DB_PREFIX= REDIS_HOST=localhost REDIS_AUTH=(null) REDIS_PORT=6379 -REDIS_DB=0 \ No newline at end of file +REDIS_DB=0 diff --git a/README.md b/README.md index 6689b83..d3d7429 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ If You Like This Please Give Me Star -基于 Hyperf 2.0 && YII3.0 框架 +基于 Hyperf 2.0 && YII3 目前还在研发中,请慎用 @@ -25,12 +25,15 @@ git clone -b 2.0 https://github.com/ice-leng/hyperf-advanced.git 使用扩展 -------------- - [jwt](https://github.com/ice-leng/hyperf-jwt) -- [授权验证-yii](https://github.com/ice-leng/hyperf-auth) +- [授权验证-yii,支持路由白名单](https://github.com/ice-leng/hyperf-auth) - [枚举,错误码合并生成](https://github.com/ice-leng/hyperf-error-code) -- [swagger](https://github.com/daodao97/apidog) +- [swagger,路由](https://github.com/daodao97/apidog) +- [rbac, 菜单](https://github.com/ice-leng/hyperf-yii-rbac) 感谢 -------------- -Yii 团队 +[Hyperf](https://github.com/hyperf) -Hyperf 团队 +[Yii](https://github.com/yiisoft) + +[dadao](https://github.com/daodao97) diff --git a/app/Constant/Error.php b/app/Constant/Error.php new file mode 100644 index 0000000..c093847 --- /dev/null +++ b/app/Constant/Error.php @@ -0,0 +1,46 @@ + \Lengbin\YiiSoft\Rbac\Manager\DbManager::class, + * 'connection' => null, // 连接db ,可以不需要 + * 'cache' => \Cache\Cache::class, //缓存类,可以不需要 + * 'log' => null // log key 名称 + * 'defaultRoles' => [], // 默认角色,可以不需要 + * 'item' => null, // item 表名称,可以不需要 + * 'assignment' => null, // assignment 表名称,可以不需要 + * 'rule' => null, // rule 表名称,可以不需要 + * 'itemChild' => null, // itemChild 表名称,可以不需要 + * 'menu' => null, // menu 表名称,可以不需要 + * ]; + * + * PhpManager + * return [ + * 'driver' => \Lengbin\YiiSoft\Rbac\Manager\PhpManager::class, + * 'cache' => \Cache\Cache::class, //缓存类,可以不需要 + * 'log' => null // log key 名称 + * 'defaultRoles' => [], // 默认角色,可以不需要 + * 'item' => null, // item 缓存名称,可以不需要 + * 'assignment' => null, // assignment 缓存名称,可以不需要 + * 'rule' => null, // rule 缓存名称,可以不需要 + * 'menu' => null, // menu 表名称,可以不需要 + * ]; + * + * PhpManagerFile + * return [ + * 'driver' => \Lengbin\YiiSoft\Rbac\Manager\PhpManagerFile::class, + * 'directory' => './cache', //保存文件路径,可以不需要 + * 'log' => null // log key 名称 + * 'defaultRoles' => [], // 默认角色,可以不需要 + * 'item' => null, // item 保存文件名称,可以不需要 + * 'assignment' => null, // assignment 保存文件名称,可以不需要 + * 'rule' => null ,// rule 保存文件名称,可以不需要 + * 'menu' => null, // menu 表名称,可以不需要 + * ]; + */ + +use Lengbin\YiiSoft\Rbac\Manager\PhpManagerFile; + +return [ + 'driver' => PhpManagerFile::class, + 'directory' => BASE_PATH . '/runtime/role' +]; From 4a5706482d501df94d1bcfaf2c04665f7fda9615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sun, 15 Nov 2020 22:15:52 +0800 Subject: [PATCH 16/82] add function getValidateData --- .../{AuthController.php => Controller.php} | 21 +++++- app/Controller/IndexController.php | 64 ------------------- app/Controller/V1/DemoController.php | 9 ++- 3 files changed, 26 insertions(+), 68 deletions(-) rename app/Controller/{AuthController.php => Controller.php} (56%) delete mode 100644 app/Controller/IndexController.php diff --git a/app/Controller/AuthController.php b/app/Controller/Controller.php similarity index 56% rename from app/Controller/AuthController.php rename to app/Controller/Controller.php index 9bd44e0..1f8f544 100644 --- a/app/Controller/AuthController.php +++ b/app/Controller/Controller.php @@ -3,10 +3,11 @@ namespace App\Controller; use Hyperf\Contract\ConfigInterface; +use Hyperf\Utils\Context; use Lengbin\Auth\User\UserInterface; use Lengbin\Hyperf\Common\Framework\BaseController; -class AuthController extends BaseController +class Controller extends BaseController { /** * auth @@ -18,4 +19,22 @@ public function getAuth(): UserInterface $requestName = $config->get('auth.api.requestName', 'api'); return $this->request->getAttribute($requestName); } + + /** + * api dog validate data + */ + public function getValidateData(): array + { + return Context::get('validator.data', []); + } + + /** + * 初始化 配置参数 设置 + * @return array + */ + public function init(): array + { + return []; + } + } diff --git a/app/Controller/IndexController.php b/app/Controller/IndexController.php deleted file mode 100644 index ed0e692..0000000 --- a/app/Controller/IndexController.php +++ /dev/null @@ -1,64 +0,0 @@ -request->input('user', 'Hyperf'); - $method = $this->request->getMethod(); - return $this->success([ - 'method' => $method, - 'message' => "Hello {$user}.", - ]); - } - - /** - * @RequestMapping(path="/user", methods={"get"}) - */ - public function user() - { - return $this->success([ - 'abc' => $this->getAuth()->getId(), - ]); - } - - /** - * @RequestMapping(path="/test", methods={"get"}) - * @RouterAuthAnnotation(isWhitelist=true) - */ - public function test() - { - return $this->success([ - 'abc' => $this->getAuth()->getId(), - ]); - } - -} diff --git a/app/Controller/V1/DemoController.php b/app/Controller/V1/DemoController.php index 3ee3237..5081ed8 100644 --- a/app/Controller/V1/DemoController.php +++ b/app/Controller/V1/DemoController.php @@ -2,7 +2,7 @@ namespace App\Controller\V1; -use App\Controller\AuthController; +use App\Controller\Controller; use Hyperf\Apidog\Annotation\ApiController; use Hyperf\Apidog\Annotation\ApiDefinition; use Hyperf\Apidog\Annotation\ApiDefinitions; @@ -39,7 +39,7 @@ * * @RouterAuthAnnotation(isPublic=true) */ -class DemoController extends AuthController +class DemoController extends Controller { /** @@ -100,9 +100,10 @@ public function delete() /** * @GetApi(path="/demo", description="获取用户详情") - * @Query(key="id", rule="required|integer|max:0") + * @Query(key="id", rule="required|integer|max:10") * @ApiResponse(code="-1", description="参数错误") * @ApiResponse(code="0", schema={"id":1,"name":"张三","age":1}, template="success") + * @RouterAuthAnnotation(isWhitelist=true) */ public function get() { @@ -111,6 +112,8 @@ public function get() 'id' => 1, 'name' => '张三', 'age' => 1, + 'data' => $this->getValidateData(), + 'user_id' => $this->getAuth()->getId() ]; } From 65993ef5fdbd7b446494144f41bb1735b340611c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sun, 15 Nov 2020 22:16:58 +0800 Subject: [PATCH 17/82] add rabc --- app/Controller/V1/DemoController.php | 12 ++++++------ config/autoload/rbac.php | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Controller/V1/DemoController.php b/app/Controller/V1/DemoController.php index 5081ed8..b84a599 100644 --- a/app/Controller/V1/DemoController.php +++ b/app/Controller/V1/DemoController.php @@ -108,12 +108,12 @@ public function delete() public function get() { return [ - 'code' => 0, - 'id' => 1, - 'name' => '张三', - 'age' => 1, - 'data' => $this->getValidateData(), - 'user_id' => $this->getAuth()->getId() + 'code' => 0, + 'id' => 1, + 'name' => '张三', + 'age' => 1, + 'data' => $this->getValidateData(), + 'user_id' => $this->getAuth()->getId(), ]; } diff --git a/config/autoload/rbac.php b/config/autoload/rbac.php index d223a21..2b66e8d 100644 --- a/config/autoload/rbac.php +++ b/config/autoload/rbac.php @@ -43,6 +43,6 @@ use Lengbin\YiiSoft\Rbac\Manager\PhpManagerFile; return [ - 'driver' => PhpManagerFile::class, - 'directory' => BASE_PATH . '/runtime/role' + 'driver' => PhpManagerFile::class, + 'directory' => BASE_PATH . '/runtime/role', ]; From af00bbaadeae33dede2ad985463b0e7c2cd507f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Mon, 16 Nov 2020 00:00:02 +0800 Subject: [PATCH 18/82] add rabc --- config/autoload/middlewares.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/autoload/middlewares.php b/config/autoload/middlewares.php index af06d5f..aeeeb94 100644 --- a/config/autoload/middlewares.php +++ b/config/autoload/middlewares.php @@ -13,11 +13,13 @@ use Hyperf\Apidog\Middleware\ApiValidationMiddleware; use Lengbin\Hyperf\Auth\Middleware\ApiMiddleware; use Lengbin\Hyperf\Common\Middleware\CorsMiddleware; +use Lengbin\Hyperf\YiiSoft\Rbac\Middleware\PermissionMiddleware; return [ 'http' => [ CorsMiddleware::class, ApiMiddleware::class, - ApiValidationMiddleware::class + ApiValidationMiddleware::class, + PermissionMiddleware::class ], ]; From 3bbb95da1770eea43352412d0a8d83adb2e598b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Mon, 16 Nov 2020 00:36:38 +0800 Subject: [PATCH 19/82] add migration - admin --- migrations/2020_11_15_160222_init.php | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 migrations/2020_11_15_160222_init.php diff --git a/migrations/2020_11_15_160222_init.php b/migrations/2020_11_15_160222_init.php new file mode 100644 index 0000000..1bb974c --- /dev/null +++ b/migrations/2020_11_15_160222_init.php @@ -0,0 +1,38 @@ +bigIncrements('admin_id'); + + $table->string('account', 32)->comment('账号'); + $table->string('password', 255)->comment('密码'); + $table->string('role', 255)->comment('角色'); + $table->string('nickname', 32)->comment('昵称'); + $table->unsignedInteger('number')->default(1)->comment('工号'); + + $table->unsignedTinyInteger('enable')->comment('状态'); + $table->unsignedInteger('create_at'); + $table->unsignedInteger('update_at'); + }); + + + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('admin'); + } +} From 179d43db4ece26d0321960c896f0d7d17fe621e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Mon, 16 Nov 2020 00:37:34 +0800 Subject: [PATCH 20/82] add migration - admin --- config/autoload/rbac.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/autoload/rbac.php b/config/autoload/rbac.php index 2b66e8d..98c599e 100644 --- a/config/autoload/rbac.php +++ b/config/autoload/rbac.php @@ -40,9 +40,8 @@ * ]; */ -use Lengbin\YiiSoft\Rbac\Manager\PhpManagerFile; +use Lengbin\YiiSoft\Rbac\Manager\DbManager; return [ - 'driver' => PhpManagerFile::class, - 'directory' => BASE_PATH . '/runtime/role', + 'driver' => DbManager::class, ]; From 69508f1fdf7868de9b9c7ec5d1f741b07ccd04ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Tue, 17 Nov 2020 00:35:30 +0800 Subject: [PATCH 21/82] =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constant/Error.php | 29 ++++- app/Constant/Errors/AdminError.php | 38 ++++++ app/Constant/Errors/ErrorCode.php | 22 ---- app/Constant/Status/AdminStatus.php | 18 +++ app/Controller/Controller.php | 6 +- app/Controller/LoginController.php | 80 ++++++++++++ app/Model/Admin.php | 50 +++++++ app/Model/AuthAssignment.php | 32 +++++ app/Model/AuthItem.php | 35 +++++ app/Model/AuthItemChild.php | 31 +++++ app/Model/AuthMenu.php | 38 ++++++ app/Model/AuthRule.php | 33 +++++ app/Model/UserModel.php | 27 ---- app/Service/Admin/LoginService.php | 123 ++++++++++++++++++ config/autoload/auth.php | 6 +- config/autoload/databases.php | 2 + config/autoload/jwt.php | 2 +- .../V1 => doc/swagger}/DemoController.php | 0 18 files changed, 516 insertions(+), 56 deletions(-) create mode 100644 app/Constant/Errors/AdminError.php delete mode 100644 app/Constant/Errors/ErrorCode.php create mode 100644 app/Constant/Status/AdminStatus.php create mode 100644 app/Controller/LoginController.php create mode 100644 app/Model/Admin.php create mode 100644 app/Model/AuthAssignment.php create mode 100644 app/Model/AuthItem.php create mode 100644 app/Model/AuthItemChild.php create mode 100644 app/Model/AuthMenu.php create mode 100644 app/Model/AuthRule.php delete mode 100644 app/Model/UserModel.php create mode 100644 app/Service/Admin/LoginService.php rename {app/Controller/V1 => doc/swagger}/DemoController.php (100%) diff --git a/app/Constant/Error.php b/app/Constant/Error.php index c093847..6cef55b 100644 --- a/app/Constant/Error.php +++ b/app/Constant/Error.php @@ -39,8 +39,33 @@ class Error extends BaseEnum const ERROR_COMMENTERRORCODE_INVALID_TOKEN = 'F-000-000-403'; /** - * @Message("Server Error!") + * @Message("账号被冻结,请联系管理员") */ - const ERROR_ERRORCODE_SERVER_ERROR = '500'; + const ERROR_ADMINERROR_ERROR_ADMIN_FREEZE = 'B-001-001-001'; + + /** + * @Message("账号不存在") + */ + const ERROR_ADMINERROR_ERROR_ADMIN_NOT_FOUND = 'B-001-001-002'; + + /** + * @Message("账号创建失败") + */ + const ERROR_ADMINERROR_ERROR_ADMIN_CREATE_FAIL = 'B-001-001-003'; + + /** + * @Message("账号更新失败") + */ + const ERROR_ADMINERROR_ERROR_ADMIN_UPDATE_FAIL = 'B-001-001-004'; + + /** + * @Message("账号删除失败") + */ + const ERROR_ADMINERROR_ERROR_ADMIN_DELETE_FAIL = 'B-001-001-005'; + + /** + * @Message("账号或密码错误") + */ + const ERROR_ADMINERROR_ERROR_ADMIN_ACCOUNT_OR_PASSWORD_FAIL = 'B-001-001-006'; } diff --git a/app/Constant/Errors/AdminError.php b/app/Constant/Errors/AdminError.php new file mode 100644 index 0000000..bb4a029 --- /dev/null +++ b/app/Constant/Errors/AdminError.php @@ -0,0 +1,38 @@ +getValidateData(); + $data = $this->loginService->login($params, $this->request->getClientIp()); + return $this->success($data); + } + + /** + * @PostApi(path="/login/refreshToken", summary="刷新token", description="刷新token") + * @Body(rules={ + * "refresh_token|刷新token" : "required|string" + * }) + * @ApiResponse(code="0", template="success", schema={ + * "token" : "123456", + * "refresh_token": "123456" + * }) + */ + public function refreshToken() + { + $refreshToken = ArrayHelper::get($this->getValidateData(), 'refresh_token'); + $data = $this->loginService->refreshToken($refreshToken, $this->request->getClientIp()); + return $this->success($data); + } + + /** + * @PostApi(path="/login/logout", summary="注销", description="退出登录") + * @Header(key="token|接口访问凭证", rule="required|string") + * + * @ApiResponse(code="0", template="success") + */ + public function logout() + { + $token = ArrayHelper::get($this->getValidateData(), 'token'); + $this->loginService->logout($token, $this->request->getClientIp()); + return $this->success([]); + } + +} diff --git a/app/Model/Admin.php b/app/Model/Admin.php new file mode 100644 index 0000000..14f932c --- /dev/null +++ b/app/Model/Admin.php @@ -0,0 +1,50 @@ + 'integer', 'enable' => 'integer', 'create_at' => 'datetime', 'update_at' => 'datetime']; + + /** + * Returns an ID that can uniquely identify a user identity. + * @return string an ID that uniquely identifies a user identity. + */ + public function getId(): string + { + return $this->admin_id; + } +} diff --git a/app/Model/AuthAssignment.php b/app/Model/AuthAssignment.php new file mode 100644 index 0000000..952fb09 --- /dev/null +++ b/app/Model/AuthAssignment.php @@ -0,0 +1,32 @@ + 'integer']; +} \ No newline at end of file diff --git a/app/Model/AuthItem.php b/app/Model/AuthItem.php new file mode 100644 index 0000000..6784e0b --- /dev/null +++ b/app/Model/AuthItem.php @@ -0,0 +1,35 @@ + 'integer', 'updated_at' => 'integer']; +} \ No newline at end of file diff --git a/app/Model/AuthItemChild.php b/app/Model/AuthItemChild.php new file mode 100644 index 0000000..370a35e --- /dev/null +++ b/app/Model/AuthItemChild.php @@ -0,0 +1,31 @@ + 'integer', 'updated_at' => 'integer', 'sort' => 'integer']; +} \ No newline at end of file diff --git a/app/Model/AuthRule.php b/app/Model/AuthRule.php new file mode 100644 index 0000000..2965683 --- /dev/null +++ b/app/Model/AuthRule.php @@ -0,0 +1,33 @@ + 'integer', 'updated_at' => 'integer']; +} \ No newline at end of file diff --git a/app/Model/UserModel.php b/app/Model/UserModel.php deleted file mode 100644 index 847e5aa..0000000 --- a/app/Model/UserModel.php +++ /dev/null @@ -1,27 +0,0 @@ -jwt->verifyToken($token); + if (!ArrayHelper::isValidValue($data, 'admin_id')) { + return null; + } + $admin = $this->findIdentity($data['admin_id']); + $this->checkAdmin($admin); + return $admin; + } + + protected function checkAdmin($admin): void + { + if (StringHelper::isEmpty($admin)) { + throw new BusinessException(AdminError::ERROR_ADMIN_NOT_FOUND); + } + + if ($admin->status === AdminStatus::FROZEN) { + throw new BusinessException(AdminError::ERROR_ADMIN_FREEZE); + } + } + + /** + * 登录 + * + * @param array $params [account, password] + * @param string $ip + * + * @return array + */ + public function login(array $params, string $ip): array + { + $admin = Admin::findOneCondition($params, ['admin_id', 'status']); + $this->checkAdmin($admin); + + $token = $this->jwt->generate([ + 'admin_id' => $admin->admin_id, + ]); + // todo 登录日志 + return [ + 'token' => $token, + 'refresh_token' => $this->jwt->generateRefreshToken($token), + ]; + } + + /** + * 刷新token + * + * @param string $refreshToken + * @param string $ip + * + * @return array + */ + public function refreshToken(string $refreshToken, string $ip): array + { + // todo 登录日志 + $token = $this->jwt->refreshToken($refreshToken); + return [ + 'token' => $token, + 'refresh_token' => $refreshToken, + ]; + } + + /** + * 退出 + * + * @param string $token + * @param string $ip + * + * @return bool + */ + public function logout(string $token, string $ip): bool + { + // todo 登录日志 + return $this->jwt->logout($token); + } +} diff --git a/config/autoload/auth.php b/config/autoload/auth.php index e7d3f76..4dd1929 100644 --- a/config/autoload/auth.php +++ b/config/autoload/auth.php @@ -28,12 +28,14 @@ * ]; */ +use App\Service\Admin\LoginService; + return [ 'api' => [ // 全局变量 名称 'requestName' => 'api', // 实现类,请实现接口 \Lengbin\Auth\IdentityRepositoryInterface::class - 'identityClass' => \App\Model\UserModel::class, + 'identityClass' => LoginService::class, // 验证器方法,支持 // header: \Lengbin\Auth\Method\HttpHeaderAuth::class //默认接收参数名称:X-Api-Token // query : \Lengbin\Auth\Method\QueryParamAuth::class //默认接收参数名称:access-token @@ -44,7 +46,7 @@ // key => val 接收参数名称 => 验证类 'method' => [ \Lengbin\Auth\Method\HttpHeaderAuth::class, - \Lengbin\Auth\Method\QueryParamAuth::class, +// \Lengbin\Auth\Method\QueryParamAuth::class, ], //路由白名单。列如 /test/{id}, 可以使用*来通配, /test/* 'whitelist' => [], diff --git a/config/autoload/databases.php b/config/autoload/databases.php index 40a71a5..68abb95 100644 --- a/config/autoload/databases.php +++ b/config/autoload/databases.php @@ -34,6 +34,8 @@ 'force_casts' => true, 'inheritance' => 'BaseModel', 'uses' => 'Lengbin\Hyperf\Common\Framework\BaseModel', + 'refresh_fillable' => true, + 'with_comments' => true, ], ], ], diff --git a/config/autoload/jwt.php b/config/autoload/jwt.php index 0bb1412..ae2b2dc 100644 --- a/config/autoload/jwt.php +++ b/config/autoload/jwt.php @@ -8,5 +8,5 @@ 'ttl' => 24 * 3600 * 30, // 是否 单点登录 'sso' => true, - 'ssoKey' => 'user_id' + 'ssoKey' => 'admin_id' ]; diff --git a/app/Controller/V1/DemoController.php b/doc/swagger/DemoController.php similarity index 100% rename from app/Controller/V1/DemoController.php rename to doc/swagger/DemoController.php From dcb57de699f516f962463c97041f7889b6154de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Tue, 17 Nov 2020 10:34:35 +0800 Subject: [PATCH 22/82] =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/autoload/auth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/autoload/auth.php b/config/autoload/auth.php index 4dd1929..d92f01e 100644 --- a/config/autoload/auth.php +++ b/config/autoload/auth.php @@ -45,7 +45,7 @@ // 如果为 数组 则为 混合验证 // key => val 接收参数名称 => 验证类 'method' => [ - \Lengbin\Auth\Method\HttpHeaderAuth::class, + 'token' => \Lengbin\Auth\Method\HttpHeaderAuth::class, // \Lengbin\Auth\Method\QueryParamAuth::class, ], //路由白名单。列如 /test/{id}, 可以使用*来通配, /test/* From f23b106a6925ec50ca2e6d24c051b5e17444453d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Wed, 18 Nov 2020 00:37:35 +0800 Subject: [PATCH 23/82] =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/Admin.php | 5 ++-- app/Service/Admin/LoginService.php | 35 ++++++++++++++++++--------- migrations/2020_11_15_160222_init.php | 1 + 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/app/Model/Admin.php b/app/Model/Admin.php index 14f932c..69ee6b9 100644 --- a/app/Model/Admin.php +++ b/app/Model/Admin.php @@ -14,6 +14,7 @@ * @property string $role 角色 * @property string $nickname 昵称 * @property int $number 工号 + * @property int $status 状态 * @property int $enable 状态 * @property int $create_at * @property int $update_at @@ -31,13 +32,13 @@ class Admin extends BaseModel implements IdentityInterface * * @var array */ - protected $fillable = ['admin_id', 'account', 'password', 'role', 'nickname', 'number', 'enable', 'create_at', 'update_at']; + protected $fillable = ['admin_id', 'account', 'password', 'role', 'nickname', 'number', 'status', 'enable', 'create_at', 'update_at']; /** * The attributes that should be cast to native types. * * @var array */ - protected $casts = ['number' => 'integer', 'enable' => 'integer', 'create_at' => 'datetime', 'update_at' => 'datetime']; + protected $casts = ['admin_id' => 'string', 'number' => 'integer', 'status' => 'integer', 'enable' => 'integer', 'create_at' => 'datetime', 'update_at' => 'datetime']; /** * Returns an ID that can uniquely identify a user identity. diff --git a/app/Service/Admin/LoginService.php b/app/Service/Admin/LoginService.php index 2b4b21e..b530749 100644 --- a/app/Service/Admin/LoginService.php +++ b/app/Service/Admin/LoginService.php @@ -8,9 +8,9 @@ use Hyperf\Di\Annotation\Inject; use Lengbin\Auth\IdentityInterface; use Lengbin\Auth\IdentityRepositoryInterface; +use Lengbin\Helper\Util\PasswordHelper; use Lengbin\Helper\YiiSoft\Arrays\ArrayHelper; use Lengbin\Helper\YiiSoft\StringHelper; -use Lengbin\Hyperf\Common\Constant\SoftDeleted; use Lengbin\Hyperf\Common\Exception\BusinessException; use Lengbin\Hyperf\Common\Framework\BaseService; use Lengbin\Jwt\JwtInterface; @@ -51,17 +51,17 @@ public function findIdentityByToken(string $token, string $type): ?IdentityInter return null; } $admin = $this->findIdentity($data['admin_id']); - $this->checkAdmin($admin); + $this->checkAdminStatus($admin); return $admin; } - protected function checkAdmin($admin): void + /** + * check status + * @param $admin + */ + protected function checkAdminStatus($admin): void { - if (StringHelper::isEmpty($admin)) { - throw new BusinessException(AdminError::ERROR_ADMIN_NOT_FOUND); - } - - if ($admin->status === AdminStatus::FROZEN) { + if (StringHelper::isEmpty($admin) || $admin->status === AdminStatus::FROZEN) { throw new BusinessException(AdminError::ERROR_ADMIN_FREEZE); } } @@ -76,15 +76,26 @@ protected function checkAdmin($admin): void */ public function login(array $params, string $ip): array { - $admin = Admin::findOneCondition($params, ['admin_id', 'status']); - $this->checkAdmin($admin); + $admin = Admin::findOneCondition([ + 'account' => $params['account'], + ], ['admin_id', 'password', 'status']); + + if (StringHelper::isEmpty($admin)) { + throw new BusinessException(AdminError::ERROR_ADMIN_ACCOUNT_OR_PASSWORD_FAIL); + } + + if (!PasswordHelper::verifyPassword($params['password'], $admin->password)) { + throw new BusinessException(AdminError::ERROR_ADMIN_ACCOUNT_OR_PASSWORD_FAIL); + } + + $this->checkAdminStatus($admin); $token = $this->jwt->generate([ 'admin_id' => $admin->admin_id, ]); // todo 登录日志 return [ - 'token' => $token, + 'token' => $token, 'refresh_token' => $this->jwt->generateRefreshToken($token), ]; } @@ -102,7 +113,7 @@ public function refreshToken(string $refreshToken, string $ip): array // todo 登录日志 $token = $this->jwt->refreshToken($refreshToken); return [ - 'token' => $token, + 'token' => $token, 'refresh_token' => $refreshToken, ]; } diff --git a/migrations/2020_11_15_160222_init.php b/migrations/2020_11_15_160222_init.php index 1bb974c..9be9ad2 100644 --- a/migrations/2020_11_15_160222_init.php +++ b/migrations/2020_11_15_160222_init.php @@ -19,6 +19,7 @@ public function up(): void $table->string('role', 255)->comment('角色'); $table->string('nickname', 32)->comment('昵称'); $table->unsignedInteger('number')->default(1)->comment('工号'); + $table->unsignedTinyInteger('status')->default(0)->comment('状态,1正常2冻结'); $table->unsignedTinyInteger('enable')->comment('状态'); $table->unsignedInteger('create_at'); From 9887ed0f2e001928ebac547fab4cb69e0e83b028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Fri, 20 Nov 2020 15:43:19 +0800 Subject: [PATCH 24/82] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20auth=20=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/User.php | 64 +++++++++++++++++++ app/Controller/LoginController.php | 4 +- ...LoginService.php => AdminLoginService.php} | 45 ++++--------- config/autoload/auth.php | 7 +- 4 files changed, 83 insertions(+), 37 deletions(-) create mode 100644 app/Component/User.php rename app/Service/Admin/{LoginService.php => AdminLoginService.php} (67%) diff --git a/app/Component/User.php b/app/Component/User.php new file mode 100644 index 0000000..81298cb --- /dev/null +++ b/app/Component/User.php @@ -0,0 +1,64 @@ +jwt->verifyToken($token); + $channel = ArrayHelper::get($data, 'channel', null); + // 多服务器 渠道 判断 + switch ($channel) { + case 'admin': + if (ArrayHelper::isValidValue($data, 'admin_id')) { + $user = $this->adminLoginService->findIdentity(['admin_id' => $data['admin_id']]); + } + break; + } + return $user; + } +} diff --git a/app/Controller/LoginController.php b/app/Controller/LoginController.php index e94fd98..89bb7f6 100644 --- a/app/Controller/LoginController.php +++ b/app/Controller/LoginController.php @@ -2,7 +2,7 @@ namespace App\Controller; -use App\Service\Admin\LoginService; +use App\Service\Admin\AdminLoginService; use Hyperf\Apidog\Annotation\ApiController; use Hyperf\Apidog\Annotation\ApiResponse; use Hyperf\Apidog\Annotation\Body; @@ -25,7 +25,7 @@ class LoginController extends Controller /** * @Inject() - * @var LoginService + * @var AdminLoginService */ protected $loginService; diff --git a/app/Service/Admin/LoginService.php b/app/Service/Admin/AdminLoginService.php similarity index 67% rename from app/Service/Admin/LoginService.php rename to app/Service/Admin/AdminLoginService.php index b530749..d27977c 100644 --- a/app/Service/Admin/LoginService.php +++ b/app/Service/Admin/AdminLoginService.php @@ -7,16 +7,15 @@ use App\Model\Admin; use Hyperf\Di\Annotation\Inject; use Lengbin\Auth\IdentityInterface; -use Lengbin\Auth\IdentityRepositoryInterface; use Lengbin\Helper\Util\PasswordHelper; -use Lengbin\Helper\YiiSoft\Arrays\ArrayHelper; use Lengbin\Helper\YiiSoft\StringHelper; use Lengbin\Hyperf\Common\Exception\BusinessException; use Lengbin\Hyperf\Common\Framework\BaseService; use Lengbin\Jwt\JwtInterface; -class LoginService extends BaseService implements IdentityRepositoryInterface +class AdminLoginService extends BaseService { + /** * @Inject() * @var JwtInterface @@ -24,48 +23,29 @@ class LoginService extends BaseService implements IdentityRepositoryInterface protected $jwt; /** - * @param string $id + * check status * - * @return IdentityInterface|null + * @param $admin */ - public function findIdentity(string $id): ?IdentityInterface + protected function checkAdminStatus($admin): void { - return Admin::findOne('admin_id', $id); + if (StringHelper::isEmpty($admin) || $admin->status === AdminStatus::FROZEN) { + throw new BusinessException(AdminError::ERROR_ADMIN_FREEZE); + } } /** - * Finds an identity by the given token. - * - * @param string $token the token to be looked for - * @param string $type the type of the token. The value of this parameter depends on the implementation and should - * allow supporting multiple token types for a single identity. + * @param array $params * - * @return IdentityInterface|null the identity object that matches the given token. - * Null should be returned if such an identity cannot be found - * or the identity is not in an active state (disabled, deleted, etc.) + * @return Admin */ - public function findIdentityByToken(string $token, string $type): ?IdentityInterface + public function findIdentity(array $params): IdentityInterface { - $data = $this->jwt->verifyToken($token); - if (!ArrayHelper::isValidValue($data, 'admin_id')) { - return null; - } - $admin = $this->findIdentity($data['admin_id']); + $admin = Admin::findOneCondition($params); $this->checkAdminStatus($admin); return $admin; } - /** - * check status - * @param $admin - */ - protected function checkAdminStatus($admin): void - { - if (StringHelper::isEmpty($admin) || $admin->status === AdminStatus::FROZEN) { - throw new BusinessException(AdminError::ERROR_ADMIN_FREEZE); - } - } - /** * 登录 * @@ -92,6 +72,7 @@ public function login(array $params, string $ip): array $token = $this->jwt->generate([ 'admin_id' => $admin->admin_id, + 'channel' => 'admin', ]); // todo 登录日志 return [ diff --git a/config/autoload/auth.php b/config/autoload/auth.php index d92f01e..e6c1fc1 100644 --- a/config/autoload/auth.php +++ b/config/autoload/auth.php @@ -28,14 +28,15 @@ * ]; */ -use App\Service\Admin\LoginService; +use App\Component\User; +use Lengbin\Auth\Method\HttpHeaderAuth; return [ 'api' => [ // 全局变量 名称 'requestName' => 'api', // 实现类,请实现接口 \Lengbin\Auth\IdentityRepositoryInterface::class - 'identityClass' => LoginService::class, + 'identityClass' => User::class, // 验证器方法,支持 // header: \Lengbin\Auth\Method\HttpHeaderAuth::class //默认接收参数名称:X-Api-Token // query : \Lengbin\Auth\Method\QueryParamAuth::class //默认接收参数名称:access-token @@ -45,7 +46,7 @@ // 如果为 数组 则为 混合验证 // key => val 接收参数名称 => 验证类 'method' => [ - 'token' => \Lengbin\Auth\Method\HttpHeaderAuth::class, + 'token' => HttpHeaderAuth::class, // \Lengbin\Auth\Method\QueryParamAuth::class, ], //路由白名单。列如 /test/{id}, 可以使用*来通配, /test/* From f1d7b4dc39054168f444a2f93a5d69f8c8e205a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Wed, 25 Nov 2020 22:32:36 +0800 Subject: [PATCH 25/82] AntDesign demo test --- app/Component/AntDesign/Column.php | 268 ++++++++++++++++++ app/Component/AntDesign/Errors/TableError.php | 28 ++ app/Component/AntDesign/Form.php | 10 + app/Component/AntDesign/Link.php | 27 ++ app/Component/AntDesign/Table.php | 65 +++++ app/Component/AntDesign/Table/Config.php | 39 +++ app/Component/AntDesign/Table/Pagination.php | 13 + .../AntDesign/Table/RowSelection.php | 25 ++ app/Component/AntDesign/Table/Search.php | 54 ++++ app/Constant/Error.php | 20 ++ app/Controller/TestController.php | 60 ++++ app/Service/Admin/AdminService.php | 16 ++ config/autoload/errorCode.php | 1 + 13 files changed, 626 insertions(+) create mode 100644 app/Component/AntDesign/Column.php create mode 100644 app/Component/AntDesign/Errors/TableError.php create mode 100644 app/Component/AntDesign/Form.php create mode 100644 app/Component/AntDesign/Link.php create mode 100644 app/Component/AntDesign/Table.php create mode 100644 app/Component/AntDesign/Table/Config.php create mode 100644 app/Component/AntDesign/Table/Pagination.php create mode 100644 app/Component/AntDesign/Table/RowSelection.php create mode 100644 app/Component/AntDesign/Table/Search.php create mode 100644 app/Controller/TestController.php create mode 100644 app/Service/Admin/AdminService.php diff --git a/app/Component/AntDesign/Column.php b/app/Component/AntDesign/Column.php new file mode 100644 index 0000000..3175f80 --- /dev/null +++ b/app/Component/AntDesign/Column.php @@ -0,0 +1,268 @@ +操作a, 操作b] + 'text', //默认值,不做任何处理 - + 'select', //选择 - + 'textarea', //与 text 相同, form 转化时会转为 textarea 组件 - + 'index', //序号列 - + 'indexBorder', //带 border 的序号列 - + 'progress', //进度条 - + 'digit', //格式化数字展示,form 转化时会转为 inputNumber - + 'percent', //百分比 + 1.12 + 'code', //代码块 const a = b + 'avatar', //头像 展示一个头像 + 'password', //密码框 密码相关的展示 + ]; + + public function init() + { + parent::init(); + if (!in_array($this->getValueType(), $this->valueTypeAllows)) { + throw new BusinessException(TableError::ERROR_ANTDESIGN_COLUMN_VALUETYPE_NOT_SUPPORT); + } + } + + /** + * @return mixed + */ + public function getValueEnum() + { + return is_array($this->valueEnum) ? new stdClass() : $this->valueEnum; + } + + /** + * @param array $valueEnum + * + * @return Column + */ + public function setValueEnum(array $valueEnum): Column + { + $this->valueEnum = $valueEnum; + return $this; + } + + /** + * @return bool + */ + public function getCopyable(): bool + { + return $this->copyable; + } + + /** + * @param bool $copyable + * + * @return Column + */ + public function setCopyable(bool $copyable): Column + { + $this->copyable = $copyable; + return $this; + } + + /** + * @return bool + */ + public function getEllipsis(): bool + { + return $this->ellipsis; + } + + /** + * @param bool $ellipsis + * + * @return Column + */ + public function setEllipsis(bool $ellipsis): Column + { + $this->ellipsis = $ellipsis; + return $this; + } + + /** + * @return bool + */ + public function getSearch(): bool + { + return $this->search; + } + + /** + * @param bool $search + * + * @return Column + */ + public function setSearch(bool $search): Column + { + $this->search = $search; + return $this; + } + + /** + * @return string + */ + public function getValueType(): string + { + return $this->valueType; + } + + /** + * @param string $valueType + * + * @return Column + */ + public function setValueType(string $valueType): Column + { + $this->valueType = $valueType; + return $this; + } + + /** + * @return bool + */ + public function getFilters(): bool + { + return $this->filters; + } + + /** + * @param bool $filters + * + * @return Column + */ + public function setFilters(bool $filters): Column + { + $this->filters = $filters; + return $this; + } + + /** + * @return string + */ + public function getDataIndex(): string + { + return $this->dataIndex; + } + + /** + * @param string $dataIndex + * + * @return Column + */ + public function setDataIndex(string $dataIndex): Column + { + $this->dataIndex = $dataIndex; + return $this; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $title + * + * @return Column + */ + public function setTitle(string $title): Column + { + $this->title = $title; + return $this; + } + + /** + * @return string|null + */ + public function getTip(): ?string + { + return $this->tip; + } + + /** + * @param string|null $tip + * + * @return Column + */ + public function setTip(?string $tip): Column + { + $this->tip = $tip; + return $this; + } +} diff --git a/app/Component/AntDesign/Errors/TableError.php b/app/Component/AntDesign/Errors/TableError.php new file mode 100644 index 0000000..477f939 --- /dev/null +++ b/app/Component/AntDesign/Errors/TableError.php @@ -0,0 +1,28 @@ +column as $key => $item) { + if (is_string($item)) { + //dataIndex|title + $data = explode('|', $item); + if (count($data) !== 2) { + throw new BusinessException(TableError::ERROR_ANTDESIGN_TABLE_PARAM_ERROR); + } + $item = new Column([ + 'dataIndex' => $data[0], + 'title' => $data[1], + ]); + } elseif (is_array($item)) { + $item = new Column($item); + } elseif ($item instanceof Column) { + + } else { + throw new BusinessException(TableError::ERROR_ANTDESIGN_TABLE_PARAM_ERROR); + } + $this->column[$key] = $item->toArray(); + } + + // TableSearch + if ($this->search === null) { + $this->search = new Search(); + } + + if ($this->config === null) { + $this->config = new Config(); + } + } +} diff --git a/app/Component/AntDesign/Table/Config.php b/app/Component/AntDesign/Table/Config.php new file mode 100644 index 0000000..8109014 --- /dev/null +++ b/app/Component/AntDesign/Table/Config.php @@ -0,0 +1,39 @@ +pagination === null) { + $this->pagination = new Pagination(); + } + } + +} diff --git a/app/Component/AntDesign/Table/Pagination.php b/app/Component/AntDesign/Table/Pagination.php new file mode 100644 index 0000000..0dfa32a --- /dev/null +++ b/app/Component/AntDesign/Table/Pagination.php @@ -0,0 +1,13 @@ +type !== null && !in_array($this->type, $this->typeAllows)) { + throw new BusinessException(TableError::ERROR_ANTDESIGN_TABLE_ROWSELECTION_TYPE_ERROR); + } + } +} diff --git a/app/Component/AntDesign/Table/Search.php b/app/Component/AntDesign/Table/Search.php new file mode 100644 index 0000000..190e29b --- /dev/null +++ b/app/Component/AntDesign/Table/Search.php @@ -0,0 +1,54 @@ +span) && $this->span < 1) || $this->span > 24) { + throw new BusinessException(TableError::ERROR_ANTDESIGN_TABLE_SPAN_RANGE_ERROR); + } + } +} diff --git a/app/Constant/Error.php b/app/Constant/Error.php index 6cef55b..2216226 100644 --- a/app/Constant/Error.php +++ b/app/Constant/Error.php @@ -38,6 +38,26 @@ class Error extends BaseEnum */ const ERROR_COMMENTERRORCODE_INVALID_TOKEN = 'F-000-000-403'; + /** + * @Message("值类型不支持") + */ + const ERROR_TABLEERROR_ERROR_ANTDESIGN_COLUMN_VALUETYPE_NOT_SUPPORT = 'A-001-001-001'; + + /** + * @Message("列表参数错误") + */ + const ERROR_TABLEERROR_ERROR_ANTDESIGN_TABLE_PARAM_ERROR = 'A-001-001-002'; + + /** + * @Message("配置搜索框在该行所占的栅格, 范围 1 - 24") + */ + const ERROR_TABLEERROR_ERROR_ANTDESIGN_TABLE_SPAN_RANGE_ERROR = 'A-001-001-003'; + + /** + * @Message("列选择类型错误") + */ + const ERROR_TABLEERROR_ERROR_ANTDESIGN_TABLE_ROWSELECTION_TYPE_ERROR = 'A-001-001-004'; + /** * @Message("账号被冻结,请联系管理员") */ diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php new file mode 100644 index 0000000..c64c712 --- /dev/null +++ b/app/Controller/TestController.php @@ -0,0 +1,60 @@ +request->inputs(['page', 'pageSize']); + $page = new PageEntity([ + 'page' => !empty($params['page']) ? (int)$params['page'] : 1, + 'pageSize' => !empty($params['pageSize']) ? (int)$params['pageSize'] : 2, + ]); + $list = $this->adminService->getList([], ['admin_id', 'nickname'], $page); + return $this->success($list); + } + + /** + * @GetMapping(path="/init") + * + * @return mixed + */ + public function init() + { + $table = new Table([ + 'column' => [ + 'admin_id|id', + 'nickname|昵称', + ], + ]); + return $this->success($table->toArray()); + } +} diff --git a/app/Service/Admin/AdminService.php b/app/Service/Admin/AdminService.php new file mode 100644 index 0000000..570e419 --- /dev/null +++ b/app/Service/Admin/AdminService.php @@ -0,0 +1,16 @@ +page($query, $pageEntity) : $query->get()->all(); + } +} diff --git a/config/autoload/errorCode.php b/config/autoload/errorCode.php index e4708e6..8c7c80e 100644 --- a/config/autoload/errorCode.php +++ b/config/autoload/errorCode.php @@ -4,6 +4,7 @@ // 错误码文件 目录 'path' => [ BASE_PATH . '/vendor/lengbin/hyperf-common/src/Error', + BASE_PATH . '/app/Component/AntDesign/Errors', BASE_PATH . '/app/Constant/Errors', ], // 合并生成 类 文件名称 From 7c0125bab1dd00b467682d9174d5f998ea460240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Mon, 30 Nov 2020 00:36:37 +0800 Subject: [PATCH 26/82] =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=AE=9A=E4=B9=89=20Co?= =?UTF-8?q?lunn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AntDesign/{ => Column}/Column.php | 214 +++++++++++++----- .../AntDesign/Column/ValueEnumType.php | 60 +++++ .../Constant/Column/ValueEnumTypeStatus.php | 33 +++ .../AntDesign/Constant/Column/ValueType.php | 140 ++++++++++++ .../AntDesign/Errors/ColumnError.php | 13 ++ app/Component/AntDesign/Errors/TableError.php | 11 +- app/Component/AntDesign/Table.php | 1 + 7 files changed, 406 insertions(+), 66 deletions(-) rename app/Component/AntDesign/{ => Column}/Column.php (51%) create mode 100644 app/Component/AntDesign/Column/ValueEnumType.php create mode 100644 app/Component/AntDesign/Constant/Column/ValueEnumTypeStatus.php create mode 100644 app/Component/AntDesign/Constant/Column/ValueType.php create mode 100644 app/Component/AntDesign/Errors/ColumnError.php diff --git a/app/Component/AntDesign/Column.php b/app/Component/AntDesign/Column/Column.php similarity index 51% rename from app/Component/AntDesign/Column.php rename to app/Component/AntDesign/Column/Column.php index 3175f80..c7c46e6 100644 --- a/app/Component/AntDesign/Column.php +++ b/app/Component/AntDesign/Column/Column.php @@ -1,12 +1,15 @@ 操作a, 操作b] - 'text', //默认值,不做任何处理 - - 'select', //选择 - - 'textarea', //与 text 相同, form 转化时会转为 textarea 组件 - - 'index', //序号列 - - 'indexBorder', //带 border 的序号列 - - 'progress', //进度条 - - 'digit', //格式化数字展示,form 转化时会转为 inputNumber - - 'percent', //百分比 + 1.12 - 'code', //代码块 const a = b - 'avatar', //头像 展示一个头像 - 'password', //密码框 密码相关的展示 - ]; - - public function init() - { - parent::init(); - if (!in_array($this->getValueType(), $this->valueTypeAllows)) { - throw new BusinessException(TableError::ERROR_ANTDESIGN_COLUMN_VALUETYPE_NOT_SUPPORT); - } - } + * @var array + * @see valueType + */ + private $valueEnum; + + /** + * 会在 title 之后展示一个 icon,hover 之后提示一些信息 + * @var string + */ + private $tooltip; + + /** + * 宽度 + * @var string + */ + private $width; + + /** + * 在查询表单中不展示此项 + * @var bool + */ + private $hideInSearch; + + /** + * 在 Table 中不展示此列 + * @var bool + */ + private $hideInTable; + + /** + * valueType为 select | radio | radioButton | checkbox 时可设置在表单搜索时的默认值 + * select |checkbox 为数组 ['string'],单选为 string + * @var string | array + */ + private $initialValue; /** - * @return mixed + * @return array */ - public function getValueEnum() + public function getValueEnum(): array { - return is_array($this->valueEnum) ? new stdClass() : $this->valueEnum; + return $this->valueEnum; } /** @@ -248,21 +251,116 @@ public function setTitle(string $title): Column } /** - * @return string|null + * @return string + */ + public function getKey(): string + { + return $this->key; + } + + /** + * @param string $key + * + * @return Column + */ + public function setKey(string $key): Column + { + $this->key = $key; + return $this; + } + + /** + * @return string + */ + public function getTooltip(): string + { + return $this->tooltip; + } + + /** + * @param string $tooltip + * + * @return Column + */ + public function setTooltip(string $tooltip): Column + { + $this->tooltip = $tooltip; + return $this; + } + + /** + * @return string + */ + public function getWidth(): string + { + return $this->width; + } + + /** + * @param string $width + * + * @return Column + */ + public function setWidth(string $width): Column + { + $this->width = $width; + return $this; + } + + /** + * @return bool + */ + public function isHideInSearch(): bool + { + return $this->hideInSearch; + } + + /** + * @param bool $hideInSearch + * + * @return Column + */ + public function setHideInSearch(bool $hideInSearch): Column + { + $this->hideInSearch = $hideInSearch; + return $this; + } + + /** + * @return bool + */ + public function isHideInTable(): bool + { + return $this->hideInTable; + } + + /** + * @param bool $hideInTable + * + * @return Column + */ + public function setHideInTable(bool $hideInTable): Column + { + $this->hideInTable = $hideInTable; + return $this; + } + + /** + * @return array|string */ - public function getTip(): ?string + public function getInitialValue() { - return $this->tip; + return $this->initialValue; } /** - * @param string|null $tip + * @param array|string $initialValue * * @return Column */ - public function setTip(?string $tip): Column + public function setInitialValue($initialValue): Column { - $this->tip = $tip; + $this->initialValue = $initialValue; return $this; } } diff --git a/app/Component/AntDesign/Column/ValueEnumType.php b/app/Component/AntDesign/Column/ValueEnumType.php new file mode 100644 index 0000000..11365d5 --- /dev/null +++ b/app/Component/AntDesign/Column/ValueEnumType.php @@ -0,0 +1,60 @@ +text; + } + + /** + * @param string $text + * + * @return ValueEnumType + */ + public function setText(string $text): ValueEnumType + { + $this->text = $text; + return $this; + } + + /** + * @return ValueEnumTypeStatus + */ + public function getStatus(): ValueEnumTypeStatus + { + return $this->status; + } + + /** + * @param ValueEnumTypeStatus $status + * + * @return ValueEnumType + */ + public function setStatus(ValueEnumTypeStatus $status): ValueEnumType + { + $this->status = $status; + return $this; + } + +} diff --git a/app/Component/AntDesign/Constant/Column/ValueEnumTypeStatus.php b/app/Component/AntDesign/Constant/Column/ValueEnumTypeStatus.php new file mode 100644 index 0000000..da3bed7 --- /dev/null +++ b/app/Component/AntDesign/Constant/Column/ValueEnumTypeStatus.php @@ -0,0 +1,33 @@ +操作a, 操作b] + * @Message("操作项") + */ + public const OPTION = 'option'; + + /** + * 选择 配合 Column::valueEnum + * @Message("选择") + */ + public const SELECT = 'select'; + + /** + * 与 text 相同, form 转化时会转为 textarea 组件 + * @Message("文本域") + */ + public const TEXTAREA = 'textarea'; + + /** + * 序号列 + * @Message("序号列") + */ + public const INDEX = 'index'; + + /** + * 带 border 的序号列 + * @Message("带 border 的序号列") + */ + public const INDEX_BORDER = 'indexBorder'; + + /** + * 进度条 + * @Message("进度条") + */ + public const PROGRESS = 'progress'; + + /** + * 格式化数字展示,form 转化时会转为 inputNumber + * @Message("格式化数字展示") + */ + public const DIGIT = 'digit'; + + /** + * 百分比 + * @Message("百分比") + */ + public const PERCENT = 'percent'; + + /** + * 代码块 + * @Message("代码块") + */ + public const CODE = 'code'; + + /** + * 密码相关的展示 + * @Message("密码框") + */ + public const PASSWORD = 'password'; + + /** + * 展示一个头像 + * @Message("头像") + */ + public const AVATAR = 'avatar'; + + /** + * 单选 + * @Message("单选") + */ + public const RADIO = 'radio'; + + /** + * 按钮形式单选 + * @Message("按钮形式单选") + */ + public const RADIO_BUTTON = 'radioButton'; + + /** + * 单选 + * @Message("多选") + */ + public const CHECKBOX = 'checkbox'; + +} diff --git a/app/Component/AntDesign/Errors/ColumnError.php b/app/Component/AntDesign/Errors/ColumnError.php new file mode 100644 index 0000000..f70082a --- /dev/null +++ b/app/Component/AntDesign/Errors/ColumnError.php @@ -0,0 +1,13 @@ + Date: Mon, 30 Nov 2020 23:28:09 +0800 Subject: [PATCH 27/82] =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=AE=9A=E4=B9=89=20Co?= =?UTF-8?q?lunn=202.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/AntDesign/Column/BaseColumn.php | 403 ++++++++++++++++++ app/Component/AntDesign/Column/Column.php | 364 +--------------- .../AntDesign/Column/ProgressType.php | 21 + app/Component/AntDesign/Column/Search.php | 14 + app/Component/AntDesign/Column/ValueEnum.php | 80 ++++ .../AntDesign/Column/ValueEnumType.php | 2 +- .../Constant/Status/ProgressTypeStatus.php | 28 ++ .../ValueEnumTypeStatus.php | 2 +- .../Constant/{Column => Type}/ValueType.php | 2 +- app/Component/AntDesign/Table.php | 8 +- 10 files changed, 559 insertions(+), 365 deletions(-) create mode 100644 app/Component/AntDesign/Column/BaseColumn.php create mode 100644 app/Component/AntDesign/Column/ProgressType.php create mode 100644 app/Component/AntDesign/Column/Search.php create mode 100644 app/Component/AntDesign/Column/ValueEnum.php create mode 100644 app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php rename app/Component/AntDesign/Constant/{Column => Status}/ValueEnumTypeStatus.php (90%) rename app/Component/AntDesign/Constant/{Column => Type}/ValueType.php (98%) diff --git a/app/Component/AntDesign/Column/BaseColumn.php b/app/Component/AntDesign/Column/BaseColumn.php new file mode 100644 index 0000000..a4de989 --- /dev/null +++ b/app/Component/AntDesign/Column/BaseColumn.php @@ -0,0 +1,403 @@ +copyable; + } + + /** + * @param bool $copyable + * + * @return BaseColumn + */ + public function setCopyable(bool $copyable): BaseColumn + { + $this->copyable = $copyable; + return $this; + } + + /** + * @return bool + */ + public function getEllipsis(): bool + { + return $this->ellipsis; + } + + /** + * @param bool $ellipsis + * + * @return BaseColumn + */ + public function setEllipsis(bool $ellipsis): BaseColumn + { + $this->ellipsis = $ellipsis; + return $this; + } + + /** + * @return bool + */ + public function getSearch(): bool + { + return $this->search; + } + + /** + * @param bool $search + * + * @return BaseColumn + */ + public function setSearch(bool $search): BaseColumn + { + $this->search = $search; + return $this; + } + + /** + * @return string + */ + public function getValueType(): string + { + return $this->valueType; + } + + /** + * @param string $valueType + * + * @return BaseColumn + */ + public function setValueType(string $valueType): BaseColumn + { + $this->valueType = $valueType; + return $this; + } + + /** + * @return bool + */ + public function getFilters(): bool + { + return $this->filters; + } + + /** + * @param bool $filters + * + * @return BaseColumn + */ + public function setFilters(bool $filters): BaseColumn + { + $this->filters = $filters; + return $this; + } + + /** + * @return string + */ + public function getDataIndex(): string + { + return $this->dataIndex; + } + + /** + * @param string $dataIndex + * + * @return BaseColumn + */ + public function setDataIndex(string $dataIndex): BaseColumn + { + $this->dataIndex = $dataIndex; + return $this; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $title + * + * @return BaseColumn + */ + public function setTitle(string $title): BaseColumn + { + $this->title = $title; + return $this; + } + + /** + * @return string + */ + public function getKey(): string + { + return $this->key; + } + + /** + * @param string $key + * + * @return BaseColumn + */ + public function setKey(string $key): BaseColumn + { + $this->key = $key; + return $this; + } + + /** + * @return string + */ + public function getTooltip(): string + { + return $this->tooltip; + } + + /** + * @param string $tooltip + * + * @return BaseColumn + */ + public function setTooltip(string $tooltip): BaseColumn + { + $this->tooltip = $tooltip; + return $this; + } + + /** + * @return string + */ + public function getWidth(): string + { + return $this->width; + } + + /** + * @param string $width + * + * @return BaseColumn + */ + public function setWidth(string $width): BaseColumn + { + $this->width = $width; + return $this; + } + + /** + * @return bool + */ + public function isHideInSearch(): bool + { + return $this->hideInSearch; + } + + /** + * @param bool $hideInSearch + * + * @return BaseColumn + */ + public function setHideInSearch(bool $hideInSearch): BaseColumn + { + $this->hideInSearch = $hideInSearch; + return $this; + } + + /** + * @return bool + */ + public function isHideInTable(): bool + { + return $this->hideInTable; + } + + /** + * @param bool $hideInTable + * + * @return BaseColumn + */ + public function setHideInTable(bool $hideInTable): BaseColumn + { + $this->hideInTable = $hideInTable; + return $this; + } + + /** + * @return array|string + */ + public function getInitialValue() + { + return $this->initialValue; + } + + /** + * @param array|string $initialValue + * + * @return BaseColumn + */ + public function setInitialValue($initialValue): BaseColumn + { + $this->initialValue = $initialValue; + return $this; + } + + /** + * @return array + */ + public function getValueEnum(): array + { + return $this->valueEnum; + } + + /** + * @param ValueEnum[] $valueEnum + * + * @return BaseColumn + */ + public function setValueEnum(array $valueEnum): BaseColumn + { + $this->valueEnum = $valueEnum; + return $this; + } + + public function init() + { + if ($this->valueType->getValue() === ValueType::PROGRESS) { + $progress = []; + foreach ($this->getValueEnum() as $item) { + $progress[$item->getKey()] = [ + 'text' => $item->getValue(), + 'status' => $item->getStatus() !== '' ? ProgressTypeStatus::byValue($item->getStatus())->getValue() : $item->getStatus(), + ]; + } + $this->valueEnum = $progress; + } + + if (in_array($this->valueType->getValue(), [ + ValueType::SELECT, + ValueType::CHECKBOX, + ValueType::RADIO, + ValueType::RADIO_BUTTON, + ], true)) { + $drops = []; + foreach ($this->getValueEnum() as $item) { + $drops[$item->getKey()] = [ + 'text' => $item->getValue(), + 'status' => $item->getStatus() !== '' ? ValueEnumTypeStatus::byValue($item->getStatus())->getValue() : $item->getStatus(), + ]; + } + $this->valueEnum = $drops; + + $initValue = $this->getInitialValue(); + if (in_array($this->valueType->getValue(), [ValueType::SELECT, ValueType::CHECKBOX,], true) && !is_array($initValue)) { + $this->setInitialValue([$initValue]); + } + } + } +} diff --git a/app/Component/AntDesign/Column/Column.php b/app/Component/AntDesign/Column/Column.php index c7c46e6..a33ee25 100644 --- a/app/Component/AntDesign/Column/Column.php +++ b/app/Component/AntDesign/Column/Column.php @@ -2,365 +2,13 @@ namespace App\Component\AntDesign\Column; -use App\Component\AntDesign\Constant\Column\ValueType; -use Lengbin\Common\Component\BaseObject; - -/** - * Class Column - * @package App\Component\AntDesign - * @document https://github.com/coderlfm/CMS - */ -class Column extends BaseObject +class Column extends BaseColumn { - /** - * 后端返回数据key - * @var string - */ - private $dataIndex; - - /** - * 表格/表单标题名 - * @var string - */ - private $title; - - /** - * 搜索时请求服务器的key名 - * @var string - */ - private $key; - - /** - * 是否拷贝 - * @var bool - */ - private $copyable; - - /** - * 超出换行 - * @var bool - */ - private $ellipsis; - - /** - * 是否展示在搜索框,默认值true - * @var bool - */ - private $search; - - /** - * 值类型, 默认值text - * @var ValueType - */ - private $valueType; - - /** - * 表头筛选项,默认值 true 当值为 true 时, 自动使用 valueEnum 生成 类型: boolean | object[] - * @var bool - */ - private $filters; - - /** - * 当前列值的枚举 - * @var array - * @see valueType - */ - private $valueEnum; - - /** - * 会在 title 之后展示一个 icon,hover 之后提示一些信息 - * @var string - */ - private $tooltip; - - /** - * 宽度 - * @var string - */ - private $width; - - /** - * 在查询表单中不展示此项 - * @var bool - */ - private $hideInSearch; - - /** - * 在 Table 中不展示此列 - * @var bool - */ - private $hideInTable; - - /** - * valueType为 select | radio | radioButton | checkbox 时可设置在表单搜索时的默认值 - * select |checkbox 为数组 ['string'],单选为 string - * @var string | array - */ - private $initialValue; - - /** - * @return array - */ - public function getValueEnum(): array - { - return $this->valueEnum; - } - - /** - * @param array $valueEnum - * - * @return Column - */ - public function setValueEnum(array $valueEnum): Column - { - $this->valueEnum = $valueEnum; - return $this; - } - - /** - * @return bool - */ - public function getCopyable(): bool - { - return $this->copyable; - } - - /** - * @param bool $copyable - * - * @return Column - */ - public function setCopyable(bool $copyable): Column - { - $this->copyable = $copyable; - return $this; - } - - /** - * @return bool - */ - public function getEllipsis(): bool - { - return $this->ellipsis; - } - - /** - * @param bool $ellipsis - * - * @return Column - */ - public function setEllipsis(bool $ellipsis): Column - { - $this->ellipsis = $ellipsis; - return $this; - } - - /** - * @return bool - */ - public function getSearch(): bool - { - return $this->search; - } - - /** - * @param bool $search - * - * @return Column - */ - public function setSearch(bool $search): Column - { - $this->search = $search; - return $this; - } - - /** - * @return string - */ - public function getValueType(): string - { - return $this->valueType; - } - - /** - * @param string $valueType - * - * @return Column - */ - public function setValueType(string $valueType): Column - { - $this->valueType = $valueType; - return $this; - } - - /** - * @return bool - */ - public function getFilters(): bool - { - return $this->filters; - } - - /** - * @param bool $filters - * - * @return Column - */ - public function setFilters(bool $filters): Column - { - $this->filters = $filters; - return $this; - } - - /** - * @return string - */ - public function getDataIndex(): string - { - return $this->dataIndex; - } - - /** - * @param string $dataIndex - * - * @return Column - */ - public function setDataIndex(string $dataIndex): Column - { - $this->dataIndex = $dataIndex; - return $this; - } - - /** - * @return string - */ - public function getTitle(): string - { - return $this->title; - } - - /** - * @param string $title - * - * @return Column - */ - public function setTitle(string $title): Column - { - $this->title = $title; - return $this; - } - - /** - * @return string - */ - public function getKey(): string - { - return $this->key; - } - - /** - * @param string $key - * - * @return Column - */ - public function setKey(string $key): Column - { - $this->key = $key; - return $this; - } - - /** - * @return string - */ - public function getTooltip(): string - { - return $this->tooltip; - } - - /** - * @param string $tooltip - * - * @return Column - */ - public function setTooltip(string $tooltip): Column - { - $this->tooltip = $tooltip; - return $this; - } - - /** - * @return string - */ - public function getWidth(): string - { - return $this->width; - } - - /** - * @param string $width - * - * @return Column - */ - public function setWidth(string $width): Column - { - $this->width = $width; - return $this; - } - - /** - * @return bool - */ - public function isHideInSearch(): bool - { - return $this->hideInSearch; - } - - /** - * @param bool $hideInSearch - * - * @return Column - */ - public function setHideInSearch(bool $hideInSearch): Column - { - $this->hideInSearch = $hideInSearch; - return $this; - } - - /** - * @return bool - */ - public function isHideInTable(): bool - { - return $this->hideInTable; - } - - /** - * @param bool $hideInTable - * - * @return Column - */ - public function setHideInTable(bool $hideInTable): Column - { - $this->hideInTable = $hideInTable; - return $this; - } - - /** - * @return array|string - */ - public function getInitialValue() - { - return $this->initialValue; - } - - /** - * @param array|string $initialValue - * - * @return Column - */ - public function setInitialValue($initialValue): Column + public function init() { - $this->initialValue = $initialValue; - return $this; + parent::init(); + $this->setSearch(false); + $this->setHideInSearch(true); + $this->setHideInTable(false); } } diff --git a/app/Component/AntDesign/Column/ProgressType.php b/app/Component/AntDesign/Column/ProgressType.php new file mode 100644 index 0000000..5f99618 --- /dev/null +++ b/app/Component/AntDesign/Column/ProgressType.php @@ -0,0 +1,21 @@ +setSearch(true); + $this->setHideInSearch(false); + $this->setHideInTable(true); + } +} diff --git a/app/Component/AntDesign/Column/ValueEnum.php b/app/Component/AntDesign/Column/ValueEnum.php new file mode 100644 index 0000000..cdfe8a2 --- /dev/null +++ b/app/Component/AntDesign/Column/ValueEnum.php @@ -0,0 +1,80 @@ +key; + } + + /** + * @param mixed $key + * + * @return ValueEnum + */ + public function setKey($key) + { + $this->key = $key; + return $this; + } + + /** + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * @param mixed $value + * + * @return ValueEnum + */ + public function setValue($value) + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function getStatus(): string + { + return $this->status; + } + + /** + * @param string $status + * + * @return ValueEnum + */ + public function setStatus(string $status): ValueEnum + { + $this->status = $status; + return $this; + } +} diff --git a/app/Component/AntDesign/Column/ValueEnumType.php b/app/Component/AntDesign/Column/ValueEnumType.php index 11365d5..45bfe59 100644 --- a/app/Component/AntDesign/Column/ValueEnumType.php +++ b/app/Component/AntDesign/Column/ValueEnumType.php @@ -2,7 +2,7 @@ namespace App\Component\AntDesign\Column; -use App\Component\AntDesign\Constant\Column\ValueEnumTypeStatus; +use App\Component\AntDesign\Constant\Status\ValueEnumTypeStatus; use Lengbin\Common\Component\BaseObject; class ValueEnumType extends BaseObject diff --git a/app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php b/app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php new file mode 100644 index 0000000..a45d450 --- /dev/null +++ b/app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php @@ -0,0 +1,28 @@ + $data[0], 'title' => $data[1], ]); } elseif (is_array($item)) { - $item = new Column($item); - } elseif ($item instanceof Column) { + $item = new BaseColumn($item); + } elseif ($item instanceof BaseColumn) { } else { throw new BusinessException(TableError::ERROR_ANTDESIGN_TABLE_PARAM_ERROR); From 14dcdad918bf62f681744a6b5e3de1e141bc27d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Mon, 30 Nov 2020 23:43:10 +0800 Subject: [PATCH 28/82] =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=AE=9A=E4=B9=89=20Co?= =?UTF-8?q?lunn=202.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/AntDesign/Column/BaseColumn.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Component/AntDesign/Column/BaseColumn.php b/app/Component/AntDesign/Column/BaseColumn.php index a4de989..45c819b 100644 --- a/app/Component/AntDesign/Column/BaseColumn.php +++ b/app/Component/AntDesign/Column/BaseColumn.php @@ -368,6 +368,9 @@ public function setValueEnum(array $valueEnum): BaseColumn public function init() { + // 必填项验证 + + // 进度条 if ($this->valueType->getValue() === ValueType::PROGRESS) { $progress = []; foreach ($this->getValueEnum() as $item) { @@ -379,6 +382,7 @@ public function init() $this->valueEnum = $progress; } + // 具有 drop 属性 if (in_array($this->valueType->getValue(), [ ValueType::SELECT, ValueType::CHECKBOX, @@ -394,6 +398,7 @@ public function init() } $this->valueEnum = $drops; + // 如果是 select 或者 checkbox 默认为数组 $initValue = $this->getInitialValue(); if (in_array($this->valueType->getValue(), [ValueType::SELECT, ValueType::CHECKBOX,], true) && !is_array($initValue)) { $this->setInitialValue([$initValue]); From dd4d6811a0d97b731282b754f1c5925d04ca61d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Tue, 1 Dec 2020 00:50:31 +0800 Subject: [PATCH 29/82] =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=AE=9A=E4=B9=89=20Co?= =?UTF-8?q?lunn=202.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/AntDesign/Column/BaseColumn.php | 56 +++++++++---------- app/Component/AntDesign/Column/Column.php | 3 +- app/Component/AntDesign/Column/ValueEnum.php | 1 + .../Constant/Status/ProgressTypeStatus.php | 6 ++ .../Constant/Status/ValueEnumTypeStatus.php | 5 ++ .../AntDesign/Constant/Type/ValueType.php | 1 - app/Component/AntDesign/Table.php | 8 ++- app/Constant/Error.php | 8 +-- 8 files changed, 49 insertions(+), 39 deletions(-) diff --git a/app/Component/AntDesign/Column/BaseColumn.php b/app/Component/AntDesign/Column/BaseColumn.php index 45c819b..dd8ee8b 100644 --- a/app/Component/AntDesign/Column/BaseColumn.php +++ b/app/Component/AntDesign/Column/BaseColumn.php @@ -2,15 +2,13 @@ namespace App\Component\AntDesign\Column; -use App\Component\AntDesign\Constant\Status\ProgressTypeStatus; -use App\Component\AntDesign\Constant\Status\ValueEnumTypeStatus; use App\Component\AntDesign\Constant\Type\ValueType; use Lengbin\Common\Component\BaseObject; /** * Class Column * @package App\Component\AntDesign - * @document https://github.com/coderlfm/CMS + * @see https://github.com/coderlfm/CMS */ class BaseColumn extends BaseObject { @@ -18,87 +16,87 @@ class BaseColumn extends BaseObject * 后端返回数据key * @var string */ - private $dataIndex; + protected $dataIndex; /** * 表格/表单标题名 * @var string */ - private $title; + protected $title; /** * 搜索时请求服务器的key名 * @var string */ - private $key; + protected $key; /** * 是否拷贝 * @var bool */ - private $copyable; + protected $copyable; /** * 超出换行 * @var bool */ - private $ellipsis; + protected $ellipsis; /** * 是否展示在搜索框,默认值true * @var bool */ - private $search; + protected $search; /** * 值类型, 默认值text * @var ValueType */ - private $valueType; + protected $valueType; /** * 表头筛选项,默认值 true 当值为 true 时, 自动使用 valueEnum 生成 类型: boolean | object[] * @var bool */ - private $filters; + protected $filters; /** * 当前列值的枚举 * @var ValueEnum[] * @see valueType */ - private $valueEnum; + protected $valueEnum; /** * 会在 title 之后展示一个 icon,hover 之后提示一些信息 * @var string */ - private $tooltip; + protected $tooltip; /** * 宽度 * @var string */ - private $width; + protected $width; /** * 在查询表单中不展示此项 * @var bool */ - private $hideInSearch; + protected $hideInSearch; /** * 在 Table 中不展示此列 * @var bool */ - private $hideInTable; + protected $hideInTable; /** * valueType为 select | radio | radioButton | checkbox 时可设置在表单搜索时的默认值 * select |checkbox 为数组 ['string'],单选为 string - * @var string | array + * @var string|array */ - private $initialValue; + protected $initialValue; /** * @return bool @@ -158,19 +156,19 @@ public function setSearch(bool $search): BaseColumn } /** - * @return string + * @return ValueType */ - public function getValueType(): string + public function getValueType(): ValueType { return $this->valueType; } /** - * @param string $valueType + * @param ValueType $valueType * * @return BaseColumn */ - public function setValueType(string $valueType): BaseColumn + public function setValueType(ValueType $valueType): BaseColumn { $this->valueType = $valueType; return $this; @@ -369,15 +367,15 @@ public function setValueEnum(array $valueEnum): BaseColumn public function init() { // 必填项验证 - + $this->getDataIndex(); // 进度条 if ($this->valueType->getValue() === ValueType::PROGRESS) { $progress = []; foreach ($this->getValueEnum() as $item) { - $progress[$item->getKey()] = [ + $progress[$item->getKey()] = new ProgressType([ 'text' => $item->getValue(), - 'status' => $item->getStatus() !== '' ? ProgressTypeStatus::byValue($item->getStatus())->getValue() : $item->getStatus(), - ]; + 'status' => $item->getStatus(), + ]); } $this->valueEnum = $progress; } @@ -391,10 +389,10 @@ public function init() ], true)) { $drops = []; foreach ($this->getValueEnum() as $item) { - $drops[$item->getKey()] = [ + $drops[$item->getKey()] = new ValueEnumType([ 'text' => $item->getValue(), - 'status' => $item->getStatus() !== '' ? ValueEnumTypeStatus::byValue($item->getStatus())->getValue() : $item->getStatus(), - ]; + 'status' => $item->getStatus(), + ]); } $this->valueEnum = $drops; diff --git a/app/Component/AntDesign/Column/Column.php b/app/Component/AntDesign/Column/Column.php index a33ee25..6129ab0 100644 --- a/app/Component/AntDesign/Column/Column.php +++ b/app/Component/AntDesign/Column/Column.php @@ -6,9 +6,8 @@ class Column extends BaseColumn { public function init() { + // 列 支持 查询,但是不能不显示在table中 parent::init(); - $this->setSearch(false); - $this->setHideInSearch(true); $this->setHideInTable(false); } } diff --git a/app/Component/AntDesign/Column/ValueEnum.php b/app/Component/AntDesign/Column/ValueEnum.php index cdfe8a2..f01e396 100644 --- a/app/Component/AntDesign/Column/ValueEnum.php +++ b/app/Component/AntDesign/Column/ValueEnum.php @@ -17,6 +17,7 @@ class ValueEnum extends BaseObject private $value; /** + * 渲染的状态 * @var string */ private $status = ''; diff --git a/app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php b/app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php index a45d450..a6f853a 100644 --- a/app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php +++ b/app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php @@ -6,6 +6,12 @@ class ProgressTypeStatus extends BaseEnum { + + /** + * @Message("未知") + */ + public const UNKNOWN = ''; + /** * @Message("成功") */ diff --git a/app/Component/AntDesign/Constant/Status/ValueEnumTypeStatus.php b/app/Component/AntDesign/Constant/Status/ValueEnumTypeStatus.php index 0971609..af7ff31 100644 --- a/app/Component/AntDesign/Constant/Status/ValueEnumTypeStatus.php +++ b/app/Component/AntDesign/Constant/Status/ValueEnumTypeStatus.php @@ -6,6 +6,11 @@ class ValueEnumTypeStatus extends BaseEnum { + /** + * @Message("未知") + */ + public const UNKNOWN = ''; + /** * @Message("成功") */ diff --git a/app/Component/AntDesign/Constant/Type/ValueType.php b/app/Component/AntDesign/Constant/Type/ValueType.php index f715c38..7d1672f 100644 --- a/app/Component/AntDesign/Constant/Type/ValueType.php +++ b/app/Component/AntDesign/Constant/Type/ValueType.php @@ -7,7 +7,6 @@ /** * value type * @package App\Component\AntDesign\Column - * @document https://github.com/coderlfm/CMS */ class ValueType extends BaseEnum { diff --git a/app/Component/AntDesign/Table.php b/app/Component/AntDesign/Table.php index d9a7ede..48b6d88 100644 --- a/app/Component/AntDesign/Table.php +++ b/app/Component/AntDesign/Table.php @@ -2,7 +2,8 @@ namespace App\Component\AntDesign; -use App\Component\AntDesign\Column\BaseColumn; +use App\Component\AntDesign\Column\Column; +use App\Component\AntDesign\Constant\Type\ValueType; use App\Component\AntDesign\Errors\TableError; use App\Component\AntDesign\Table\Config; use App\Component\AntDesign\Table\Search; @@ -40,12 +41,13 @@ public function init() if (count($data) !== 2) { throw new BusinessException(TableError::ERROR_ANTDESIGN_TABLE_PARAM_ERROR); } - $item = new BaseColumn([ + $item = new Column([ 'dataIndex' => $data[0], 'title' => $data[1], + 'valueType' => ValueType::TEXT, ]); } elseif (is_array($item)) { - $item = new BaseColumn($item); + $item = new Column($item); } elseif ($item instanceof BaseColumn) { } else { diff --git a/app/Constant/Error.php b/app/Constant/Error.php index 2216226..0b968b5 100644 --- a/app/Constant/Error.php +++ b/app/Constant/Error.php @@ -41,22 +41,22 @@ class Error extends BaseEnum /** * @Message("值类型不支持") */ - const ERROR_TABLEERROR_ERROR_ANTDESIGN_COLUMN_VALUETYPE_NOT_SUPPORT = 'A-001-001-001'; + const ERROR_COLUMNERROR_ERROR_ANTDESIGN_COLUMN_VALUEENUMTYPE_NOT_SUPPORT = 'A-002-001-001'; /** * @Message("列表参数错误") */ - const ERROR_TABLEERROR_ERROR_ANTDESIGN_TABLE_PARAM_ERROR = 'A-001-001-002'; + const ERROR_TABLEERROR_ERROR_ANTDESIGN_TABLE_PARAM_ERROR = 'A-001-001-001'; /** * @Message("配置搜索框在该行所占的栅格, 范围 1 - 24") */ - const ERROR_TABLEERROR_ERROR_ANTDESIGN_TABLE_SPAN_RANGE_ERROR = 'A-001-001-003'; + const ERROR_TABLEERROR_ERROR_ANTDESIGN_TABLE_SPAN_RANGE_ERROR = 'A-001-001-002'; /** * @Message("列选择类型错误") */ - const ERROR_TABLEERROR_ERROR_ANTDESIGN_TABLE_ROWSELECTION_TYPE_ERROR = 'A-001-001-004'; + const ERROR_TABLEERROR_ERROR_ANTDESIGN_TABLE_ROWSELECTION_TYPE_ERROR = 'A-001-001-003'; /** * @Message("账号被冻结,请联系管理员") From 8e87ce58144a944eaa7df52cec032b2bc4e35978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Tue, 1 Dec 2020 01:03:39 +0800 Subject: [PATCH 30/82] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AntDesign/Errors/ColumnError.php | 13 --------- app/Component/AntDesign/Table.php | 29 +++++++++++++------ .../{ => Table}/Column/BaseColumn.php | 2 +- .../AntDesign/{ => Table}/Column/Column.php | 2 +- .../{ => Table}/Column/ProgressType.php | 2 +- .../AntDesign/{ => Table}/Column/Search.php | 2 +- .../{ => Table}/Column/ValueEnum.php | 2 +- .../{ => Table}/Column/ValueEnumType.php | 2 +- .../{Config.php => Config/ColumnConfig.php} | 4 +-- .../Table/{ => Config}/Pagination.php | 2 +- .../Table/{ => Config}/RowSelection.php | 2 +- .../{Search.php => Config/TableConfig.php} | 4 +-- app/Constant/Error.php | 5 ---- 13 files changed, 32 insertions(+), 39 deletions(-) delete mode 100644 app/Component/AntDesign/Errors/ColumnError.php rename app/Component/AntDesign/{ => Table}/Column/BaseColumn.php (99%) rename app/Component/AntDesign/{ => Table}/Column/Column.php (81%) rename app/Component/AntDesign/{ => Table}/Column/ProgressType.php (87%) rename app/Component/AntDesign/{ => Table}/Column/Search.php (81%) rename app/Component/AntDesign/{ => Table}/Column/ValueEnum.php (96%) rename app/Component/AntDesign/{ => Table}/Column/ValueEnumType.php (95%) rename app/Component/AntDesign/Table/{Config.php => Config/ColumnConfig.php} (85%) rename app/Component/AntDesign/Table/{ => Config}/Pagination.php (75%) rename app/Component/AntDesign/Table/{ => Config}/RowSelection.php (92%) rename app/Component/AntDesign/Table/{Search.php => Config/TableConfig.php} (92%) diff --git a/app/Component/AntDesign/Errors/ColumnError.php b/app/Component/AntDesign/Errors/ColumnError.php deleted file mode 100644 index f70082a..0000000 --- a/app/Component/AntDesign/Errors/ColumnError.php +++ /dev/null @@ -1,13 +0,0 @@ -column[$key] = $item->toArray(); } - // TableSearch - if ($this->search === null) { - $this->search = new Search(); + if ($this->tableConfig === null) { + $this->tableConfig = new TableConfig(); } - if ($this->config === null) { - $this->config = new Config(); + if ($this->columnConfig === null) { + $this->columnConfig = new ColumnConfig(); } } } diff --git a/app/Component/AntDesign/Column/BaseColumn.php b/app/Component/AntDesign/Table/Column/BaseColumn.php similarity index 99% rename from app/Component/AntDesign/Column/BaseColumn.php rename to app/Component/AntDesign/Table/Column/BaseColumn.php index dd8ee8b..fb4f675 100644 --- a/app/Component/AntDesign/Column/BaseColumn.php +++ b/app/Component/AntDesign/Table/Column/BaseColumn.php @@ -1,6 +1,6 @@ Date: Tue, 1 Dec 2020 01:31:29 +0800 Subject: [PATCH 31/82] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Constant/Type/RowSelectionType.php | 18 ++ app/Component/AntDesign/Errors/TableError.php | 5 - app/Component/AntDesign/Table.php | 16 +- .../AntDesign/Table/Config/FormConfig.php | 185 ++++++++++++++++++ .../AntDesign/Table/Config/RowSelection.php | 27 ++- .../AntDesign/Table/Config/TableConfig.php | 54 ----- app/Constant/Error.php | 5 - 7 files changed, 224 insertions(+), 86 deletions(-) create mode 100644 app/Component/AntDesign/Constant/Type/RowSelectionType.php create mode 100644 app/Component/AntDesign/Table/Config/FormConfig.php delete mode 100644 app/Component/AntDesign/Table/Config/TableConfig.php diff --git a/app/Component/AntDesign/Constant/Type/RowSelectionType.php b/app/Component/AntDesign/Constant/Type/RowSelectionType.php new file mode 100644 index 0000000..1113762 --- /dev/null +++ b/app/Component/AntDesign/Constant/Type/RowSelectionType.php @@ -0,0 +1,18 @@ +column[$key] = $item->toArray(); } - if ($this->tableConfig === null) { - $this->tableConfig = new TableConfig(); - } - if ($this->columnConfig === null) { $this->columnConfig = new ColumnConfig(); } diff --git a/app/Component/AntDesign/Table/Config/FormConfig.php b/app/Component/AntDesign/Table/Config/FormConfig.php new file mode 100644 index 0000000..20e2fe1 --- /dev/null +++ b/app/Component/AntDesign/Table/Config/FormConfig.php @@ -0,0 +1,185 @@ +searchText; + } + + /** + * @param string $searchText + * + * @return FormConfig + */ + public function setSearchText(string $searchText): FormConfig + { + $this->searchText = $searchText; + return $this; + } + + /** + * @return string + */ + public function getResetText(): string + { + return $this->resetText; + } + + /** + * @param string $resetText + * + * @return FormConfig + */ + public function setResetText(string $resetText): FormConfig + { + $this->resetText = $resetText; + return $this; + } + + /** + * @return string + */ + public function getSubmitText(): string + { + return $this->submitText; + } + + /** + * @param string $submitText + * + * @return FormConfig + */ + public function setSubmitText(string $submitText): FormConfig + { + $this->submitText = $submitText; + return $this; + } + + /** + * @return int|string + */ + public function getLabelWidth() + { + return $this->labelWidth; + } + + /** + * @param int|string $labelWidth + * + * @return FormConfig + */ + public function setLabelWidth($labelWidth) + { + $this->labelWidth = $labelWidth; + return $this; + } + + /** + * @return int + */ + public function getSpan(): int + { + return $this->span; + } + + /** + * @param int $span + * + * @return FormConfig + */ + public function setSpan(int $span): FormConfig + { + $this->span = $span; + return $this; + } + + /** + * @return bool + */ + public function isDefaultCollapsed(): bool + { + return $this->defaultCollapsed; + } + + /** + * @param bool $defaultCollapsed + * + * @return FormConfig + */ + public function setDefaultCollapsed(bool $defaultCollapsed): FormConfig + { + $this->defaultCollapsed = $defaultCollapsed; + return $this; + } + + /** + * @return bool + */ + public function isCollapsed(): bool + { + return $this->collapsed; + } + + /** + * @param bool $collapsed + * + * @return FormConfig + */ + public function setCollapsed(bool $collapsed): FormConfig + { + $this->collapsed = $collapsed; + return $this; + } +} diff --git a/app/Component/AntDesign/Table/Config/RowSelection.php b/app/Component/AntDesign/Table/Config/RowSelection.php index 1cd027b..3ebc426 100644 --- a/app/Component/AntDesign/Table/Config/RowSelection.php +++ b/app/Component/AntDesign/Table/Config/RowSelection.php @@ -2,24 +2,33 @@ namespace App\Component\AntDesign\Table\Config; -use App\Component\AntDesign\Errors\TableError; +use App\Component\AntDesign\Constant\Type\RowSelectionType; use Lengbin\Common\Component\BaseObject; -use Lengbin\Hyperf\Common\Exception\BusinessException; class RowSelection extends BaseObject { /** * 列选择 类型 - * @var string + * @var RowSelectionType */ - public $type; + private $type; - private $typeAllows = ['radio', 'checkbox']; + /** + * @return RowSelectionType + */ + public function getType(): RowSelectionType + { + return $this->type; + } - public function init() + /** + * @param RowSelectionType $type + * + * @return RowSelection + */ + public function setType(RowSelectionType $type): RowSelection { - if ($this->type !== null && !in_array($this->type, $this->typeAllows)) { - throw new BusinessException(TableError::ERROR_ANTDESIGN_TABLE_ROWSELECTION_TYPE_ERROR); - } + $this->type = $type; + return $this; } } diff --git a/app/Component/AntDesign/Table/Config/TableConfig.php b/app/Component/AntDesign/Table/Config/TableConfig.php deleted file mode 100644 index 9b08868..0000000 --- a/app/Component/AntDesign/Table/Config/TableConfig.php +++ /dev/null @@ -1,54 +0,0 @@ -span) && $this->span < 1) || $this->span > 24) { - throw new BusinessException(TableError::ERROR_ANTDESIGN_TABLE_SPAN_RANGE_ERROR); - } - } -} diff --git a/app/Constant/Error.php b/app/Constant/Error.php index d7dfab0..977f352 100644 --- a/app/Constant/Error.php +++ b/app/Constant/Error.php @@ -43,11 +43,6 @@ class Error extends BaseEnum */ const ERROR_TABLEERROR_ERROR_ANTDESIGN_TABLE_PARAM_ERROR = 'A-001-001-001'; - /** - * @Message("配置搜索框在该行所占的栅格, 范围 1 - 24") - */ - const ERROR_TABLEERROR_ERROR_ANTDESIGN_TABLE_SPAN_RANGE_ERROR = 'A-001-001-002'; - /** * @Message("列选择类型错误") */ From cf3cb10e314b5b77d7af2e67a8b685bfd6c0064d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Tue, 1 Dec 2020 15:52:06 +0800 Subject: [PATCH 32/82] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AntDesign/{Table => }/Column/BaseColumn.php | 2 +- app/Component/AntDesign/{Table => }/Column/Column.php | 2 +- .../AntDesign/{Table => }/Column/ProgressType.php | 2 +- app/Component/AntDesign/{Table => }/Column/Search.php | 2 +- .../AntDesign/{Table => }/Column/ValueEnum.php | 2 +- .../AntDesign/{Table => }/Column/ValueEnumType.php | 2 +- .../AntDesign/{Table => }/Config/ColumnConfig.php | 2 +- .../AntDesign/{Table => }/Config/FormConfig.php | 4 +--- .../AntDesign/{Table => }/Config/Pagination.php | 2 +- .../AntDesign/{Table => }/Config/RowSelection.php | 2 +- app/Component/AntDesign/{ => Form}/Form.php | 2 +- app/Component/AntDesign/Table.php | 11 +++++++---- 12 files changed, 18 insertions(+), 17 deletions(-) rename app/Component/AntDesign/{Table => }/Column/BaseColumn.php (99%) rename app/Component/AntDesign/{Table => }/Column/Column.php (81%) rename app/Component/AntDesign/{Table => }/Column/ProgressType.php (87%) rename app/Component/AntDesign/{Table => }/Column/Search.php (81%) rename app/Component/AntDesign/{Table => }/Column/ValueEnum.php (96%) rename app/Component/AntDesign/{Table => }/Column/ValueEnumType.php (95%) rename app/Component/AntDesign/{Table => }/Config/ColumnConfig.php (91%) rename app/Component/AntDesign/{Table => }/Config/FormConfig.php (95%) rename app/Component/AntDesign/{Table => }/Config/Pagination.php (75%) rename app/Component/AntDesign/{Table => }/Config/RowSelection.php (92%) rename app/Component/AntDesign/{ => Form}/Form.php (68%) diff --git a/app/Component/AntDesign/Table/Column/BaseColumn.php b/app/Component/AntDesign/Column/BaseColumn.php similarity index 99% rename from app/Component/AntDesign/Table/Column/BaseColumn.php rename to app/Component/AntDesign/Column/BaseColumn.php index fb4f675..dd8ee8b 100644 --- a/app/Component/AntDesign/Table/Column/BaseColumn.php +++ b/app/Component/AntDesign/Column/BaseColumn.php @@ -1,6 +1,6 @@ Date: Wed, 2 Dec 2020 19:43:30 +0800 Subject: [PATCH 33/82] =?UTF-8?q?form=20=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/AntDesign/Column/BaseColumn.php | 10 +- app/Component/AntDesign/Column/Column.php | 4 + .../AntDesign/Column/ProgressType.php | 4 + app/Component/AntDesign/Column/Search.php | 5 + app/Component/AntDesign/Column/ValueEnum.php | 5 + .../AntDesign/Column/ValueEnumType.php | 5 + .../AntDesign/Config/ColumnConfig.php | 5 +- .../Config/{FormConfig.php => PageConfig.php} | 8 +- app/Component/AntDesign/Config/Pagination.php | 4 + .../AntDesign/Config/RowSelection.php | 5 + .../Constant/Status/ProgressTypeStatus.php | 4 + .../Constant/Status/ValueEnumTypeStatus.php | 4 + .../AntDesign/Constant/Type/FormDateType.php | 26 ++ .../Constant/Type/FormSelectModeType.php | 18 ++ .../AntDesign/Constant/Type/InputType.php | 57 ++++ .../Constant/Type/RowSelectionType.php | 4 + .../AntDesign/Constant/Type/SizeType.php | 23 ++ .../AntDesign/Constant/Type/WidthType.php | 42 +++ app/Component/AntDesign/Form/AutoSize.php | 24 ++ app/Component/AntDesign/Form/BaseForm.php | 169 +++++++++++ app/Component/AntDesign/Form/Form.php | 46 +++ app/Component/AntDesign/Form/FormCheckbox.php | 67 +++++ .../AntDesign/Form/FormDatePicker.php | 84 ++++++ app/Component/AntDesign/Form/FormRate.php | 130 +++++++++ app/Component/AntDesign/Form/FormSelect.php | 274 ++++++++++++++++++ app/Component/AntDesign/Form/FormSlider.php | 132 +++++++++ app/Component/AntDesign/Form/FormSwitch.php | 109 +++++++ app/Component/AntDesign/Form/FormText.php | 81 ++++++ .../AntDesign/Form/FormTextPassword.php | 12 + app/Component/AntDesign/Form/FormTextarea.php | 85 ++++++ app/Component/AntDesign/Form/Rules.php | 62 ++++ app/Component/AntDesign/Table.php | 10 +- 32 files changed, 1510 insertions(+), 8 deletions(-) rename app/Component/AntDesign/Config/{FormConfig.php => PageConfig.php} (95%) create mode 100644 app/Component/AntDesign/Constant/Type/FormDateType.php create mode 100644 app/Component/AntDesign/Constant/Type/FormSelectModeType.php create mode 100644 app/Component/AntDesign/Constant/Type/InputType.php create mode 100644 app/Component/AntDesign/Constant/Type/SizeType.php create mode 100644 app/Component/AntDesign/Constant/Type/WidthType.php create mode 100644 app/Component/AntDesign/Form/AutoSize.php create mode 100644 app/Component/AntDesign/Form/BaseForm.php create mode 100644 app/Component/AntDesign/Form/FormCheckbox.php create mode 100644 app/Component/AntDesign/Form/FormDatePicker.php create mode 100644 app/Component/AntDesign/Form/FormRate.php create mode 100644 app/Component/AntDesign/Form/FormSelect.php create mode 100644 app/Component/AntDesign/Form/FormSlider.php create mode 100644 app/Component/AntDesign/Form/FormSwitch.php create mode 100644 app/Component/AntDesign/Form/FormText.php create mode 100644 app/Component/AntDesign/Form/FormTextPassword.php create mode 100644 app/Component/AntDesign/Form/FormTextarea.php create mode 100644 app/Component/AntDesign/Form/Rules.php diff --git a/app/Component/AntDesign/Column/BaseColumn.php b/app/Component/AntDesign/Column/BaseColumn.php index dd8ee8b..26e041b 100644 --- a/app/Component/AntDesign/Column/BaseColumn.php +++ b/app/Component/AntDesign/Column/BaseColumn.php @@ -6,7 +6,7 @@ use Lengbin\Common\Component\BaseObject; /** - * Class Column + * 基础 列类 * @package App\Component\AntDesign * @see https://github.com/coderlfm/CMS */ @@ -364,7 +364,7 @@ public function setValueEnum(array $valueEnum): BaseColumn return $this; } - public function init() + protected function check(): void { // 必填项验证 $this->getDataIndex(); @@ -403,4 +403,10 @@ public function init() } } } + + public function toArray(?object $object = null): array + { + $this->check(); + return parent::toArray($object); // TODO: Change the autogenerated stub + } } diff --git a/app/Component/AntDesign/Column/Column.php b/app/Component/AntDesign/Column/Column.php index 6129ab0..c8d4750 100644 --- a/app/Component/AntDesign/Column/Column.php +++ b/app/Component/AntDesign/Column/Column.php @@ -2,6 +2,10 @@ namespace App\Component\AntDesign\Column; +/** + * 列 + * @package App\Component\AntDesign\Column + */ class Column extends BaseColumn { public function init() diff --git a/app/Component/AntDesign/Column/ProgressType.php b/app/Component/AntDesign/Column/ProgressType.php index 5f99618..d56de65 100644 --- a/app/Component/AntDesign/Column/ProgressType.php +++ b/app/Component/AntDesign/Column/ProgressType.php @@ -5,6 +5,10 @@ use App\Component\AntDesign\Constant\Status\ProgressTypeStatus; use Lengbin\Common\Component\BaseObject; +/** + * 列值的枚举 - 进度条 + * @package App\Component\AntDesign\Column + */ class ProgressType extends BaseObject { /** diff --git a/app/Component/AntDesign/Column/Search.php b/app/Component/AntDesign/Column/Search.php index c38db07..ace801f 100644 --- a/app/Component/AntDesign/Column/Search.php +++ b/app/Component/AntDesign/Column/Search.php @@ -2,6 +2,11 @@ namespace App\Component\AntDesign\Column; +/** + * 自定义 搜索 列 + * + * @package App\Component\AntDesign\Column + */ class Search extends BaseColumn { public function init() diff --git a/app/Component/AntDesign/Column/ValueEnum.php b/app/Component/AntDesign/Column/ValueEnum.php index f01e396..a8b4890 100644 --- a/app/Component/AntDesign/Column/ValueEnum.php +++ b/app/Component/AntDesign/Column/ValueEnum.php @@ -4,6 +4,11 @@ use Lengbin\Common\Component\BaseObject; +/** + * 当前列值的枚举 + * + * @package App\Component\AntDesign\Column + */ class ValueEnum extends BaseObject { /** diff --git a/app/Component/AntDesign/Column/ValueEnumType.php b/app/Component/AntDesign/Column/ValueEnumType.php index 45bfe59..21d9aee 100644 --- a/app/Component/AntDesign/Column/ValueEnumType.php +++ b/app/Component/AntDesign/Column/ValueEnumType.php @@ -5,6 +5,11 @@ use App\Component\AntDesign\Constant\Status\ValueEnumTypeStatus; use Lengbin\Common\Component\BaseObject; +/** + * 列值的枚举 - 枚举 + * + * @package App\Component\AntDesign\Column + */ class ValueEnumType extends BaseObject { /** diff --git a/app/Component/AntDesign/Config/ColumnConfig.php b/app/Component/AntDesign/Config/ColumnConfig.php index f113d54..0525379 100644 --- a/app/Component/AntDesign/Config/ColumnConfig.php +++ b/app/Component/AntDesign/Config/ColumnConfig.php @@ -4,9 +4,12 @@ use Lengbin\Common\Component\BaseObject; +/** + * 表格 配置 + * @package App\Component\AntDesign\Config + */ class ColumnConfig extends BaseObject { - /** * 唯一key值 * @var string diff --git a/app/Component/AntDesign/Config/FormConfig.php b/app/Component/AntDesign/Config/PageConfig.php similarity index 95% rename from app/Component/AntDesign/Config/FormConfig.php rename to app/Component/AntDesign/Config/PageConfig.php index 041f96b..e56af71 100644 --- a/app/Component/AntDesign/Config/FormConfig.php +++ b/app/Component/AntDesign/Config/PageConfig.php @@ -4,10 +4,14 @@ use Lengbin\Common\Component\BaseObject; -class FormConfig extends BaseObject +/** + * 页 配置 + * @package App\Component\AntDesign\Config + */ +class PageConfig extends BaseObject { /** - * 查询按钮的文本 + * 查询按钮的PageConfig文本 * @var string */ private $searchText; diff --git a/app/Component/AntDesign/Config/Pagination.php b/app/Component/AntDesign/Config/Pagination.php index 89bb708..9ac3c31 100644 --- a/app/Component/AntDesign/Config/Pagination.php +++ b/app/Component/AntDesign/Config/Pagination.php @@ -4,6 +4,10 @@ use Lengbin\Common\Component\BaseObject; +/** + * 分页配置 + * @package App\Component\AntDesign\Config + */ class Pagination extends BaseObject { /** diff --git a/app/Component/AntDesign/Config/RowSelection.php b/app/Component/AntDesign/Config/RowSelection.php index 7ba9a40..1e8e91e 100644 --- a/app/Component/AntDesign/Config/RowSelection.php +++ b/app/Component/AntDesign/Config/RowSelection.php @@ -5,6 +5,11 @@ use App\Component\AntDesign\Constant\Type\RowSelectionType; use Lengbin\Common\Component\BaseObject; +/** + * 列 配置 + * + * @package App\Component\AntDesign\Config + */ class RowSelection extends BaseObject { /** diff --git a/app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php b/app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php index a6f853a..25b30c5 100644 --- a/app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php +++ b/app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php @@ -4,6 +4,10 @@ use Lengbin\Hyperf\ErrorCode\BaseEnum; +/** + * 该值要渲染的状态 + * @package App\Component\AntDesign\Constant\Status + */ class ProgressTypeStatus extends BaseEnum { diff --git a/app/Component/AntDesign/Constant/Status/ValueEnumTypeStatus.php b/app/Component/AntDesign/Constant/Status/ValueEnumTypeStatus.php index af7ff31..af72434 100644 --- a/app/Component/AntDesign/Constant/Status/ValueEnumTypeStatus.php +++ b/app/Component/AntDesign/Constant/Status/ValueEnumTypeStatus.php @@ -4,6 +4,10 @@ use Lengbin\Hyperf\ErrorCode\BaseEnum; +/** + * 该值要渲染的状态 + * @package App\Component\AntDesign\Constant\Status + */ class ValueEnumTypeStatus extends BaseEnum { /** diff --git a/app/Component/AntDesign/Constant/Type/FormDateType.php b/app/Component/AntDesign/Constant/Type/FormDateType.php new file mode 100644 index 0000000..a29011f --- /dev/null +++ b/app/Component/AntDesign/Constant/Type/FormDateType.php @@ -0,0 +1,26 @@ +name; + } + + /** + * @param string $name + * + * @return BaseForm + */ + public function setName(string $name): BaseForm + { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getLabel(): string + { + return $this->label; + } + + /** + * @param string $label + * + * @return BaseForm + */ + public function setLabel(string $label): BaseForm + { + $this->label = $label; + return $this; + } + + /** + * @return string + */ + public function getPlaceholder(): string + { + return $this->placeholder; + } + + /** + * @param string $placeholder + * + * @return BaseForm + */ + public function setPlaceholder(string $placeholder): BaseForm + { + $this->placeholder = $placeholder; + return $this; + } + + /** + * @return WidthType + */ + public function getWidth(): WidthType + { + return $this->width; + } + + /** + * @param WidthType $width + * + * @return BaseForm + */ + public function setWidth(WidthType $width): BaseForm + { + $this->width = $width; + return $this; + } + + /** + * @return Rules[] + */ + public function getRules(): array + { + return $this->rules; + } + + /** + * @param Rules[] $rules + * + * @return BaseForm + */ + public function setRules(array $rules): BaseForm + { + $this->rules = $rules; + return $this; + } + + /** + * @return bool + */ + public function isDisabled(): bool + { + return $this->disabled; + } + + /** + * @param bool $disabled + * + * @return BaseForm + */ + public function setDisabled(bool $disabled): BaseForm + { + $this->disabled = $disabled; + return $this; + } + + public function toArray(?object $object = null): array + { + $this->getName(); + return parent::toArray($object); + } +} diff --git a/app/Component/AntDesign/Form/Form.php b/app/Component/AntDesign/Form/Form.php index d656b4c..a659b0d 100644 --- a/app/Component/AntDesign/Form/Form.php +++ b/app/Component/AntDesign/Form/Form.php @@ -6,5 +6,51 @@ class Form extends BaseObject { + /** + * @var string + */ + private $title = ''; + /** + * @var array + */ + private $item; + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $title + * + * @return Form + */ + public function setTitle(string $title): Form + { + $this->title = $title; + return $this; + } + + /** + * @return array + */ + public function getItem(): array + { + return $this->item; + } + + /** + * @param array $item + * + * @return Form + */ + public function setItem(array $item): Form + { + $this->item = $item; + return $this; + } } diff --git a/app/Component/AntDesign/Form/FormCheckbox.php b/app/Component/AntDesign/Form/FormCheckbox.php new file mode 100644 index 0000000..39711a9 --- /dev/null +++ b/app/Component/AntDesign/Form/FormCheckbox.php @@ -0,0 +1,67 @@ +defaultChecked; + } + + /** + * @param bool $defaultChecked + * + * @return FormCheckbox + */ + public function setDefaultChecked(bool $defaultChecked): FormCheckbox + { + $this->defaultChecked = $defaultChecked; + return $this; + } + + /** + * @return array + */ + public function getValueEnum(): array + { + return $this->valueEnum; + } + + /** + * @param ValueEnum[] $valueEnum + * + * @return FormCheckbox + */ + public function setValueEnum(array $valueEnum): FormCheckbox + { + $drops = []; + foreach ($valueEnum as $item) { + $drops[$item->getKey()] = new ValueEnumType([ + 'text' => $item->getValue(), + 'status' => $item->getStatus(), + ]); + } + $this->valueEnum = $drops; + return $this; + } +} diff --git a/app/Component/AntDesign/Form/FormDatePicker.php b/app/Component/AntDesign/Form/FormDatePicker.php new file mode 100644 index 0000000..498a79d --- /dev/null +++ b/app/Component/AntDesign/Form/FormDatePicker.php @@ -0,0 +1,84 @@ +type; + } + + /** + * @param FormDateType $type + * + * @return FormDatePicker + */ + public function setType(FormDateType $type): FormDatePicker + { + $this->type = $type; + return $this; + } + + /** + * @return bool + */ + public function isRange(): bool + { + return $this->range; + } + + /** + * @param bool $range + * + * @return FormDatePicker + */ + public function setRange(bool $range): FormDatePicker + { + $this->range = $range; + return $this; + } + + /** + * @return string + */ + public function getDefaultValue(): string + { + return $this->defaultValue; + } + + /** + * @param string $defaultValue + * + * @return FormDatePicker + */ + public function setDefaultValue(string $defaultValue): FormDatePicker + { + $this->defaultValue = $defaultValue; + return $this; + } + +} diff --git a/app/Component/AntDesign/Form/FormRate.php b/app/Component/AntDesign/Form/FormRate.php new file mode 100644 index 0000000..3a92077 --- /dev/null +++ b/app/Component/AntDesign/Form/FormRate.php @@ -0,0 +1,130 @@ +character; + } + + /** + * @param string $character + * + * @return FormRate + */ + public function setCharacter(string $character): FormRate + { + $this->character = $character; + return $this; + } + + /** + * @return bool + */ + public function isAllowClear(): bool + { + return $this->allowClear; + } + + /** + * @param bool $allowClear + * + * @return FormRate + */ + public function setAllowClear(bool $allowClear): FormRate + { + $this->allowClear = $allowClear; + return $this; + } + + /** + * @return bool + */ + public function isAllowHalf(): bool + { + return $this->allowHalf; + } + + /** + * @param bool $allowHalf + * + * @return FormRate + */ + public function setAllowHalf(bool $allowHalf): FormRate + { + $this->allowHalf = $allowHalf; + return $this; + } + + /** + * @return int + */ + public function getCount(): int + { + return $this->count; + } + + /** + * @param int $count + * + * @return FormRate + */ + public function setCount(int $count): FormRate + { + $this->count = $count; + return $this; + } + + /** + * @return float|int + */ + public function getDefaultValue() + { + return $this->defaultValue; + } + + /** + * @param float|int $defaultValue + * + * @return FormRate + */ + public function setDefaultValue($defaultValue): FormRate + { + $this->defaultValue = $defaultValue; + return $this; + } +} diff --git a/app/Component/AntDesign/Form/FormSelect.php b/app/Component/AntDesign/Form/FormSelect.php new file mode 100644 index 0000000..43a9279 --- /dev/null +++ b/app/Component/AntDesign/Form/FormSelect.php @@ -0,0 +1,274 @@ +valueEnum; + } + + /** + * @param ValueEnum[] $valueEnum + * + * @return FormSelect + */ + public function setValueEnum(array $valueEnum): FormSelect + { + $drops = []; + foreach ($valueEnum as $item) { + $drops[$item->getKey()] = new ValueEnumType([ + 'text' => $item->getValue(), + 'status' => $item->getStatus(), + ]); + } + $this->valueEnum = $drops; + return $this; + } + + /** + * @return FormSelectModeType + */ + public function getMode(): FormSelectModeType + { + return $this->mode; + } + + /** + * @param FormSelectModeType $mode + * + * @return FormSelect + */ + public function setMode(FormSelectModeType $mode): FormSelect + { + $this->mode = $mode; + return $this; + } + + /** + * @return int + */ + public function getListHeight(): int + { + return $this->listHeight; + } + + /** + * @param int $listHeight + * + * @return FormSelect + */ + public function setListHeight(int $listHeight): FormSelect + { + $this->listHeight = $listHeight; + return $this; + } + + /** + * @return SizeType + */ + public function getSize(): SizeType + { + return $this->size; + } + + /** + * @param SizeType $size + * + * @return FormSelect + */ + public function setSize(SizeType $size): FormSelect + { + $this->size = $size; + return $this; + } + + /** + * @return bool + */ + public function isShowSearch(): bool + { + return $this->showSearch; + } + + /** + * @param bool $showSearch + * + * @return FormSelect + */ + public function setShowSearch(bool $showSearch): FormSelect + { + $this->showSearch = $showSearch; + return $this; + } + + /** + * @return bool + */ + public function isAllowClear(): bool + { + return $this->allowClear; + } + + /** + * @param bool $allowClear + * + * @return FormSelect + */ + public function setAllowClear(bool $allowClear): FormSelect + { + $this->allowClear = $allowClear; + return $this; + } + + /** + * @return bool + */ + public function isAutoClearSearchValue(): bool + { + return $this->autoClearSearchValue; + } + + /** + * @param bool $autoClearSearchValue + * + * @return FormSelect + */ + public function setAutoClearSearchValue(bool $autoClearSearchValue): FormSelect + { + $this->autoClearSearchValue = $autoClearSearchValue; + return $this; + } + + /** + * @return bool + */ + public function isBordered(): bool + { + return $this->bordered; + } + + /** + * @param bool $bordered + * + * @return FormSelect + */ + public function setBordered(bool $bordered): FormSelect + { + $this->bordered = $bordered; + return $this; + } + + /** + * @return bool + */ + public function isDefaultActiveFirstOption(): bool + { + return $this->defaultActiveFirstOption; + } + + /** + * @param bool $defaultActiveFirstOption + * + * @return FormSelect + */ + public function setDefaultActiveFirstOption(bool $defaultActiveFirstOption): FormSelect + { + $this->defaultActiveFirstOption = $defaultActiveFirstOption; + return $this; + } + + /** + * @return bool + */ + public function isDefaultOpen(): bool + { + return $this->defaultOpen; + } + + /** + * @param bool $defaultOpen + * + * @return FormSelect + */ + public function setDefaultOpen(bool $defaultOpen): FormSelect + { + $this->defaultOpen = $defaultOpen; + return $this; + } + +} diff --git a/app/Component/AntDesign/Form/FormSlider.php b/app/Component/AntDesign/Form/FormSlider.php new file mode 100644 index 0000000..0b559f0 --- /dev/null +++ b/app/Component/AntDesign/Form/FormSlider.php @@ -0,0 +1,132 @@ +range; + } + + /** + * @param bool $range + * + * @return FormSlider + */ + public function setRange(bool $range): FormSlider + { + $this->range = $range; + return $this; + } + + /** + * @return float|float[] + */ + public function getDefaultValue() + { + return $this->defaultValue; + } + + /** + * @param float|float[] $defaultValue + * + * @return FormSlider + */ + public function setDefaultValue($defaultValue): FormSlider + { + $this->defaultValue = $defaultValue; + return $this; + } + + /** + * @return float|int + */ + public function getMax() + { + return $this->max; + } + + /** + * @param float|int $max + * + * @return FormSlider + */ + public function setMax($max): FormSlider + { + $this->max = $max; + return $this; + } + + /** + * @return float|int + */ + public function getMin() + { + return $this->min; + } + + /** + * @param float|int $min + * + * @return FormSlider + */ + public function setMin($min): FormSlider + { + $this->min = $min; + return $this; + } + + /** + * @return bool + */ + public function isTooltipVisible(): bool + { + return $this->tooltipVisible; + } + + /** + * @param bool $tooltipVisible + * + * @return FormSlider + */ + public function setTooltipVisible(bool $tooltipVisible): FormSlider + { + $this->tooltipVisible = $tooltipVisible; + return $this; + } + +} diff --git a/app/Component/AntDesign/Form/FormSwitch.php b/app/Component/AntDesign/Form/FormSwitch.php new file mode 100644 index 0000000..421a530 --- /dev/null +++ b/app/Component/AntDesign/Form/FormSwitch.php @@ -0,0 +1,109 @@ +defaultChecked; + } + + /** + * @param bool $defaultChecked + * + * @return FormSwitch + */ + public function setDefaultChecked(bool $defaultChecked): FormSwitch + { + $this->defaultChecked = $defaultChecked; + return $this; + } + + /** + * @return SizeType + */ + public function getSize(): SizeType + { + return $this->size; + } + + /** + * @param SizeType $size + * + * @return FormSwitch + */ + public function setSize(SizeType $size): FormSwitch + { + $this->size = $size; + return $this; + } + + /** + * @return string + */ + public function getCheckedChildren(): string + { + return $this->checkedChildren; + } + + /** + * @param string $checkedChildren + * + * @return FormSwitch + */ + public function setCheckedChildren(string $checkedChildren): FormSwitch + { + $this->checkedChildren = $checkedChildren; + return $this; + } + + /** + * @return string + */ + public function getUnCheckedChildren(): string + { + return $this->unCheckedChildren; + } + + /** + * @param string $unCheckedChildren + * + * @return FormSwitch + */ + public function setUnCheckedChildren(string $unCheckedChildren): FormSwitch + { + $this->unCheckedChildren = $unCheckedChildren; + return $this; + } + +} diff --git a/app/Component/AntDesign/Form/FormText.php b/app/Component/AntDesign/Form/FormText.php new file mode 100644 index 0000000..336cf94 --- /dev/null +++ b/app/Component/AntDesign/Form/FormText.php @@ -0,0 +1,81 @@ +bordered; + } + + /** + * @param bool $bordered + * + * @return FormText + */ + public function setBordered(bool $bordered): FormText + { + $this->bordered = $bordered; + return $this; + } + + /** + * @return bool + */ + public function isAllowClear(): bool + { + return $this->allowClear; + } + + /** + * @param bool $allowClear + * + * @return FormText + */ + public function setAllowClear(bool $allowClear): FormText + { + $this->allowClear = $allowClear; + return $this; + } + + /** + * @return bool + */ + public function isShowCount(): bool + { + return $this->showCount; + } + + /** + * @param bool $showCount + * + * @return FormText + */ + public function setShowCount(bool $showCount): FormText + { + $this->showCount = $showCount; + return $this; + } +} diff --git a/app/Component/AntDesign/Form/FormTextPassword.php b/app/Component/AntDesign/Form/FormTextPassword.php new file mode 100644 index 0000000..efff5f7 --- /dev/null +++ b/app/Component/AntDesign/Form/FormTextPassword.php @@ -0,0 +1,12 @@ +autoSize; + } + + /** + * @param AutoSize|bool $autoSize + * + * @return FormTextarea + */ + public function setAutoSize($autoSize) + { + $this->autoSize = $autoSize; + return $this; + } + + /** + * @return string + */ + public function getDefaultValue(): string + { + return $this->defaultValue; + } + + /** + * @param string $defaultValue + * + * @return FormTextarea + */ + public function setDefaultValue(string $defaultValue): FormTextarea + { + $this->defaultValue = $defaultValue; + return $this; + } + + /** + * @return int + */ + public function getMaxLength(): int + { + return $this->maxLength; + } + + /** + * @param int $maxLength + * + * @return FormTextarea + */ + public function setMaxLength(int $maxLength): FormTextarea + { + $this->maxLength = $maxLength; + return $this; + } +} diff --git a/app/Component/AntDesign/Form/Rules.php b/app/Component/AntDesign/Form/Rules.php new file mode 100644 index 0000000..61adc4f --- /dev/null +++ b/app/Component/AntDesign/Form/Rules.php @@ -0,0 +1,62 @@ +required; + } + + /** + * @param bool $required + * + * @return Rules + */ + public function setRequired(bool $required): Rules + { + $this->required = $required; + return $this; + } + + /** + * @return string + */ + public function getMessage(): string + { + return $this->message; + } + + /** + * @param string $message + * + * @return Rules + */ + public function setMessage(string $message): Rules + { + $this->message = $message; + return $this; + } +} diff --git a/app/Component/AntDesign/Table.php b/app/Component/AntDesign/Table.php index f3e4751..ca0cb32 100644 --- a/app/Component/AntDesign/Table.php +++ b/app/Component/AntDesign/Table.php @@ -8,7 +8,8 @@ use App\Component\AntDesign\Column\Column; use App\Component\AntDesign\Column\Search; use App\Component\AntDesign\Config\ColumnConfig; -use App\Component\AntDesign\Config\FormConfig; +use App\Component\AntDesign\Config\PageConfig; +use App\Component\AntDesign\Form\Form; use Lengbin\Common\Component\BaseObject; use Lengbin\Hyperf\Common\Exception\BusinessException; @@ -29,15 +30,18 @@ class Table extends BaseObject public $columnConfig; /** - * @var FormConfig + * @var */ - public $formConfig; + public $pageConfig; /** * @var Search[] */ public $search; + /** + * @var Form[] + */ public $form; public function init() From cc226fd4579d212fb8eb7ecb18d6b240997a8b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Thu, 3 Dec 2020 11:54:27 +0800 Subject: [PATCH 34/82] =?UTF-8?q?=E5=93=8E=EF=BC=8C=E4=B8=80=E8=A8=80?= =?UTF-8?q?=E9=9A=BE=E5=B0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/AntDesign/Config/PageConfig.php | 26 +++++----- app/Component/AntDesign/Table.php | 10 ++-- app/Controller/TestController.php | 51 ++++++++++++++----- 3 files changed, 56 insertions(+), 31 deletions(-) diff --git a/app/Component/AntDesign/Config/PageConfig.php b/app/Component/AntDesign/Config/PageConfig.php index e56af71..8cd9ecb 100644 --- a/app/Component/AntDesign/Config/PageConfig.php +++ b/app/Component/AntDesign/Config/PageConfig.php @@ -63,9 +63,9 @@ public function getSearchText(): string /** * @param string $searchText * - * @return FormConfig + * @return PageConfig */ - public function setSearchText(string $searchText): FormConfig + public function setSearchText(string $searchText): PageConfig { $this->searchText = $searchText; return $this; @@ -82,9 +82,9 @@ public function getResetText(): string /** * @param string $resetText * - * @return FormConfig + * @return PageConfig */ - public function setResetText(string $resetText): FormConfig + public function setResetText(string $resetText): PageConfig { $this->resetText = $resetText; return $this; @@ -101,9 +101,9 @@ public function getSubmitText(): string /** * @param string $submitText * - * @return FormConfig + * @return PageConfig */ - public function setSubmitText(string $submitText): FormConfig + public function setSubmitText(string $submitText): PageConfig { $this->submitText = $submitText; return $this; @@ -120,7 +120,7 @@ public function getLabelWidth() /** * @param int|string $labelWidth * - * @return FormConfig + * @return PageConfig */ public function setLabelWidth($labelWidth) { @@ -139,9 +139,9 @@ public function getSpan(): int /** * @param int $span * - * @return FormConfig + * @return PageConfig */ - public function setSpan(int $span): FormConfig + public function setSpan(int $span): PageConfig { $this->span = $span; return $this; @@ -158,9 +158,9 @@ public function isDefaultCollapsed(): bool /** * @param bool $defaultCollapsed * - * @return FormConfig + * @return PageConfig */ - public function setDefaultCollapsed(bool $defaultCollapsed): FormConfig + public function setDefaultCollapsed(bool $defaultCollapsed): PageConfig { $this->defaultCollapsed = $defaultCollapsed; return $this; @@ -177,9 +177,9 @@ public function isCollapsed(): bool /** * @param bool $collapsed * - * @return FormConfig + * @return PageConfig */ - public function setCollapsed(bool $collapsed): FormConfig + public function setCollapsed(bool $collapsed): PageConfig { $this->collapsed = $collapsed; return $this; diff --git a/app/Component/AntDesign/Table.php b/app/Component/AntDesign/Table.php index ca0cb32..3ca9aa2 100644 --- a/app/Component/AntDesign/Table.php +++ b/app/Component/AntDesign/Table.php @@ -2,14 +2,12 @@ namespace App\Component\AntDesign; +use App\Component\AntDesign\Config\PageConfig; use App\Component\AntDesign\Constant\Type\ValueType; use App\Component\AntDesign\Errors\TableError; use App\Component\AntDesign\Column\BaseColumn; use App\Component\AntDesign\Column\Column; -use App\Component\AntDesign\Column\Search; use App\Component\AntDesign\Config\ColumnConfig; -use App\Component\AntDesign\Config\PageConfig; -use App\Component\AntDesign\Form\Form; use Lengbin\Common\Component\BaseObject; use Lengbin\Hyperf\Common\Exception\BusinessException; @@ -30,17 +28,17 @@ class Table extends BaseObject public $columnConfig; /** - * @var + * @var PageConfig */ public $pageConfig; /** - * @var Search[] + * @var array */ public $search; /** - * @var Form[] + * @var array */ public $form; diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index c64c712..6b38c1d 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -6,6 +6,7 @@ use App\Service\Admin\AdminService; use Hyperf\Di\Annotation\Inject; use Hyperf\HttpServer\Annotation\GetMapping; +use Hyperf\HttpServer\Annotation\PostMapping; use Lengbin\Hyperf\Auth\RouterAuthAnnotation; use Lengbin\Hyperf\Common\Entity\PageEntity; use Lengbin\Hyperf\Common\Framework\BaseController; @@ -26,6 +27,23 @@ class TestController extends BaseController */ protected $adminService; + /** + * @GetMapping(path="/init") + * + * @return mixed + */ + public function init() + { + $table = new Table([ + 'column' => [ + 'admin_id|id', + 'nickname|昵称', + [], + ], + ]); + return $this->success($table->toArray()); + } + /** * @GetMapping(path="/") * @@ -39,22 +57,31 @@ public function list() 'pageSize' => !empty($params['pageSize']) ? (int)$params['pageSize'] : 2, ]); $list = $this->adminService->getList([], ['admin_id', 'nickname'], $page); - return $this->success($list); + $data = array_merge($list, $params); + return $this->success($data); } /** - * @GetMapping(path="/init") - * - * @return mixed + * @PostMapping(path="/create") */ - public function init() + public function create() { - $table = new Table([ - 'column' => [ - 'admin_id|id', - 'nickname|昵称', - ], - ]); - return $this->success($table->toArray()); + return $this->success($this->request->post()); + } + + /** + * @PostMapping(path="/update") + */ + public function update() + { + return $this->success($this->request->post()); + } + + /** + * @PostMapping(path="/remove") + */ + public function remove() + { + return $this->success($this->request->post()); } } From 3392e3d9699158e20243056a941ab8c348a78df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Thu, 3 Dec 2020 18:39:20 +0800 Subject: [PATCH 35/82] =?UTF-8?q?=E4=BF=AE=E4=BF=AE=E6=94=B9=E6=94=B9?= =?UTF-8?q?=E5=8F=88=E4=B8=80=E5=B9=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/AntDesign/Column/BaseColumn.php | 10 +- .../AntDesign/Config/ColumnConfig.php | 8 -- app/Component/AntDesign/Config/PageConfig.php | 4 +- app/Component/AntDesign/Config/Pagination.php | 2 +- app/Component/AntDesign/Errors/TableError.php | 18 --- app/Component/AntDesign/Form/AutoSize.php | 38 ++++++ app/Component/AntDesign/Form/BaseForm.php | 29 ++++- app/Component/AntDesign/Form/Form.php | 9 +- app/Component/AntDesign/Form/FormCheckbox.php | 2 +- .../AntDesign/Form/FormDatePicker.php | 2 +- app/Component/AntDesign/Form/FormRate.php | 4 +- app/Component/AntDesign/Form/FormSelect.php | 12 +- app/Component/AntDesign/Form/FormSlider.php | 4 +- app/Component/AntDesign/Form/FormSwitch.php | 2 +- app/Component/AntDesign/Form/FormText.php | 6 +- .../AntDesign/Form/FormTextPassword.php | 20 +++ app/Component/AntDesign/Form/Rules.php | 2 +- app/Component/AntDesign/Table.php | 31 +---- app/Constant/Error.php | 10 -- app/Controller/TestController.php | 120 +++++++++++++++++- config/autoload/errorCode.php | 1 - 21 files changed, 239 insertions(+), 95 deletions(-) delete mode 100644 app/Component/AntDesign/Errors/TableError.php diff --git a/app/Component/AntDesign/Column/BaseColumn.php b/app/Component/AntDesign/Column/BaseColumn.php index 26e041b..059d5d9 100644 --- a/app/Component/AntDesign/Column/BaseColumn.php +++ b/app/Component/AntDesign/Column/BaseColumn.php @@ -291,7 +291,7 @@ public function setWidth(string $width): BaseColumn /** * @return bool */ - public function isHideInSearch(): bool + public function getHideInSearch(): bool { return $this->hideInSearch; } @@ -310,7 +310,7 @@ public function setHideInSearch(bool $hideInSearch): BaseColumn /** * @return bool */ - public function isHideInTable(): bool + public function getHideInTable(): bool { return $this->hideInTable; } @@ -397,9 +397,9 @@ protected function check(): void $this->valueEnum = $drops; // 如果是 select 或者 checkbox 默认为数组 - $initValue = $this->getInitialValue(); - if (in_array($this->valueType->getValue(), [ValueType::SELECT, ValueType::CHECKBOX,], true) && !is_array($initValue)) { - $this->setInitialValue([$initValue]); + $initValue = $this->getInitialValue() ?? ''; + if (in_array($this->valueType->getValue(), [ValueType::SELECT, ValueType::CHECKBOX], true) && !is_array($initValue)) { + $initValue ? $this->setInitialValue([$initValue]) : $this->setInitialValue([]) ; } } } diff --git a/app/Component/AntDesign/Config/ColumnConfig.php b/app/Component/AntDesign/Config/ColumnConfig.php index 0525379..e16e26d 100644 --- a/app/Component/AntDesign/Config/ColumnConfig.php +++ b/app/Component/AntDesign/Config/ColumnConfig.php @@ -31,12 +31,4 @@ class ColumnConfig extends BaseObject * @var Pagination */ public $pagination; - - public function init() - { - if ($this->pagination === null) { - $this->pagination = new Pagination(); - } - } - } diff --git a/app/Component/AntDesign/Config/PageConfig.php b/app/Component/AntDesign/Config/PageConfig.php index 8cd9ecb..cefbd43 100644 --- a/app/Component/AntDesign/Config/PageConfig.php +++ b/app/Component/AntDesign/Config/PageConfig.php @@ -150,7 +150,7 @@ public function setSpan(int $span): PageConfig /** * @return bool */ - public function isDefaultCollapsed(): bool + public function getDefaultCollapsed(): bool { return $this->defaultCollapsed; } @@ -169,7 +169,7 @@ public function setDefaultCollapsed(bool $defaultCollapsed): PageConfig /** * @return bool */ - public function isCollapsed(): bool + public function getCollapsed(): bool { return $this->collapsed; } diff --git a/app/Component/AntDesign/Config/Pagination.php b/app/Component/AntDesign/Config/Pagination.php index 9ac3c31..e6ebdc9 100644 --- a/app/Component/AntDesign/Config/Pagination.php +++ b/app/Component/AntDesign/Config/Pagination.php @@ -13,5 +13,5 @@ class Pagination extends BaseObject /** * @var int */ - public $pageSize = 2; + public $pageSize = 10; } diff --git a/app/Component/AntDesign/Errors/TableError.php b/app/Component/AntDesign/Errors/TableError.php deleted file mode 100644 index 1d6f019..0000000 --- a/app/Component/AntDesign/Errors/TableError.php +++ /dev/null @@ -1,18 +0,0 @@ -minRows; + } + + /** + * @param int $minRows + * + * @return AutoSize + */ + public function setMinRows(int $minRows): AutoSize + { + $this->minRows = $minRows; + return $this; + } + + /** + * @return int + */ + public function getMaxRows(): int + { + return $this->maxRows; + } + + /** + * @param int $maxRows + * + * @return AutoSize + */ + public function setMaxRows(int $maxRows): AutoSize + { + $this->maxRows = $maxRows; + return $this; + } } diff --git a/app/Component/AntDesign/Form/BaseForm.php b/app/Component/AntDesign/Form/BaseForm.php index f8a825d..a6f001f 100644 --- a/app/Component/AntDesign/Form/BaseForm.php +++ b/app/Component/AntDesign/Form/BaseForm.php @@ -42,11 +42,17 @@ class BaseForm extends BaseObject protected $rules; /** - * 不可选中 + * 不可选中 * @var bool */ protected $disabled; + /** + * 表单类型 + * @var string + */ + protected $inputType; + /** * @return string */ @@ -145,7 +151,7 @@ public function setRules(array $rules): BaseForm /** * @return bool */ - public function isDisabled(): bool + public function getDisabled(): bool { return $this->disabled; } @@ -166,4 +172,23 @@ public function toArray(?object $object = null): array $this->getName(); return parent::toArray($object); } + + /** + * @return string + */ + public function getInputType(): string + { + return $this->inputType; + } + + /** + * @param string $inputType + * + * @return BaseForm + */ + public function setInputType(string $inputType): BaseForm + { + $this->inputType = $inputType; + return $this; + } } diff --git a/app/Component/AntDesign/Form/Form.php b/app/Component/AntDesign/Form/Form.php index a659b0d..b789f62 100644 --- a/app/Component/AntDesign/Form/Form.php +++ b/app/Component/AntDesign/Form/Form.php @@ -2,6 +2,7 @@ namespace App\Component\AntDesign\Form; +use App\Component\AntDesign\Constant\Type\InputType; use Lengbin\Common\Component\BaseObject; class Form extends BaseObject @@ -50,7 +51,13 @@ public function getItem(): array */ public function setItem(array $item): Form { - $this->item = $item; + $data = []; + foreach ($item as $form) { + $type = $form['inputType']; + $class = __NAMESPACE__ . '\\' . InputType::byName(strtoupper($type))->getValue(); + $data[] = new $class($form); + } + $this->item = $data; return $this; } } diff --git a/app/Component/AntDesign/Form/FormCheckbox.php b/app/Component/AntDesign/Form/FormCheckbox.php index 39711a9..24a30d1 100644 --- a/app/Component/AntDesign/Form/FormCheckbox.php +++ b/app/Component/AntDesign/Form/FormCheckbox.php @@ -23,7 +23,7 @@ class FormCheckbox extends BaseForm /** * @return bool */ - public function isDefaultChecked(): bool + public function getDefaultChecked(): bool { return $this->defaultChecked; } diff --git a/app/Component/AntDesign/Form/FormDatePicker.php b/app/Component/AntDesign/Form/FormDatePicker.php index 498a79d..ff657aa 100644 --- a/app/Component/AntDesign/Form/FormDatePicker.php +++ b/app/Component/AntDesign/Form/FormDatePicker.php @@ -46,7 +46,7 @@ public function setType(FormDateType $type): FormDatePicker /** * @return bool */ - public function isRange(): bool + public function getRange(): bool { return $this->range; } diff --git a/app/Component/AntDesign/Form/FormRate.php b/app/Component/AntDesign/Form/FormRate.php index 3a92077..f6f04ff 100644 --- a/app/Component/AntDesign/Form/FormRate.php +++ b/app/Component/AntDesign/Form/FormRate.php @@ -55,7 +55,7 @@ public function setCharacter(string $character): FormRate /** * @return bool */ - public function isAllowClear(): bool + public function getAllowClear(): bool { return $this->allowClear; } @@ -74,7 +74,7 @@ public function setAllowClear(bool $allowClear): FormRate /** * @return bool */ - public function isAllowHalf(): bool + public function getAllowHalf(): bool { return $this->allowHalf; } diff --git a/app/Component/AntDesign/Form/FormSelect.php b/app/Component/AntDesign/Form/FormSelect.php index 43a9279..0bd9889 100644 --- a/app/Component/AntDesign/Form/FormSelect.php +++ b/app/Component/AntDesign/Form/FormSelect.php @@ -160,7 +160,7 @@ public function setSize(SizeType $size): FormSelect /** * @return bool */ - public function isShowSearch(): bool + public function getShowSearch(): bool { return $this->showSearch; } @@ -179,7 +179,7 @@ public function setShowSearch(bool $showSearch): FormSelect /** * @return bool */ - public function isAllowClear(): bool + public function getAllowClear(): bool { return $this->allowClear; } @@ -198,7 +198,7 @@ public function setAllowClear(bool $allowClear): FormSelect /** * @return bool */ - public function isAutoClearSearchValue(): bool + public function getAutoClearSearchValue(): bool { return $this->autoClearSearchValue; } @@ -217,7 +217,7 @@ public function setAutoClearSearchValue(bool $autoClearSearchValue): FormSelect /** * @return bool */ - public function isBordered(): bool + public function getBordered(): bool { return $this->bordered; } @@ -236,7 +236,7 @@ public function setBordered(bool $bordered): FormSelect /** * @return bool */ - public function isDefaultActiveFirstOption(): bool + public function getDefaultActiveFirstOption(): bool { return $this->defaultActiveFirstOption; } @@ -255,7 +255,7 @@ public function setDefaultActiveFirstOption(bool $defaultActiveFirstOption): For /** * @return bool */ - public function isDefaultOpen(): bool + public function getDefaultOpen(): bool { return $this->defaultOpen; } diff --git a/app/Component/AntDesign/Form/FormSlider.php b/app/Component/AntDesign/Form/FormSlider.php index 0b559f0..919c548 100644 --- a/app/Component/AntDesign/Form/FormSlider.php +++ b/app/Component/AntDesign/Form/FormSlider.php @@ -37,7 +37,7 @@ class FormSlider extends BaseForm /** * @return bool */ - public function isRange(): bool + public function getRange(): bool { return $this->range; } @@ -113,7 +113,7 @@ public function setMin($min): FormSlider /** * @return bool */ - public function isTooltipVisible(): bool + public function getTooltipVisible(): bool { return $this->tooltipVisible; } diff --git a/app/Component/AntDesign/Form/FormSwitch.php b/app/Component/AntDesign/Form/FormSwitch.php index 421a530..c0b525c 100644 --- a/app/Component/AntDesign/Form/FormSwitch.php +++ b/app/Component/AntDesign/Form/FormSwitch.php @@ -33,7 +33,7 @@ class FormSwitch extends BaseForm /** * @return bool */ - public function isDefaultChecked(): bool + public function getDefaultChecked(): bool { return $this->defaultChecked; } diff --git a/app/Component/AntDesign/Form/FormText.php b/app/Component/AntDesign/Form/FormText.php index 336cf94..d393321 100644 --- a/app/Component/AntDesign/Form/FormText.php +++ b/app/Component/AntDesign/Form/FormText.php @@ -25,7 +25,7 @@ class FormText extends BaseForm /** * @return bool */ - public function isBordered(): bool + public function getBordered(): bool { return $this->bordered; } @@ -44,7 +44,7 @@ public function setBordered(bool $bordered): FormText /** * @return bool */ - public function isAllowClear(): bool + public function getAllowClear(): bool { return $this->allowClear; } @@ -63,7 +63,7 @@ public function setAllowClear(bool $allowClear): FormText /** * @return bool */ - public function isShowCount(): bool + public function getShowCount(): bool { return $this->showCount; } diff --git a/app/Component/AntDesign/Form/FormTextPassword.php b/app/Component/AntDesign/Form/FormTextPassword.php index efff5f7..8695c62 100644 --- a/app/Component/AntDesign/Form/FormTextPassword.php +++ b/app/Component/AntDesign/Form/FormTextPassword.php @@ -9,4 +9,24 @@ class FormTextPassword extends FormText * @var bool */ private $visibilityToggle; + + /** + * @return bool + */ + public function getVisibilityToggle(): bool + { + return $this->visibilityToggle; + } + + /** + * @param bool $visibilityToggle + * + * @return FormTextPassword + */ + public function setVisibilityToggle(bool $visibilityToggle): FormTextPassword + { + $this->visibilityToggle = $visibilityToggle; + return $this; + } + } diff --git a/app/Component/AntDesign/Form/Rules.php b/app/Component/AntDesign/Form/Rules.php index 61adc4f..3a50c71 100644 --- a/app/Component/AntDesign/Form/Rules.php +++ b/app/Component/AntDesign/Form/Rules.php @@ -25,7 +25,7 @@ class Rules extends BaseObject /** * @return bool */ - public function isRequired(): bool + public function getRequired(): bool { return $this->required; } diff --git a/app/Component/AntDesign/Table.php b/app/Component/AntDesign/Table.php index 3ca9aa2..26a17a0 100644 --- a/app/Component/AntDesign/Table.php +++ b/app/Component/AntDesign/Table.php @@ -3,11 +3,13 @@ namespace App\Component\AntDesign; use App\Component\AntDesign\Config\PageConfig; +use App\Component\AntDesign\Constant\Type\InputType; use App\Component\AntDesign\Constant\Type\ValueType; use App\Component\AntDesign\Errors\TableError; use App\Component\AntDesign\Column\BaseColumn; use App\Component\AntDesign\Column\Column; use App\Component\AntDesign\Config\ColumnConfig; +use App\Component\AntDesign\Form\Form; use Lengbin\Common\Component\BaseObject; use Lengbin\Hyperf\Common\Exception\BusinessException; @@ -18,9 +20,9 @@ class Table extends BaseObject { /** - * @var array + * @var Column[] */ - public $column = []; + public $column; /** * @var ColumnConfig @@ -38,35 +40,12 @@ class Table extends BaseObject public $search; /** - * @var array + * @var Form[] */ public $form; public function init() { - // column - foreach ($this->column as $key => $item) { - if (is_string($item)) { - //dataIndex|title - $data = explode('|', $item); - if (count($data) !== 2) { - throw new BusinessException(TableError::ERROR_ANTDESIGN_TABLE_PARAM_ERROR); - } - $item = new Column([ - 'dataIndex' => $data[0], - 'title' => $data[1], - 'valueType' => ValueType::TEXT, - ]); - } elseif (is_array($item)) { - $item = new Column($item); - } elseif ($item instanceof BaseColumn) { - - } else { - throw new BusinessException(TableError::ERROR_ANTDESIGN_TABLE_PARAM_ERROR); - } - $this->column[$key] = $item->toArray(); - } - if ($this->columnConfig === null) { $this->columnConfig = new ColumnConfig(); } diff --git a/app/Constant/Error.php b/app/Constant/Error.php index 977f352..6cef55b 100644 --- a/app/Constant/Error.php +++ b/app/Constant/Error.php @@ -38,16 +38,6 @@ class Error extends BaseEnum */ const ERROR_COMMENTERRORCODE_INVALID_TOKEN = 'F-000-000-403'; - /** - * @Message("列表参数错误") - */ - const ERROR_TABLEERROR_ERROR_ANTDESIGN_TABLE_PARAM_ERROR = 'A-001-001-001'; - - /** - * @Message("列选择类型错误") - */ - const ERROR_TABLEERROR_ERROR_ANTDESIGN_TABLE_ROWSELECTION_TYPE_ERROR = 'A-001-001-003'; - /** * @Message("账号被冻结,请联系管理员") */ diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index 6b38c1d..ccd35c2 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -2,12 +2,16 @@ namespace App\Controller; +use App\Component\AntDesign\Constant\Type\FormDateType; +use App\Component\AntDesign\Constant\Type\ValueType; use App\Component\AntDesign\Table; +use App\Constant\Status\AdminStatus; use App\Service\Admin\AdminService; use Hyperf\Di\Annotation\Inject; use Hyperf\HttpServer\Annotation\GetMapping; use Hyperf\HttpServer\Annotation\PostMapping; use Lengbin\Hyperf\Auth\RouterAuthAnnotation; +use Lengbin\Hyperf\Common\Constant\SoftDeleted; use Lengbin\Hyperf\Common\Entity\PageEntity; use Lengbin\Hyperf\Common\Framework\BaseController; use Hyperf\HttpServer\Annotation\Controller; @@ -35,10 +39,118 @@ class TestController extends BaseController public function init() { $table = new Table([ - 'column' => [ - 'admin_id|id', - 'nickname|昵称', - [], + 'column' => [ + [ + 'dataIndex' => 'admin_id', + 'title' => 'id', + 'valueType' => ValueType::INDEX, + ], + [ + 'dataIndex' => 'nickname', + 'title' => '昵称', + 'valueType' => ValueType::TEXT, + ], + [ + 'dataIndex' => 'password', + 'title' => '密码', + 'valueType' => ValueType::PASSWORD, + ], + [ + 'dataIndex' => 'number', + 'title' => '工号', + 'valueType' => ValueType::MONEY, + ], + [ + 'dataIndex' => 'status', + 'title' => '状态', + 'valueType' => ValueType::SELECT, + 'valueEnum' => AdminStatus::getMapJson(), + ], + [ + 'dataIndex' => 'enable', + 'title' => '是否停用', + 'valueType' => ValueType::RADIO, + 'valueEnum' => SoftDeleted::getMapJson(), + ], + [ + 'dataIndex' => 'create_at', + 'title' => '创建时间', + 'valueType' => ValueType::DATE_TIME, + ], + [ + 'dataIndex' => '', + 'title' => '操作', + 'valueType' => ValueType::OPTION, + ], + ], + 'columnConfig' => [ + 'rowKey' => 'admin_id', + 'pagination' => ['pageSize' => 2], + ], + 'pageConfig' => [ + 'submitText' => '提交', + ], + 'form' => [ + [ + 'title' => '基础信息', + 'item' => [ + [ + 'inputType' => 'text', + 'name' => 'nickname', + 'label' => '昵称', + ], + [ + 'inputType' => 'password', + 'name' => 'password', + 'label' => '密码', + ], + [ + 'inputType' => 'checkbox', + 'name' => 'number', + 'label' => '工号', + 'valueEnum' => AdminStatus::getMapJson(), + ], + [ + 'inputType' => 'select', + 'name' => 'status', + 'label' => '状态', + 'valueEnum' => AdminStatus::getMapJson(), + ], + [ + 'inputType' => 'switch', + 'name' => 'enable', + 'label' => '是否停用', + 'checkedChildren' => '左', + 'unCheckedChildren' => '右', + 'valueEnum' => SoftDeleted::getMapJson(), + ], + [ + 'inputType' => 'date', + 'name' => 'create_at', + 'label' => '创建时间', + 'type' => FormDateType::DATE_TIME, + ], + ], + ], + [ + 'title' => '额外', + 'item' => [ + [ + 'inputType' => 'slider', + 'name' => 'slider', + 'label' => '百分比', + 'min' => 0, + 'max' => 100, + ], + [ + 'inputType' => 'rate', + 'name' => 'rate', + 'label' => '分', + 'allowHalf' => true, + 'count' => 6, + ], + ], + ], ], ]); return $this->success($table->toArray()); diff --git a/config/autoload/errorCode.php b/config/autoload/errorCode.php index 8c7c80e..e4708e6 100644 --- a/config/autoload/errorCode.php +++ b/config/autoload/errorCode.php @@ -4,7 +4,6 @@ // 错误码文件 目录 'path' => [ BASE_PATH . '/vendor/lengbin/hyperf-common/src/Error', - BASE_PATH . '/app/Component/AntDesign/Errors', BASE_PATH . '/app/Constant/Errors', ], // 合并生成 类 文件名称 From 2d6f0af46b45d04d2d45e51d56aeca867c6e7156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Thu, 3 Dec 2020 19:17:52 +0800 Subject: [PATCH 36/82] =?UTF-8?q?=E4=BF=AE=E4=BF=AE=E6=94=B9=E6=94=B9?= =?UTF-8?q?=E5=8F=88=E4=B8=80=E5=B9=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/AntDesign/Column/BaseColumn.php | 412 ------------------ app/Component/AntDesign/Column/Column.php | 302 ++++++++++++- app/Component/AntDesign/Column/Search.php | 19 - app/Component/AntDesign/Form/FormCheckbox.php | 9 +- app/Component/AntDesign/Form/FormSelect.php | 11 +- app/Controller/TestController.php | 4 +- 6 files changed, 300 insertions(+), 457 deletions(-) delete mode 100644 app/Component/AntDesign/Column/BaseColumn.php delete mode 100644 app/Component/AntDesign/Column/Search.php diff --git a/app/Component/AntDesign/Column/BaseColumn.php b/app/Component/AntDesign/Column/BaseColumn.php deleted file mode 100644 index 059d5d9..0000000 --- a/app/Component/AntDesign/Column/BaseColumn.php +++ /dev/null @@ -1,412 +0,0 @@ -copyable; - } - - /** - * @param bool $copyable - * - * @return BaseColumn - */ - public function setCopyable(bool $copyable): BaseColumn - { - $this->copyable = $copyable; - return $this; - } - - /** - * @return bool - */ - public function getEllipsis(): bool - { - return $this->ellipsis; - } - - /** - * @param bool $ellipsis - * - * @return BaseColumn - */ - public function setEllipsis(bool $ellipsis): BaseColumn - { - $this->ellipsis = $ellipsis; - return $this; - } - - /** - * @return bool - */ - public function getSearch(): bool - { - return $this->search; - } - - /** - * @param bool $search - * - * @return BaseColumn - */ - public function setSearch(bool $search): BaseColumn - { - $this->search = $search; - return $this; - } - - /** - * @return ValueType - */ - public function getValueType(): ValueType - { - return $this->valueType; - } - - /** - * @param ValueType $valueType - * - * @return BaseColumn - */ - public function setValueType(ValueType $valueType): BaseColumn - { - $this->valueType = $valueType; - return $this; - } - - /** - * @return bool - */ - public function getFilters(): bool - { - return $this->filters; - } - - /** - * @param bool $filters - * - * @return BaseColumn - */ - public function setFilters(bool $filters): BaseColumn - { - $this->filters = $filters; - return $this; - } - - /** - * @return string - */ - public function getDataIndex(): string - { - return $this->dataIndex; - } - - /** - * @param string $dataIndex - * - * @return BaseColumn - */ - public function setDataIndex(string $dataIndex): BaseColumn - { - $this->dataIndex = $dataIndex; - return $this; - } - - /** - * @return string - */ - public function getTitle(): string - { - return $this->title; - } - - /** - * @param string $title - * - * @return BaseColumn - */ - public function setTitle(string $title): BaseColumn - { - $this->title = $title; - return $this; - } - - /** - * @return string - */ - public function getKey(): string - { - return $this->key; - } - - /** - * @param string $key - * - * @return BaseColumn - */ - public function setKey(string $key): BaseColumn - { - $this->key = $key; - return $this; - } - - /** - * @return string - */ - public function getTooltip(): string - { - return $this->tooltip; - } - - /** - * @param string $tooltip - * - * @return BaseColumn - */ - public function setTooltip(string $tooltip): BaseColumn - { - $this->tooltip = $tooltip; - return $this; - } - - /** - * @return string - */ - public function getWidth(): string - { - return $this->width; - } - - /** - * @param string $width - * - * @return BaseColumn - */ - public function setWidth(string $width): BaseColumn - { - $this->width = $width; - return $this; - } - - /** - * @return bool - */ - public function getHideInSearch(): bool - { - return $this->hideInSearch; - } - - /** - * @param bool $hideInSearch - * - * @return BaseColumn - */ - public function setHideInSearch(bool $hideInSearch): BaseColumn - { - $this->hideInSearch = $hideInSearch; - return $this; - } - - /** - * @return bool - */ - public function getHideInTable(): bool - { - return $this->hideInTable; - } - - /** - * @param bool $hideInTable - * - * @return BaseColumn - */ - public function setHideInTable(bool $hideInTable): BaseColumn - { - $this->hideInTable = $hideInTable; - return $this; - } - - /** - * @return array|string - */ - public function getInitialValue() - { - return $this->initialValue; - } - - /** - * @param array|string $initialValue - * - * @return BaseColumn - */ - public function setInitialValue($initialValue): BaseColumn - { - $this->initialValue = $initialValue; - return $this; - } - - /** - * @return array - */ - public function getValueEnum(): array - { - return $this->valueEnum; - } - - /** - * @param ValueEnum[] $valueEnum - * - * @return BaseColumn - */ - public function setValueEnum(array $valueEnum): BaseColumn - { - $this->valueEnum = $valueEnum; - return $this; - } - - protected function check(): void - { - // 必填项验证 - $this->getDataIndex(); - // 进度条 - if ($this->valueType->getValue() === ValueType::PROGRESS) { - $progress = []; - foreach ($this->getValueEnum() as $item) { - $progress[$item->getKey()] = new ProgressType([ - 'text' => $item->getValue(), - 'status' => $item->getStatus(), - ]); - } - $this->valueEnum = $progress; - } - - // 具有 drop 属性 - if (in_array($this->valueType->getValue(), [ - ValueType::SELECT, - ValueType::CHECKBOX, - ValueType::RADIO, - ValueType::RADIO_BUTTON, - ], true)) { - $drops = []; - foreach ($this->getValueEnum() as $item) { - $drops[$item->getKey()] = new ValueEnumType([ - 'text' => $item->getValue(), - 'status' => $item->getStatus(), - ]); - } - $this->valueEnum = $drops; - - // 如果是 select 或者 checkbox 默认为数组 - $initValue = $this->getInitialValue() ?? ''; - if (in_array($this->valueType->getValue(), [ValueType::SELECT, ValueType::CHECKBOX], true) && !is_array($initValue)) { - $initValue ? $this->setInitialValue([$initValue]) : $this->setInitialValue([]) ; - } - } - } - - public function toArray(?object $object = null): array - { - $this->check(); - return parent::toArray($object); // TODO: Change the autogenerated stub - } -} diff --git a/app/Component/AntDesign/Column/Column.php b/app/Component/AntDesign/Column/Column.php index c8d4750..8ac7e3d 100644 --- a/app/Component/AntDesign/Column/Column.php +++ b/app/Component/AntDesign/Column/Column.php @@ -2,16 +2,304 @@ namespace App\Component\AntDesign\Column; +use App\Component\AntDesign\Constant\Type\ValueType; +use Lengbin\Common\Component\BaseObject; + /** - * 列 - * @package App\Component\AntDesign\Column + * 基础 列类 + * @package App\Component\AntDesign + * @see https://github.com/coderlfm/CMS */ -class Column extends BaseColumn +class Column extends BaseObject { - public function init() + /** + * 后端返回数据key + * @var string + */ + protected $dataIndex; + + /** + * 表格/表单标题名 + * @var string + */ + protected $title; + + /** + * 搜索时请求服务器的key名 + * @var string + */ + protected $key; + + /** + * 是否拷贝 + * @var bool + */ + protected $copyable; + + /** + * 超出换行 + * @var bool + */ + protected $ellipsis; + + /** + * 值类型, 默认值text + * @var ValueType + */ + protected $valueType; + + /** + * 表头筛选项,默认值 true 当值为 true 时, 自动使用 valueEnum 生成 类型: boolean | object[] + * @var bool + */ + protected $filters; + + /** + * 当前列值的枚举 + * @var ValueEnum[] + * @see valueType + */ + protected $valueEnum; + + /** + * 会在 title 之后展示一个 icon,hover 之后提示一些信息 + * @var string + */ + protected $tooltip; + + /** + * 宽度 + * @var string + */ + protected $width; + + /** + * @return bool + */ + public function getCopyable(): bool + { + return $this->copyable; + } + + /** + * @param bool $copyable + * + * @return BaseColumn + */ + public function setCopyable(bool $copyable): BaseColumn + { + $this->copyable = $copyable; + return $this; + } + + /** + * @return bool + */ + public function getEllipsis(): bool + { + return $this->ellipsis; + } + + /** + * @param bool $ellipsis + * + * @return BaseColumn + */ + public function setEllipsis(bool $ellipsis): BaseColumn + { + $this->ellipsis = $ellipsis; + return $this; + } + + /** + * @return ValueType + */ + public function getValueType(): ValueType + { + return $this->valueType; + } + + /** + * @param ValueType $valueType + * + * @return BaseColumn + */ + public function setValueType(ValueType $valueType): BaseColumn + { + $this->valueType = $valueType; + return $this; + } + + /** + * @return bool + */ + public function getFilters(): bool + { + return $this->filters; + } + + /** + * @param bool $filters + * + * @return BaseColumn + */ + public function setFilters(bool $filters): BaseColumn + { + $this->filters = $filters; + return $this; + } + + /** + * @return string + */ + public function getDataIndex(): string + { + return $this->dataIndex; + } + + /** + * @param string $dataIndex + * + * @return BaseColumn + */ + public function setDataIndex(string $dataIndex): BaseColumn + { + $this->dataIndex = $dataIndex; + return $this; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $title + * + * @return BaseColumn + */ + public function setTitle(string $title): BaseColumn + { + $this->title = $title; + return $this; + } + + /** + * @return string + */ + public function getKey(): string + { + return $this->key; + } + + /** + * @param string $key + * + * @return BaseColumn + */ + public function setKey(string $key): BaseColumn + { + $this->key = $key; + return $this; + } + + /** + * @return string + */ + public function getTooltip(): string + { + return $this->tooltip; + } + + /** + * @param string $tooltip + * + * @return BaseColumn + */ + public function setTooltip(string $tooltip): BaseColumn + { + $this->tooltip = $tooltip; + return $this; + } + + /** + * @return string + */ + public function getWidth(): string + { + return $this->width; + } + + /** + * @param string $width + * + * @return BaseColumn + */ + public function setWidth(string $width): BaseColumn + { + $this->width = $width; + return $this; + } + + /** + * @return array + */ + public function getValueEnum(): array + { + return $this->valueEnum; + } + + /** + * @param ValueEnum[] $valueEnum + * + * @return BaseColumn + */ + public function setValueEnum(array $valueEnum): BaseColumn + { + $this->valueEnum = $valueEnum; + return $this; + } + + protected function check(): void + { + // 必填项验证 + $this->getDataIndex(); + // 进度条 + if ($this->valueType->getValue() === ValueType::PROGRESS) { + $progress = []; + foreach ($this->getValueEnum() as $item) { + $progress[$item->getKey()] = new ProgressType([ + 'text' => $item->getValue(), + 'status' => $item->getStatus(), + ]); + } + $this->valueEnum = $progress; + } + + // 具有 drop 属性 + if (in_array($this->valueType->getValue(), [ + ValueType::SELECT, + ValueType::CHECKBOX, + ValueType::RADIO, + ValueType::RADIO_BUTTON, + ], true)) { + $drops = []; + foreach ($this->getValueEnum() as $item) { + $drops[$item->getKey()] = new ValueEnumType([ + 'text' => $item->getValue(), + 'status' => $item->getStatus(), + ]); + } + $this->valueEnum = $drops; + } + } + + public function toArray(?object $object = null): array { - // 列 支持 查询,但是不能不显示在table中 - parent::init(); - $this->setHideInTable(false); + $this->check(); + return parent::toArray($object); // TODO: Change the autogenerated stub } } diff --git a/app/Component/AntDesign/Column/Search.php b/app/Component/AntDesign/Column/Search.php deleted file mode 100644 index ace801f..0000000 --- a/app/Component/AntDesign/Column/Search.php +++ /dev/null @@ -1,19 +0,0 @@ -setSearch(true); - $this->setHideInSearch(false); - $this->setHideInTable(true); - } -} diff --git a/app/Component/AntDesign/Form/FormCheckbox.php b/app/Component/AntDesign/Form/FormCheckbox.php index 24a30d1..4bec90c 100644 --- a/app/Component/AntDesign/Form/FormCheckbox.php +++ b/app/Component/AntDesign/Form/FormCheckbox.php @@ -54,14 +54,7 @@ public function getValueEnum(): array */ public function setValueEnum(array $valueEnum): FormCheckbox { - $drops = []; - foreach ($valueEnum as $item) { - $drops[$item->getKey()] = new ValueEnumType([ - 'text' => $item->getValue(), - 'status' => $item->getStatus(), - ]); - } - $this->valueEnum = $drops; + $this->valueEnum = $valueEnum; return $this; } } diff --git a/app/Component/AntDesign/Form/FormSelect.php b/app/Component/AntDesign/Form/FormSelect.php index 0bd9889..ddadc5a 100644 --- a/app/Component/AntDesign/Form/FormSelect.php +++ b/app/Component/AntDesign/Form/FormSelect.php @@ -75,7 +75,7 @@ class FormSelect extends BaseForm private $defaultOpen; /** - * @return array + * @return ValueEnum[] */ public function getValueEnum(): array { @@ -89,14 +89,7 @@ public function getValueEnum(): array */ public function setValueEnum(array $valueEnum): FormSelect { - $drops = []; - foreach ($valueEnum as $item) { - $drops[$item->getKey()] = new ValueEnumType([ - 'text' => $item->getValue(), - 'status' => $item->getStatus(), - ]); - } - $this->valueEnum = $drops; + $this->valueEnum = $valueEnum; return $this; } diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index ccd35c2..ba3d652 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -41,8 +41,8 @@ public function init() $table = new Table([ 'column' => [ [ - 'dataIndex' => 'admin_id', - 'title' => 'id', + 'dataIndex' => '', + 'title' => '序号', 'valueType' => ValueType::INDEX, ], [ From 01cb77344ff384ce8cf57be259819dff5d5e847b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Fri, 4 Dec 2020 23:41:18 +0800 Subject: [PATCH 37/82] =?UTF-8?q?=E8=84=9A=E6=89=8B=E6=9E=B6=20-=20?= =?UTF-8?q?=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/Generate/Template.php | 61 +++++++++++++++++++++++++ app/Component/Generate/View/Curd.tpl | 7 +++ app/Component/Generate/View/Service.tpl | 1 + app/Controller/TestController.php | 10 ++++ composer.json | 3 +- 5 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 app/Component/Generate/Template.php create mode 100644 app/Component/Generate/View/Curd.tpl create mode 100644 app/Component/Generate/View/Service.tpl diff --git a/app/Component/Generate/Template.php b/app/Component/Generate/Template.php new file mode 100644 index 0000000..b4e8111 --- /dev/null +++ b/app/Component/Generate/Template.php @@ -0,0 +1,61 @@ +smarty = new Smarty(); + $this->smarty->setTemplateDir($dir); + $this->smarty->setCacheDir("{$temp}/smarty/cache/"); + $this->smarty->setCompileDir("{$temp}/smarty/compile/"); + $this->smarty->setLeftDelimiter('{{'); + $this->smarty->setRightDelimiter('}}'); + } + + /** + * @param string $template + * @param array $data + * + * @return string|null + * @throws SmartyException + */ + protected function render(string $template, array $data = []): ?string + { + foreach ($data as $key => $item) { + $this->smarty->assign($key, $item); + } + + return $this->smarty->fetch($template); + } + + /** + * 增删改查 + * + * @param array $params + * + * @return string|null + * @throws SmartyException + */ + public function generateCurd(array $params = []): ?string + { + return $this->render('Curd.tpl', $params); + } + +} diff --git a/app/Component/Generate/View/Curd.tpl b/app/Component/Generate/View/Curd.tpl new file mode 100644 index 0000000..369e7e1 --- /dev/null +++ b/app/Component/Generate/View/Curd.tpl @@ -0,0 +1,7 @@ +success($this->request->post()); } + + /** + * @GetMapping(path="/generate") + */ + public function generate() + { + $str = (new Template())->generateCurd(['namespace' => ""]); + return $this->success(['string'=> $str]); + } } diff --git a/composer.json b/composer.json index c51682c..6a77907 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,8 @@ "lengbin/hyperf-common": "dev-master", "lengbin/hyperf-error-code": "dev-main", "daodao97/apidog": "^1.5", - "lengbin/hyperf-yii-rbac": "9999999-dev" + "lengbin/hyperf-yii-rbac": "9999999-dev", + "smarty/smarty": "^3.1" }, "require-dev": { "swoole/ide-helper": "^4.4", From 3ca8ee3a7171cbea21eb80971366ba0b3b0c739c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Mon, 7 Dec 2020 18:39:29 +0800 Subject: [PATCH 38/82] fix bug --- app/Component/User.php | 8 ++------ app/Model/Admin.php | 1 + app/Service/Admin/AdminLoginService.php | 6 +++--- app/Service/Admin/AdminService.php | 7 +++++++ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/Component/User.php b/app/Component/User.php index 81298cb..185ccfd 100644 --- a/app/Component/User.php +++ b/app/Component/User.php @@ -52,12 +52,8 @@ public function findIdentityByToken(string $token, string $type): ?IdentityInter $data = $this->jwt->verifyToken($token); $channel = ArrayHelper::get($data, 'channel', null); // 多服务器 渠道 判断 - switch ($channel) { - case 'admin': - if (ArrayHelper::isValidValue($data, 'admin_id')) { - $user = $this->adminLoginService->findIdentity(['admin_id' => $data['admin_id']]); - } - break; + if ($channel === 'admin' && ArrayHelper::isValidValue($data, 'admin_id')) { + $user = $this->adminLoginService->findIdentity(['admin_id' => $data['admin_id']]); } return $user; } diff --git a/app/Model/Admin.php b/app/Model/Admin.php index 69ee6b9..4a8067c 100644 --- a/app/Model/Admin.php +++ b/app/Model/Admin.php @@ -21,6 +21,7 @@ */ class Admin extends BaseModel implements IdentityInterface { + protected $primaryKey = 'admin_id'; /** * The table associated with the model. * diff --git a/app/Service/Admin/AdminLoginService.php b/app/Service/Admin/AdminLoginService.php index d27977c..912fe6b 100644 --- a/app/Service/Admin/AdminLoginService.php +++ b/app/Service/Admin/AdminLoginService.php @@ -25,7 +25,7 @@ class AdminLoginService extends BaseService /** * check status * - * @param $admin + * @param Admin|null $admin */ protected function checkAdminStatus($admin): void { @@ -37,9 +37,9 @@ protected function checkAdminStatus($admin): void /** * @param array $params * - * @return Admin + * @return Admin|null */ - public function findIdentity(array $params): IdentityInterface + public function findIdentity(array $params): ?IdentityInterface { $admin = Admin::findOneCondition($params); $this->checkAdminStatus($admin); diff --git a/app/Service/Admin/AdminService.php b/app/Service/Admin/AdminService.php index 570e419..a148224 100644 --- a/app/Service/Admin/AdminService.php +++ b/app/Service/Admin/AdminService.php @@ -8,6 +8,13 @@ class AdminService extends BaseService { + /** + * @param array $params + * @param array|string[] $field + * @param PageEntity|null $pageEntity + * + * @return array + */ public function getList(array $params = [], array $field = ['*'], ?PageEntity $pageEntity = null): array { $query = Admin::query(); From 2dfbae57b292b0af605c778813a46a13392f0ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Tue, 8 Dec 2020 01:04:13 +0800 Subject: [PATCH 39/82] =?UTF-8?q?=E8=84=9A=E6=89=8B=E6=9E=B6=20-=20?= =?UTF-8?q?=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/Generate/Config.php | 176 ++++++++++++++++++++++++ app/Component/Generate/Generate.php | 24 ++++ app/Component/Generate/Template.php | 159 ++++++++++++++++++--- app/Component/Generate/View/Class.tpl | 23 ++++ app/Component/Generate/View/Curd.tpl | 7 - app/Component/Generate/View/Service.tpl | 1 - app/Controller/Controller.php | 2 +- 7 files changed, 362 insertions(+), 30 deletions(-) create mode 100644 app/Component/Generate/Config.php create mode 100644 app/Component/Generate/Generate.php create mode 100644 app/Component/Generate/View/Class.tpl delete mode 100644 app/Component/Generate/View/Curd.tpl delete mode 100644 app/Component/Generate/View/Service.tpl diff --git a/app/Component/Generate/Config.php b/app/Component/Generate/Config.php new file mode 100644 index 0000000..ac40e2a --- /dev/null +++ b/app/Component/Generate/Config.php @@ -0,0 +1,176 @@ +namespace; + } + + /** + * @param string $namespace + * + * @return Config + */ + public function setNamespace(string $namespace): Config + { + $this->namespace = $namespace; + return $this; + } + + /** + * @return array + */ + public function getUses(): array + { + return $this->uses; + } + + /** + * @param array $uses + * + * @return Config + */ + public function setUses(array $uses): Config + { + $this->uses = $uses; + return $this; + } + + /** + * @return string + */ + public function getClassname(): string + { + return $this->classname; + } + + /** + * @param string $classname + * + * @return Config + */ + public function setClassname(string $classname): Config + { + $this->classname = $classname; + return $this; + } + + /** + * @return string + */ + public function getInheritance(): string + { + return $this->inheritance; + } + + /** + * @param string $inheritance + * + * @return Config + */ + public function setInheritance(string $inheritance): Config + { + $this->inheritance = $inheritance; + return $this; + } + + /** + * @return string + */ + public function getImplement(): string + { + return $this->implement; + } + + /** + * @param string $implement + * + * @return Config + */ + public function setImplement(string $implement): Config + { + $this->implement = $implement; + return $this; + } + + /** + * @return array + */ + public function getFunctions(): array + { + return $this->functions; + } + + /** + * @param array $functions + * + * @return Config + */ + public function setFunctions(array $functions): Config + { + $this->functions = $functions; + return $this; + } + + /** + * @return array + */ + public function getAnnotations(): array + { + return $this->annotations; + } + + /** + * @param array $annotations + * + * @return Config + */ + public function setAnnotations(array $annotations): Config + { + $this->annotations = $annotations; + return $this; + } +} diff --git a/app/Component/Generate/Generate.php b/app/Component/Generate/Generate.php new file mode 100644 index 0000000..f0f014c --- /dev/null +++ b/app/Component/Generate/Generate.php @@ -0,0 +1,24 @@ +view; + } + + /** + * @param string|null $view + * + * @return Template + */ + public function setView(?string $view): Template + { + $this->view = $view; + return $this; + } + + /** + * @return string|null + */ + public function getCacheDir(): ?string + { + return $this->cacheDir; + } + + /** + * @param string|null $cacheDir + * + * @return Template + */ + public function setCacheDir(?string $cacheDir): Template + { + $this->cacheDir = $cacheDir; + return $this; + } + + /** + * @return string|null + */ + public function getCompileDir(): ?string + { + return $this->compileDir; + } + + /** + * @param string|null $compileDir + * + * @return Template + */ + public function setCompileDir(?string $compileDir): Template + { + $this->compileDir = $compileDir; + return $this; + } + + /** + * @return string + */ + public function getLeftDelimiter(): string + { + return $this->leftDelimiter; + } + + /** + * @param string $leftDelimiter + * + * @return Template + */ + public function setLeftDelimiter(string $leftDelimiter): Template + { + $this->leftDelimiter = $leftDelimiter; + return $this; + } + + /** + * @return string + */ + public function getRightDelimiter(): string + { + return $this->rightDelimiter; + } + + /** + * @param string $rightDelimiter * + * @return Template + */ + public function setRightDelimiter(string $rightDelimiter): Template + { + $this->rightDelimiter = $rightDelimiter; + return $this; + } + + /** + * init */ public function init() { - $dir = __DIR__ . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR; + if ($this->getView() === null) { + $this->setView(__DIR__ . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR); + } + $temp = sys_get_temp_dir(); + if ($this->getCacheDir() === null) { + $this->setCacheDir("{$temp}/smarty/cache/"); + } + + if ($this->getCompileDir() === null) { + $this->setCompileDir("{$temp}/smarty/compile/"); + } + $this->smarty = new Smarty(); - $this->smarty->setTemplateDir($dir); - $this->smarty->setCacheDir("{$temp}/smarty/cache/"); - $this->smarty->setCompileDir("{$temp}/smarty/compile/"); - $this->smarty->setLeftDelimiter('{{'); - $this->smarty->setRightDelimiter('}}'); + $this->smarty->setTemplateDir($this->getView()); + $this->smarty->setCacheDir($this->getCacheDir()); + $this->smarty->setCompileDir($this->getCompileDir()); + $this->smarty->setLeftDelimiter($this->getLeftDelimiter()); + $this->smarty->setRightDelimiter($this->getRightDelimiter()); } /** @@ -36,7 +167,7 @@ public function init() * @return string|null * @throws SmartyException */ - protected function render(string $template, array $data = []): ?string + public function render(string $template, array $data = []): ?string { foreach ($data as $key => $item) { $this->smarty->assign($key, $item); @@ -44,18 +175,4 @@ protected function render(string $template, array $data = []): ?string return $this->smarty->fetch($template); } - - /** - * 增删改查 - * - * @param array $params - * - * @return string|null - * @throws SmartyException - */ - public function generateCurd(array $params = []): ?string - { - return $this->render('Curd.tpl', $params); - } - } diff --git a/app/Component/Generate/View/Class.tpl b/app/Component/Generate/View/Class.tpl new file mode 100644 index 0000000..f97c3ad --- /dev/null +++ b/app/Component/Generate/View/Class.tpl @@ -0,0 +1,23 @@ + $fun}} + {{if $annotation[$name]}} + {{$annotation[$name]}} + {{/if}} + {{$fun}} +{{/foreach}} +{{/if}} +} diff --git a/app/Component/Generate/View/Curd.tpl b/app/Component/Generate/View/Curd.tpl deleted file mode 100644 index 369e7e1..0000000 --- a/app/Component/Generate/View/Curd.tpl +++ /dev/null @@ -1,7 +0,0 @@ - Date: Tue, 8 Dec 2020 23:05:00 +0800 Subject: [PATCH 40/82] =?UTF-8?q?=E8=84=9A=E6=89=8B=E6=9E=B6=20-=20?= =?UTF-8?q?=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/Generate/ClassBase.php | 164 +++++++++++++++++++ app/Component/Generate/ClassMethod.php | 55 +++++++ app/Component/Generate/ClassParams.php | 80 +++++++++ app/Component/Generate/ClassProperty.php | 32 ++++ app/Component/Generate/Config.php | 63 +++---- app/Component/Generate/Generate.php | 4 +- app/Component/Generate/Template.php | 2 +- app/Component/Generate/TemplateInterface.php | 14 ++ app/Component/Generate/View/Class.tpl | 22 ++- 9 files changed, 397 insertions(+), 39 deletions(-) create mode 100644 app/Component/Generate/ClassBase.php create mode 100644 app/Component/Generate/ClassMethod.php create mode 100644 app/Component/Generate/ClassParams.php create mode 100644 app/Component/Generate/ClassProperty.php create mode 100644 app/Component/Generate/TemplateInterface.php diff --git a/app/Component/Generate/ClassBase.php b/app/Component/Generate/ClassBase.php new file mode 100644 index 0000000..b7cbdd1 --- /dev/null +++ b/app/Component/Generate/ClassBase.php @@ -0,0 +1,164 @@ +static; + } + + /** + * @param bool $static + * + * @return ClassBase + */ + public function setStatic(bool $static = true): ClassBase + { + $this->static = $static; + return $this; + } + + /** + * @return bool + */ + public function getPrivate(): bool + { + return $this->private; + } + + /** + * @param bool $private + * + * @return ClassBase + */ + public function setPrivate(bool $private = true): ClassBase + { + $this->private = $private; + if ($private === true) { + $this->setPublic(false); + $this->setProtected(false); + } + return $this; + } + + /** + * @return bool + */ + public function getProtected(): bool + { + return $this->protected; + } + + /** + * @param bool $protected + * + * @return ClassBase + */ + public function setProtected(bool $protected = true): ClassBase + { + $this->protected = $protected; + if ($protected === true) { + $this->setPublic(false); + $this->setPrivate(false); + } + return $this; + } + + /** + * @return bool + */ + public function getPublic(): bool + { + return $this->public; + } + + /** + * @param bool $public + * + * @return ClassBase + */ + public function setPublic(bool $public = true): ClassBase + { + $this->public = $public; + if ($public === true) { + $this->setProtected(false); + $this->setPrivate(false); + } + return $this; + } + + /** + * @return string + */ + public function getComment(): string + { + return $this->comment; + } + + /** + * @param string $comment + * + * @return ClassBase + */ + public function setComment(string $comment): ClassBase + { + $this->comment = $comment; + return $this; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @param string $name + * + * @return ClassBase + */ + public function setName(string $name): ClassBase + { + $this->name = $name; + return $this; + } +} diff --git a/app/Component/Generate/ClassMethod.php b/app/Component/Generate/ClassMethod.php new file mode 100644 index 0000000..3482c6d --- /dev/null +++ b/app/Component/Generate/ClassMethod.php @@ -0,0 +1,55 @@ +final; + } + + /** + * @param bool $final + * + * @return ClassMethod + */ + public function setFinal(bool $final = true): ClassMethod + { + $this->final = $final; + return $this; + } + + /** + * @return ClassParams[] + */ + public function getParams(): array + { + return $this->params; + } + + /** + * @param ClassParams[] $params + * + * @return ClassMethod + */ + public function setParams(array $params): ClassMethod + { + $this->params = $params; + return $this; + } + +} diff --git a/app/Component/Generate/ClassParams.php b/app/Component/Generate/ClassParams.php new file mode 100644 index 0000000..3e5e5e6 --- /dev/null +++ b/app/Component/Generate/ClassParams.php @@ -0,0 +1,80 @@ +name; + } + + /** + * @param string $name + * + * @return ClassParams + */ + public function setName(string $name): ClassParams + { + $this->name = $name; + return $this; + } + + /** + * @return mixed + */ + public function getType() + { + return $this->type; + } + + /** + * @param mixed $type + * + * @return ClassParams + */ + public function setType($type): ClassParams + { + $this->type = $type; + return $this; + } + + /** + * @return string + */ + public function getComment(): string + { + return $this->comment; + } + + /** + * @param string $comment + * + * @return ClassParams + */ + public function setComment(string $comment): ClassParams + { + $this->comment = $comment; + return $this; + } +} diff --git a/app/Component/Generate/ClassProperty.php b/app/Component/Generate/ClassProperty.php new file mode 100644 index 0000000..478d47f --- /dev/null +++ b/app/Component/Generate/ClassProperty.php @@ -0,0 +1,32 @@ +const; + } + + /** + * @param bool $const + * + * @return ClassProperty + */ + public function setConst(bool $const = true): ClassProperty + { + $this->const = $const; + return $this; + } +} diff --git a/app/Component/Generate/Config.php b/app/Component/Generate/Config.php index ac40e2a..baa1357 100644 --- a/app/Component/Generate/Config.php +++ b/app/Component/Generate/Config.php @@ -7,14 +7,14 @@ class Config extends BaseObject { /** - * @var string + * @var ?string */ private $namespace; /** * @var array */ - private $uses; + private $uses = []; /** * @var string @@ -22,29 +22,29 @@ class Config extends BaseObject private $classname; /** - * @var string + * @var ?string */ private $inheritance; /** - * @var string + * @var array */ - private $implement; + private $implements = []; /** - * @var array + * @var ClassMethod[] */ - private $functions; + private $methods = []; /** - * @var array + * @var ClassProperty[] */ - private $annotations; + private $properties = []; /** - * @return string + * @return ?string */ - public function getNamespace(): string + public function getNamespace(): ?string { return $this->namespace; } @@ -99,9 +99,9 @@ public function setClassname(string $classname): Config } /** - * @return string + * @return ?string */ - public function getInheritance(): string + public function getInheritance(): ?string { return $this->inheritance; } @@ -118,59 +118,60 @@ public function setInheritance(string $inheritance): Config } /** - * @return string + * @return array */ - public function getImplement(): string + public function getImplements(): array { - return $this->implement; + return $this->implements; } /** - * @param string $implement + * @param array $implements * * @return Config */ - public function setImplement(string $implement): Config + public function setImplements(array $implements): Config { - $this->implement = $implement; + $this->implements = $implements; return $this; } /** - * @return array + * @return ClassMethod[] */ - public function getFunctions(): array + public function getMethods(): array { - return $this->functions; + return $this->methods; } /** - * @param array $functions + * @param ClassMethod[] $methods * * @return Config */ - public function setFunctions(array $functions): Config + public function setMethods(array $methods): Config { - $this->functions = $functions; + $this->methods = $methods; return $this; } /** - * @return array + * @return ClassProperty[] */ - public function getAnnotations(): array + public function getProperties(): ?array { - return $this->annotations; + return $this->properties; } /** - * @param array $annotations + * @param ClassProperty[] $properties * * @return Config */ - public function setAnnotations(array $annotations): Config + public function setProperties(array $properties): Config { - $this->annotations = $annotations; + $this->properties = $properties; return $this; } + } diff --git a/app/Component/Generate/Generate.php b/app/Component/Generate/Generate.php index f0f014c..37c7fe2 100644 --- a/app/Component/Generate/Generate.php +++ b/app/Component/Generate/Generate.php @@ -17,8 +17,8 @@ class Generate extends BaseObject private $template; /** - * 输出目录 + * 输出路径 * @var string */ - private $output; + private $path; } diff --git a/app/Component/Generate/Template.php b/app/Component/Generate/Template.php index ad279c5..71117d3 100644 --- a/app/Component/Generate/Template.php +++ b/app/Component/Generate/Template.php @@ -6,7 +6,7 @@ use Smarty; use SmartyException; -class Template extends BaseObject +class Template extends BaseObject implements TemplateInterface { /** diff --git a/app/Component/Generate/TemplateInterface.php b/app/Component/Generate/TemplateInterface.php new file mode 100644 index 0000000..41cf88c --- /dev/null +++ b/app/Component/Generate/TemplateInterface.php @@ -0,0 +1,14 @@ + $fun}} - {{if $annotation[$name]}} + +{{if $properties}} +{{foreach $properties as $name => $property}} +{{if $annotation[$name]}} {{$annotation[$name]}} - {{/if}} - {{$fun}} +{{/if}} + {{$property}} + +{{/foreach}} +{{/if}} + +{{if $methods}} +{{foreach $methods as $key => $method}} +{{if $annotation[$key]}} + {{$annotation[$key]}} +{{/if}} + {{$method}} + {{/foreach}} {{/if}} } From 013637763a4c2afb9c119f0472d81bcd8ff2b044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Tue, 8 Dec 2020 23:31:58 +0800 Subject: [PATCH 41/82] =?UTF-8?q?=E8=84=9A=E6=89=8B=E6=9E=B6=20-=20?= =?UTF-8?q?=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/Generate/Generate.php | 99 +++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/app/Component/Generate/Generate.php b/app/Component/Generate/Generate.php index 37c7fe2..95ee82a 100644 --- a/app/Component/Generate/Generate.php +++ b/app/Component/Generate/Generate.php @@ -3,6 +3,8 @@ namespace App\Component\Generate; use Lengbin\Common\Component\BaseObject; +use Lengbin\Helper\Util\FileHelper; +use SmartyException; class Generate extends BaseObject { @@ -21,4 +23,101 @@ class Generate extends BaseObject * @var string */ private $path; + + /** + * @return Config + */ + public function getConfig(): Config + { + return $this->config; + } + + /** + * @param Config $config + * + * @return Generate + */ + public function setConfig(Config $config): Generate + { + $this->config = $config; + return $this; + } + + /** + * @return Template + */ + public function getTemplate(): Template + { + return $this->template; + } + + /** + * @param Template $template + * + * @return Generate + */ + public function setTemplate(Template $template): Generate + { + $this->template = $template; + return $this; + } + + /** + * @return string + */ + public function getPath(): string + { + return $this->path; + } + + /** + * @param string $path + * + * @return Generate + */ + public function setPath(string $path): Generate + { + $this->path = $path; + return $this; + } + + /** + * + * @param string $suffix + * + * @return string + */ + public function getFilePath(string $suffix = 'php'): string + { + $classname = $this->getConfig()->getClassname(); + return implode(DIRECTORY_SEPARATOR, [ + $this->getPath(), + $classname, + '.', + $suffix, + ]); + } + + /** + * @param string $view + * + * @return string + * @throws SmartyException + */ + public function getContent($view = 'Class.tpl'): string + { + return $this->getTemplate()->render($view, $this->getConfig()->toArray()); + } + + /** + * @param string $suffix + * @param string $view + * + * @return bool + * @throws SmartyException + */ + public function output(string $suffix = 'php', $view = 'Class.tpl'): bool + { + return FileHelper::putFile($this->getFilePath($suffix), $this->getContent($view)); + } } From 9c6a283dcba6f8213f85b7ef66a0c53604acf57f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Tue, 8 Dec 2020 23:32:49 +0800 Subject: [PATCH 42/82] =?UTF-8?q?=E8=84=9A=E6=89=8B=E6=9E=B6=20-=20?= =?UTF-8?q?=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/Generate/Generate.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Component/Generate/Generate.php b/app/Component/Generate/Generate.php index 95ee82a..d7e6936 100644 --- a/app/Component/Generate/Generate.php +++ b/app/Component/Generate/Generate.php @@ -89,12 +89,13 @@ public function setPath(string $path): Generate */ public function getFilePath(string $suffix = 'php'): string { + $ext = FileHelper::getExtension($suffix); $classname = $this->getConfig()->getClassname(); return implode(DIRECTORY_SEPARATOR, [ $this->getPath(), $classname, '.', - $suffix, + $ext, ]); } From b1df6284118854b64f8f11036094d74f02190322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Tue, 8 Dec 2020 23:33:22 +0800 Subject: [PATCH 43/82] =?UTF-8?q?=E8=84=9A=E6=89=8B=E6=9E=B6=20-=20?= =?UTF-8?q?=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/Generate/Generate.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Component/Generate/Generate.php b/app/Component/Generate/Generate.php index d7e6936..d744256 100644 --- a/app/Component/Generate/Generate.php +++ b/app/Component/Generate/Generate.php @@ -82,6 +82,7 @@ public function setPath(string $path): Generate } /** + * 获得 输出文件 path * * @param string $suffix * @@ -100,6 +101,8 @@ public function getFilePath(string $suffix = 'php'): string } /** + * 获得 模版内容 + * * @param string $view * * @return string @@ -111,6 +114,8 @@ public function getContent($view = 'Class.tpl'): string } /** + * 输出 + * * @param string $suffix * @param string $view * From aaabf8eccd92999a4200979b58511c07ecd97605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Wed, 9 Dec 2020 01:12:06 +0800 Subject: [PATCH 44/82] =?UTF-8?q?=E8=84=9A=E6=89=8B=E6=9E=B6=20-=20?= =?UTF-8?q?=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/Generate/ClassBase.php | 37 +++++++++++++++++--------- app/Component/Generate/ClassMethod.php | 11 ++++++++ app/Component/Generate/Config.php | 23 ++++++++++++++++ app/Component/Generate/View/Class.tpl | 23 ++-------------- 4 files changed, 60 insertions(+), 34 deletions(-) diff --git a/app/Component/Generate/ClassBase.php b/app/Component/Generate/ClassBase.php index b7cbdd1..e32c964 100644 --- a/app/Component/Generate/ClassBase.php +++ b/app/Component/Generate/ClassBase.php @@ -27,9 +27,9 @@ class ClassBase extends BaseObject protected $public = true; /** - * @var string + * @var array */ - protected $comment = ''; + protected $comments = []; /** * @var string @@ -127,38 +127,49 @@ public function setPublic(bool $public = true): ClassBase /** * @return string */ - public function getComment(): string + public function getName(): string { - return $this->comment; + return $this->name; } /** - * @param string $comment + * @param string $name * * @return ClassBase */ - public function setComment(string $comment): ClassBase + public function setName(string $name): ClassBase { - $this->comment = $comment; + $this->name = $name; return $this; } /** - * @return string + * @return array */ - public function getName(): string + public function getComments(): array { - return $this->name; + return $this->comments; } /** - * @param string $name + * @param array $comments * * @return ClassBase */ - public function setName(string $name): ClassBase + public function setComments(array $comments): ClassBase { - $this->name = $name; + $this->comments = $comments; + return $this; + } + + /** + * @param string $comment + * + * @return ClassBase + */ + public function addComment(string $comment): ClassBase + { + $this->comments[] = $comment; return $this; } } diff --git a/app/Component/Generate/ClassMethod.php b/app/Component/Generate/ClassMethod.php index 3482c6d..dd5b029 100644 --- a/app/Component/Generate/ClassMethod.php +++ b/app/Component/Generate/ClassMethod.php @@ -49,7 +49,18 @@ public function getParams(): array public function setParams(array $params): ClassMethod { $this->params = $params; + $this->init(); return $this; } + public function init() + { + parent::init(); + if (!empty($this->getParams())) { + foreach ($this->getParams() as $params) { + $name = '$' . $params->getName(); + $this->addComment("@param {$params->getType()} {$name}"); + } + } + } } diff --git a/app/Component/Generate/Config.php b/app/Component/Generate/Config.php index baa1357..10a92fd 100644 --- a/app/Component/Generate/Config.php +++ b/app/Component/Generate/Config.php @@ -26,6 +26,11 @@ class Config extends BaseObject */ private $inheritance; + /** + * @var array + */ + private $comments; + /** * @var array */ @@ -174,4 +179,22 @@ public function setProperties(array $properties): Config return $this; } + /** + * @return array + */ + public function getComments(): array + { + return $this->comments; + } + + /** + * @param array $comments + * + * @return Config + */ + public function setComments(array $comments): Config + { + $this->comments = $comments; + return $this; + } } diff --git a/app/Component/Generate/View/Class.tpl b/app/Component/Generate/View/Class.tpl index 141fe66..d114181 100644 --- a/app/Component/Generate/View/Class.tpl +++ b/app/Component/Generate/View/Class.tpl @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace {{$namespace}} +{{if $namespace }}namespace {{$namespace}}{{/if}} {{if $uses }} {{foreach $uses as $use}} @@ -10,26 +10,7 @@ use {{$use}} {{/foreach}} {{/if}} -class {{$classname}} {{if $inheritance }}extends {{$inheritance}}{{/if}} {{if $implement }}implements {{$implement}} {{/if}} +class {{$classname}} {{if $inheritance }}extends {{$inheritance}}{{/if}} {{if $implements }}implements {{foreach $implements as $implement }}{{$implement}}, {{/foreach}} {{/if}} { -{{if $properties}} -{{foreach $properties as $name => $property}} -{{if $annotation[$name]}} - {{$annotation[$name]}} -{{/if}} - {{$property}} - -{{/foreach}} -{{/if}} - -{{if $methods}} -{{foreach $methods as $key => $method}} -{{if $annotation[$key]}} - {{$annotation[$key]}} -{{/if}} - {{$method}} - -{{/foreach}} -{{/if}} } From ee55033cc3523e53d0d539a57d30cb89a9c97317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Wed, 9 Dec 2020 01:14:14 +0800 Subject: [PATCH 45/82] =?UTF-8?q?=E8=84=9A=E6=89=8B=E6=9E=B6=20-=20?= =?UTF-8?q?=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/Generate/ClassBase.php | 3 +++ app/Component/Generate/View/Class.tpl | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/app/Component/Generate/ClassBase.php b/app/Component/Generate/ClassBase.php index e32c964..9e814f7 100644 --- a/app/Component/Generate/ClassBase.php +++ b/app/Component/Generate/ClassBase.php @@ -4,6 +4,9 @@ use Lengbin\Common\Component\BaseObject; +/** + * Class ClassBase + */ class ClassBase extends BaseObject { /** diff --git a/app/Component/Generate/View/Class.tpl b/app/Component/Generate/View/Class.tpl index d114181..fd86025 100644 --- a/app/Component/Generate/View/Class.tpl +++ b/app/Component/Generate/View/Class.tpl @@ -10,6 +10,13 @@ use {{$use}} {{/foreach}} {{/if}} +/** +{{if $comments }} +{{foreach $comments as $comment}} + *{{$comment}} +{{/foreach}} +{{/if}} + */ class {{$classname}} {{if $inheritance }}extends {{$inheritance}}{{/if}} {{if $implements }}implements {{foreach $implements as $implement }}{{$implement}}, {{/foreach}} {{/if}} { From cc6297f8a68042e8a6721dad69bd78f554357f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Wed, 9 Dec 2020 22:52:15 +0800 Subject: [PATCH 46/82] =?UTF-8?q?=E8=84=9A=E6=89=8B=E6=9E=B6=20-=20?= =?UTF-8?q?=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/Generate/Generate.php | 36 +++++++++++++++---- app/Component/Generate/Template.php | 2 +- .../{View/Class.tpl => tpl/class.tpl} | 0 config/autoload/scaffold.php | 5 +++ 4 files changed, 35 insertions(+), 8 deletions(-) rename app/Component/Generate/{View/Class.tpl => tpl/class.tpl} (100%) create mode 100644 config/autoload/scaffold.php diff --git a/app/Component/Generate/Generate.php b/app/Component/Generate/Generate.php index d744256..67efc3b 100644 --- a/app/Component/Generate/Generate.php +++ b/app/Component/Generate/Generate.php @@ -24,6 +24,31 @@ class Generate extends BaseObject */ private $path; + /** + * 模版 + * @var string + */ + private $tpl = 'class.tpl'; + + /** + * @return string + */ + public function getTpl(): string + { + return $this->tpl; + } + + /** + * @param string $tpl + * + * @return Generate + */ + public function setTpl(string $tpl): Generate + { + $this->tpl = $tpl; + return $this; + } + /** * @return Config */ @@ -103,27 +128,24 @@ public function getFilePath(string $suffix = 'php'): string /** * 获得 模版内容 * - * @param string $view - * * @return string * @throws SmartyException */ - public function getContent($view = 'Class.tpl'): string + public function getContent(): string { - return $this->getTemplate()->render($view, $this->getConfig()->toArray()); + return $this->getTemplate()->render($this->getTpl(), $this->getConfig()->toArray()); } /** * 输出 * * @param string $suffix - * @param string $view * * @return bool * @throws SmartyException */ - public function output(string $suffix = 'php', $view = 'Class.tpl'): bool + public function output(string $suffix = 'php'): bool { - return FileHelper::putFile($this->getFilePath($suffix), $this->getContent($view)); + return FileHelper::putFile($this->getFilePath($suffix), $this->getContent()); } } diff --git a/app/Component/Generate/Template.php b/app/Component/Generate/Template.php index 71117d3..6b9135e 100644 --- a/app/Component/Generate/Template.php +++ b/app/Component/Generate/Template.php @@ -140,7 +140,7 @@ public function setRightDelimiter(string $rightDelimiter): Template public function init() { if ($this->getView() === null) { - $this->setView(__DIR__ . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR); + $this->setView(__DIR__ . DIRECTORY_SEPARATOR . 'tpl' . DIRECTORY_SEPARATOR); } $temp = sys_get_temp_dir(); diff --git a/app/Component/Generate/View/Class.tpl b/app/Component/Generate/tpl/class.tpl similarity index 100% rename from app/Component/Generate/View/Class.tpl rename to app/Component/Generate/tpl/class.tpl diff --git a/config/autoload/scaffold.php b/config/autoload/scaffold.php new file mode 100644 index 0000000..ca5d8ed --- /dev/null +++ b/config/autoload/scaffold.php @@ -0,0 +1,5 @@ + Date: Tue, 15 Dec 2020 18:53:51 +0800 Subject: [PATCH 47/82] =?UTF-8?q?=E8=84=9A=E6=89=8B=E6=9E=B6=20-=20?= =?UTF-8?q?=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/Generate/ClassProperty.php | 4 +-- app/Component/Generate/Generate.php | 33 +++++++++++------------- app/Component/Generate/tpl/config.tpl | 0 app/Controller/TestController.php | 32 ++++++++++++++++++++--- config/autoload/scaffold.php | 5 ---- 5 files changed, 44 insertions(+), 30 deletions(-) create mode 100644 app/Component/Generate/tpl/config.tpl delete mode 100644 config/autoload/scaffold.php diff --git a/app/Component/Generate/ClassProperty.php b/app/Component/Generate/ClassProperty.php index 478d47f..d7d3128 100644 --- a/app/Component/Generate/ClassProperty.php +++ b/app/Component/Generate/ClassProperty.php @@ -2,9 +2,7 @@ namespace App\Component\Generate; -use Lengbin\Common\Component\BaseObject; - -class ClassProperty extends BaseObject +class ClassProperty extends ClassBase { /** * @var bool diff --git a/app/Component/Generate/Generate.php b/app/Component/Generate/Generate.php index 67efc3b..4f4bb2f 100644 --- a/app/Component/Generate/Generate.php +++ b/app/Component/Generate/Generate.php @@ -4,7 +4,6 @@ use Lengbin\Common\Component\BaseObject; use Lengbin\Helper\Util\FileHelper; -use SmartyException; class Generate extends BaseObject { @@ -14,7 +13,7 @@ class Generate extends BaseObject private $config; /** - * @var Template + * @var TemplateInterface */ private $template; @@ -69,19 +68,19 @@ public function setConfig(Config $config): Generate } /** - * @return Template + * @return TemplateInterface */ - public function getTemplate(): Template + public function getTemplate(): TemplateInterface { return $this->template; } /** - * @param Template $template + * @param TemplateInterface $template * * @return Generate */ - public function setTemplate(Template $template): Generate + public function setTemplate(TemplateInterface $template): Generate { $this->template = $template; return $this; @@ -95,6 +94,16 @@ public function getPath(): string return $this->path; } + /** + * 获得 模版内容 + * + * @return string + */ + public function getContent(): string + { + return $this->getTemplate()->render($this->getTpl(), $this->getConfig()->toArray()); + } + /** * @param string $path * @@ -125,24 +134,12 @@ public function getFilePath(string $suffix = 'php'): string ]); } - /** - * 获得 模版内容 - * - * @return string - * @throws SmartyException - */ - public function getContent(): string - { - return $this->getTemplate()->render($this->getTpl(), $this->getConfig()->toArray()); - } - /** * 输出 * * @param string $suffix * * @return bool - * @throws SmartyException */ public function output(string $suffix = 'php'): bool { diff --git a/app/Component/Generate/tpl/config.tpl b/app/Component/Generate/tpl/config.tpl new file mode 100644 index 0000000..e69de29 diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index 47aab43..0fec9c3 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -5,8 +5,8 @@ use App\Component\AntDesign\Constant\Type\FormDateType; use App\Component\AntDesign\Constant\Type\ValueType; use App\Component\AntDesign\Table; -use App\Component\Generate\Template; -use App\Constant\Status\AdminStatus; +use App\Component\Generate\Config; +//use App\Constant\Status\AdminStatus; use App\Service\Admin\AdminService; use Hyperf\Di\Annotation\Inject; use Hyperf\HttpServer\Annotation\GetMapping; @@ -203,7 +203,31 @@ public function remove() */ public function generate() { - $str = (new Template())->generateCurd(['namespace' => ""]); - return $this->success(['string'=> $str]); + $data = [ + 'namespace' => 'App\Controller', + 'classname' => 'AdminController', + 'uses' => [ + 'Hyperf\HttpServer\Annotation\Controller', + 'Lengbin\Hyperf\Auth\RouterAuthAnnotation', + 'Lengbin\Hyperf\Common\Framework\BaseController' + ], + 'comments' => [ + 'Class AdminController', + '@package App\Controller', + '@Controller()', + '@RouterAuthAnnotation(isPublic=true)' + ], + 'inheritance' => 'BaseController', + 'properties' => [ + ["name" => 'abc'], + ["name" => 'abc2'] + ], + ]; + $config = new Config($data); + + $str = $config->__toObjectString(); + file_put_contents(BASE_PATH . '/app/Controller/a.php', "success(['array' => $config->toArray(), 'string' => $str]); } } diff --git a/config/autoload/scaffold.php b/config/autoload/scaffold.php deleted file mode 100644 index ca5d8ed..0000000 --- a/config/autoload/scaffold.php +++ /dev/null @@ -1,5 +0,0 @@ - Date: Wed, 16 Dec 2020 01:20:50 +0800 Subject: [PATCH 48/82] =?UTF-8?q?class=20=E6=96=87=E4=BB=B6=20=E7=94=9F?= =?UTF-8?q?=E6=88=90=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/Generate/AbstractConfig.php | 30 ++ .../Generate/{ => ClassFile}/ClassBase.php | 2 +- .../Generate/{ => ClassFile}/ClassMethod.php | 2 +- .../Generate/{ => ClassFile}/ClassParams.php | 2 +- .../{ => ClassFile}/ClassProperty.php | 2 +- app/Component/Generate/ClassFile/Config.php | 331 ++++++++++++++++++ app/Component/Generate/Config.php | 200 ----------- app/Component/Generate/Generate.php | 113 +----- app/Component/Generate/Generate2.php | 148 ++++++++ app/Controller/TestController.php | 32 +- 10 files changed, 547 insertions(+), 315 deletions(-) create mode 100644 app/Component/Generate/AbstractConfig.php rename app/Component/Generate/{ => ClassFile}/ClassBase.php (98%) rename app/Component/Generate/{ => ClassFile}/ClassMethod.php (96%) rename app/Component/Generate/{ => ClassFile}/ClassParams.php (96%) rename app/Component/Generate/{ => ClassFile}/ClassProperty.php (90%) create mode 100644 app/Component/Generate/ClassFile/Config.php delete mode 100644 app/Component/Generate/Config.php create mode 100644 app/Component/Generate/Generate2.php diff --git a/app/Component/Generate/AbstractConfig.php b/app/Component/Generate/AbstractConfig.php new file mode 100644 index 0000000..7a61f26 --- /dev/null +++ b/app/Component/Generate/AbstractConfig.php @@ -0,0 +1,30 @@ +namespace; + } + + /** + * @param string $namespace + * + * @return Config + */ + public function setNamespace(string $namespace): Config + { + $this->namespace = $namespace; + return $this; + } + + /** + * @return array + */ + public function getUses(): array + { + return $this->uses; + } + + /** + * @param array $uses + * + * @return Config + */ + public function setUses(array $uses): Config + { + $this->uses = $uses; + return $this; + } + + /** + * @return string + */ + public function getClassname(): string + { + return $this->classname; + } + + /** + * @param string $classname + * + * @return Config + */ + public function setClassname(string $classname): Config + { + $this->classname = $classname; + return $this; + } + + /** + * @return ?string + */ + public function getInheritance(): ?string + { + return $this->inheritance; + } + + /** + * @param string $inheritance + * + * @return Config + */ + public function setInheritance(string $inheritance): Config + { + $this->inheritance = $inheritance; + return $this; + } + + /** + * @return array + */ + public function getImplements(): array + { + return $this->implements; + } + + /** + * @param array $implements + * + * @return Config + */ + public function setImplements(array $implements): Config + { + $this->implements = $implements; + return $this; + } + + /** + * @return ClassMethod[] + */ + public function getMethods(): array + { + return $this->methods; + } + + /** + * @param ClassMethod[] $methods + * + * @return Config + */ + public function setMethods(array $methods): Config + { + $this->methods = $methods; + return $this; + } + + /** + * @return ClassProperty[] + */ + public function getProperties(): ?array + { + return $this->properties; + } + + /** + * @param ClassProperty[] $properties + * + * @return Config + */ + public function setProperties(array $properties): Config + { + $this->properties = $properties; + return $this; + } + + /** + * @return array + */ + public function getComments(): array + { + return $this->comments; + } + + /** + * @param array $comments + * + * @return Config + */ + public function setComments(array $comments): Config + { + $this->comments = $comments; + return $this; + } + + /** + * @return string + */ + public function getFileName(): string + { + return $this->getClassname(); + } + + /** + * @param string $str + * @param array $comments + * + * @return string + */ + protected function renderComment(string $str, array $comments = []): string + { + $str .= "/**\n"; + foreach ($comments as $comment) { + $str .= " * {$comment}\n"; + } + $str .= " */\n"; + return $str; + } + + /** + * @param ClassBase $classBase + * + * @return string + */ + protected function getScope(ClassBase $classBase): string + { + $str = ''; + if ($classBase->getPublic()) { + $str = 'public'; + } + + if ($classBase->getProtected()) { + $str = 'protected'; + } + + if ($classBase->getPrivate()) { + $str = 'private'; + } + + if ($classBase->getStatic()) { + $str .= ' static'; + } + return $str; + } + + protected function renderProperty(string $str): string + { + if (!empty($this->getProperties())) { + // constant + foreach ($this->getProperties() as $classProperty) { + if (!$classProperty->getConst()) { + continue; + } + if (!empty($classProperty->getComments())) { + $str = $this->renderComment($str, $classProperty->getComments()); + } + $str .= "{$this->getScope($classProperty)} $" . $classProperty->getName() . ";\n"; + } + // property + foreach ($this->getProperties() as $classProperty) { + if ($classProperty->getConst()) { + continue; + } + if (!empty($classProperty->getComments())) { + $str = $this->renderComment($str, $classProperty->getComments()); + } + $str .= "{$this->getScope($classProperty)} $" . $classProperty->getName() . ";\n"; + } + } + return $str; + } + + protected function renderMethod(string $str): string + { + return $str; + } + + /** + * @return string + */ + public function getContent(): string + { + // getNamespace())) { + $str .= "namespace {$this->getNamespace()};\n\n"; + } + + // uses + if (!empty($this->getUses())) { + foreach ($this->getUses() as $use) { + $str .= "use {$use};\n"; + } + $str .= "\n"; + } + + // class comment + if (!empty($this->getComments())) { + $str = $this->renderComment($str, $this->getComments()); + } + + // class + $str .= "class {$this->getClassname()}"; + if (!empty($this->getInheritance())) { + $str .= " extends {$this->getInheritance()}"; + } + if (!empty($this->getImplements())) { + $implement = implode(', ', $this->getImplements()); + $str .= " implements {$implement}"; + } + $str .= "\n{\n"; + + if (empty($this->getProperties()) && empty($this->getMethods())) { + $str .= "{$this->getSpaces()}\n"; + } else { + // properties + $str = $this->renderProperty($str); + // methods + $str = $this->renderMethod($str); + } + $str .= "}\n"; + return $str; + } +} diff --git a/app/Component/Generate/Config.php b/app/Component/Generate/Config.php deleted file mode 100644 index 10a92fd..0000000 --- a/app/Component/Generate/Config.php +++ /dev/null @@ -1,200 +0,0 @@ -namespace; - } - - /** - * @param string $namespace - * - * @return Config - */ - public function setNamespace(string $namespace): Config - { - $this->namespace = $namespace; - return $this; - } - - /** - * @return array - */ - public function getUses(): array - { - return $this->uses; - } - - /** - * @param array $uses - * - * @return Config - */ - public function setUses(array $uses): Config - { - $this->uses = $uses; - return $this; - } - - /** - * @return string - */ - public function getClassname(): string - { - return $this->classname; - } - - /** - * @param string $classname - * - * @return Config - */ - public function setClassname(string $classname): Config - { - $this->classname = $classname; - return $this; - } - - /** - * @return ?string - */ - public function getInheritance(): ?string - { - return $this->inheritance; - } - - /** - * @param string $inheritance - * - * @return Config - */ - public function setInheritance(string $inheritance): Config - { - $this->inheritance = $inheritance; - return $this; - } - - /** - * @return array - */ - public function getImplements(): array - { - return $this->implements; - } - - /** - * @param array $implements - * - * @return Config - */ - public function setImplements(array $implements): Config - { - $this->implements = $implements; - return $this; - } - - /** - * @return ClassMethod[] - */ - public function getMethods(): array - { - return $this->methods; - } - - /** - * @param ClassMethod[] $methods - * - * @return Config - */ - public function setMethods(array $methods): Config - { - $this->methods = $methods; - return $this; - } - - /** - * @return ClassProperty[] - */ - public function getProperties(): ?array - { - return $this->properties; - } - - /** - * @param ClassProperty[] $properties - * - * @return Config - */ - public function setProperties(array $properties): Config - { - $this->properties = $properties; - return $this; - } - - /** - * @return array - */ - public function getComments(): array - { - return $this->comments; - } - - /** - * @param array $comments - * - * @return Config - */ - public function setComments(array $comments): Config - { - $this->comments = $comments; - return $this; - } -} diff --git a/app/Component/Generate/Generate.php b/app/Component/Generate/Generate.php index 4f4bb2f..580a680 100644 --- a/app/Component/Generate/Generate.php +++ b/app/Component/Generate/Generate.php @@ -2,21 +2,10 @@ namespace App\Component\Generate; -use Lengbin\Common\Component\BaseObject; use Lengbin\Helper\Util\FileHelper; -class Generate extends BaseObject +class Generate { - /** - * @var Config - */ - private $config; - - /** - * @var TemplateInterface - */ - private $template; - /** * 输出路径 * @var string @@ -24,125 +13,59 @@ class Generate extends BaseObject private $path; /** - * 模版 - * @var string + * @var AbstractConfig */ - private $tpl = 'class.tpl'; + private $config; /** * @return string */ - public function getTpl(): string + public function getPath(): string { - return $this->tpl; + return $this->path; } /** - * @param string $tpl + * @param string $path * * @return Generate */ - public function setTpl(string $tpl): Generate + public function setPath(string $path): Generate { - $this->tpl = $tpl; + $this->path = $path; return $this; } /** - * @return Config + * @return AbstractConfig */ - public function getConfig(): Config + public function getConfig(): AbstractConfig { return $this->config; } /** - * @param Config $config + * @param AbstractConfig $config * * @return Generate */ - public function setConfig(Config $config): Generate + public function setConfig(AbstractConfig $config): Generate { $this->config = $config; return $this; } /** - * @return TemplateInterface - */ - public function getTemplate(): TemplateInterface - { - return $this->template; - } - - /** - * @param TemplateInterface $template - * - * @return Generate - */ - public function setTemplate(TemplateInterface $template): Generate - { - $this->template = $template; - return $this; - } - - /** - * @return string - */ - public function getPath(): string - { - return $this->path; - } - - /** - * 获得 模版内容 - * - * @return string - */ - public function getContent(): string - { - return $this->getTemplate()->render($this->getTpl(), $this->getConfig()->toArray()); - } - - /** - * @param string $path - * - * @return Generate - */ - public function setPath(string $path): Generate - { - $this->path = $path; - return $this; - } - - /** - * 获得 输出文件 path - * - * @param string $suffix - * - * @return string - */ - public function getFilePath(string $suffix = 'php'): string - { - $ext = FileHelper::getExtension($suffix); - $classname = $this->getConfig()->getClassname(); - return implode(DIRECTORY_SEPARATOR, [ - $this->getPath(), - $classname, - '.', - $ext, - ]); - } - - /** - * 输出 - * * @param string $suffix * * @return bool */ - public function output(string $suffix = 'php'): bool + public function output(string $suffix): bool { - return FileHelper::putFile($this->getFilePath($suffix), $this->getContent()); + $file = implode(DIRECTORY_SEPARATOR, [ + $this->getPath(), + $this->getConfig()->getFileName(), + ]) . '.' . FileHelper::getExtension($suffix); + return FileHelper::putFile($file, $this->getConfig()->getContent()); } } diff --git a/app/Component/Generate/Generate2.php b/app/Component/Generate/Generate2.php new file mode 100644 index 0000000..866d841 --- /dev/null +++ b/app/Component/Generate/Generate2.php @@ -0,0 +1,148 @@ +tpl; + } + + /** + * @param string $tpl + * + * @return Generate2 + */ + public function setTpl(string $tpl): Generate2 + { + $this->tpl = $tpl; + return $this; + } + + /** + * @return Config + */ + public function getConfig(): Config + { + return $this->config; + } + + /** + * @param Config $config + * + * @return Generate2 + */ + public function setConfig(Config $config): Generate2 + { + $this->config = $config; + return $this; + } + + /** + * @return TemplateInterface + */ + public function getTemplate(): TemplateInterface + { + return $this->template; + } + + /** + * @param TemplateInterface $template + * + * @return Generate2 + */ + public function setTemplate(TemplateInterface $template): Generate2 + { + $this->template = $template; + return $this; + } + + /** + * @return string + */ + public function getPath(): string + { + return $this->path; + } + + /** + * 获得 模版内容 + * + * @return string + */ + public function getContent(): string + { + return $this->getTemplate()->render($this->getTpl(), $this->getConfig()->toArray()); + } + + /** + * @param string $path + * + * @return Generate2 + */ + public function setPath(string $path): Generate2 + { + $this->path = $path; + return $this; + } + + /** + * 获得 输出文件 path + * + * @param string $suffix + * + * @return string + */ + public function getFilePath(string $suffix = 'php'): string + { + $ext = FileHelper::getExtension($suffix); + $classname = $this->getConfig()->getClassname(); + return implode(DIRECTORY_SEPARATOR, [ + $this->getPath(), + $classname, + '.', + $ext, + ]); + } + + /** + * 输出 + * + * @param string $suffix + * + * @return bool + */ + public function output(string $suffix = 'php'): bool + { + return FileHelper::putFile($this->getFilePath($suffix), $this->getContent()); + } +} diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index 0fec9c3..0cb5e25 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -5,8 +5,8 @@ use App\Component\AntDesign\Constant\Type\FormDateType; use App\Component\AntDesign\Constant\Type\ValueType; use App\Component\AntDesign\Table; -use App\Component\Generate\Config; -//use App\Constant\Status\AdminStatus; +use App\Component\Generate\ClassFile\Config; +use App\Component\Generate\Generate; use App\Service\Admin\AdminService; use Hyperf\Di\Annotation\Inject; use Hyperf\HttpServer\Annotation\GetMapping; @@ -204,30 +204,30 @@ public function remove() public function generate() { $data = [ - 'namespace' => 'App\Controller', - 'classname' => 'AdminController', - 'uses' => [ + 'namespace' => 'App\Controller', + 'classname' => 'AdminController', + 'uses' => [ 'Hyperf\HttpServer\Annotation\Controller', 'Lengbin\Hyperf\Auth\RouterAuthAnnotation', - 'Lengbin\Hyperf\Common\Framework\BaseController' + 'Lengbin\Hyperf\Common\Framework\BaseController', ], - 'comments' => [ + 'comments' => [ 'Class AdminController', '@package App\Controller', '@Controller()', - '@RouterAuthAnnotation(isPublic=true)' + '@RouterAuthAnnotation(isPublic=true)', ], 'inheritance' => 'BaseController', - 'properties' => [ - ["name" => 'abc'], - ["name" => 'abc2'] - ], +// 'properties' => [ +// ["name" => 'abc'], +// ["name" => 'abc2'], +// ], ]; - $config = new Config($data); - $str = $config->__toObjectString(); - file_put_contents(BASE_PATH . '/app/Controller/a.php', "setPath(BASE_PATH . '/app/Controller'); + $generate->setConfig(new Config($data)); - return $this->success(['array' => $config->toArray(), 'string' => $str]); + return $this->success(['a' => $generate->output('php')]); } } From 1906f1b351691f6165cff2a259a0bd75a8c42151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Wed, 16 Dec 2020 01:22:25 +0800 Subject: [PATCH 49/82] =?UTF-8?q?class=20=E6=96=87=E4=BB=B6=20=E7=94=9F?= =?UTF-8?q?=E6=88=90=202=EF=BC=8C=20=E5=8E=BB=E6=8E=89=E6=A8=A1=E7=89=88?= =?UTF-8?q?=E5=BC=95=E6=93=8E=20=20=E8=87=AA=E5=B7=B1=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/Generate/Generate2.php | 148 --------------- app/Component/Generate/Template.php | 178 ------------------- app/Component/Generate/TemplateInterface.php | 14 -- app/Component/Generate/tpl/class.tpl | 23 --- app/Component/Generate/tpl/config.tpl | 0 composer.json | 3 +- 6 files changed, 1 insertion(+), 365 deletions(-) delete mode 100644 app/Component/Generate/Generate2.php delete mode 100644 app/Component/Generate/Template.php delete mode 100644 app/Component/Generate/TemplateInterface.php delete mode 100644 app/Component/Generate/tpl/class.tpl delete mode 100644 app/Component/Generate/tpl/config.tpl diff --git a/app/Component/Generate/Generate2.php b/app/Component/Generate/Generate2.php deleted file mode 100644 index 866d841..0000000 --- a/app/Component/Generate/Generate2.php +++ /dev/null @@ -1,148 +0,0 @@ -tpl; - } - - /** - * @param string $tpl - * - * @return Generate2 - */ - public function setTpl(string $tpl): Generate2 - { - $this->tpl = $tpl; - return $this; - } - - /** - * @return Config - */ - public function getConfig(): Config - { - return $this->config; - } - - /** - * @param Config $config - * - * @return Generate2 - */ - public function setConfig(Config $config): Generate2 - { - $this->config = $config; - return $this; - } - - /** - * @return TemplateInterface - */ - public function getTemplate(): TemplateInterface - { - return $this->template; - } - - /** - * @param TemplateInterface $template - * - * @return Generate2 - */ - public function setTemplate(TemplateInterface $template): Generate2 - { - $this->template = $template; - return $this; - } - - /** - * @return string - */ - public function getPath(): string - { - return $this->path; - } - - /** - * 获得 模版内容 - * - * @return string - */ - public function getContent(): string - { - return $this->getTemplate()->render($this->getTpl(), $this->getConfig()->toArray()); - } - - /** - * @param string $path - * - * @return Generate2 - */ - public function setPath(string $path): Generate2 - { - $this->path = $path; - return $this; - } - - /** - * 获得 输出文件 path - * - * @param string $suffix - * - * @return string - */ - public function getFilePath(string $suffix = 'php'): string - { - $ext = FileHelper::getExtension($suffix); - $classname = $this->getConfig()->getClassname(); - return implode(DIRECTORY_SEPARATOR, [ - $this->getPath(), - $classname, - '.', - $ext, - ]); - } - - /** - * 输出 - * - * @param string $suffix - * - * @return bool - */ - public function output(string $suffix = 'php'): bool - { - return FileHelper::putFile($this->getFilePath($suffix), $this->getContent()); - } -} diff --git a/app/Component/Generate/Template.php b/app/Component/Generate/Template.php deleted file mode 100644 index 6b9135e..0000000 --- a/app/Component/Generate/Template.php +++ /dev/null @@ -1,178 +0,0 @@ -view; - } - - /** - * @param string|null $view - * - * @return Template - */ - public function setView(?string $view): Template - { - $this->view = $view; - return $this; - } - - /** - * @return string|null - */ - public function getCacheDir(): ?string - { - return $this->cacheDir; - } - - /** - * @param string|null $cacheDir - * - * @return Template - */ - public function setCacheDir(?string $cacheDir): Template - { - $this->cacheDir = $cacheDir; - return $this; - } - - /** - * @return string|null - */ - public function getCompileDir(): ?string - { - return $this->compileDir; - } - - /** - * @param string|null $compileDir - * - * @return Template - */ - public function setCompileDir(?string $compileDir): Template - { - $this->compileDir = $compileDir; - return $this; - } - - /** - * @return string - */ - public function getLeftDelimiter(): string - { - return $this->leftDelimiter; - } - - /** - * @param string $leftDelimiter - * - * @return Template - */ - public function setLeftDelimiter(string $leftDelimiter): Template - { - $this->leftDelimiter = $leftDelimiter; - return $this; - } - - /** - * @return string - */ - public function getRightDelimiter(): string - { - return $this->rightDelimiter; - } - - /** - * @param string $rightDelimiter - * - * @return Template - */ - public function setRightDelimiter(string $rightDelimiter): Template - { - $this->rightDelimiter = $rightDelimiter; - return $this; - } - - /** - * init - */ - public function init() - { - if ($this->getView() === null) { - $this->setView(__DIR__ . DIRECTORY_SEPARATOR . 'tpl' . DIRECTORY_SEPARATOR); - } - - $temp = sys_get_temp_dir(); - if ($this->getCacheDir() === null) { - $this->setCacheDir("{$temp}/smarty/cache/"); - } - - if ($this->getCompileDir() === null) { - $this->setCompileDir("{$temp}/smarty/compile/"); - } - - $this->smarty = new Smarty(); - $this->smarty->setTemplateDir($this->getView()); - $this->smarty->setCacheDir($this->getCacheDir()); - $this->smarty->setCompileDir($this->getCompileDir()); - $this->smarty->setLeftDelimiter($this->getLeftDelimiter()); - $this->smarty->setRightDelimiter($this->getRightDelimiter()); - } - - /** - * @param string $template - * @param array $data - * - * @return string|null - * @throws SmartyException - */ - public function render(string $template, array $data = []): ?string - { - foreach ($data as $key => $item) { - $this->smarty->assign($key, $item); - } - - return $this->smarty->fetch($template); - } -} diff --git a/app/Component/Generate/TemplateInterface.php b/app/Component/Generate/TemplateInterface.php deleted file mode 100644 index 41cf88c..0000000 --- a/app/Component/Generate/TemplateInterface.php +++ /dev/null @@ -1,14 +0,0 @@ - Date: Wed, 16 Dec 2020 15:56:22 +0800 Subject: [PATCH 50/82] =?UTF-8?q?class=20=E6=96=87=E4=BB=B6=20=E7=94=9F?= =?UTF-8?q?=E6=88=90=203,=20=E6=B7=BB=E5=8A=A0=E7=B1=BB=E7=9A=84=20?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Generate/ClassFile/ClassBase.php | 5 + .../Generate/ClassFile/ClassConstant.php | 19 ++ .../Generate/ClassFile/ClassProperty.php | 22 --- app/Component/Generate/ClassFile/Config.php | 184 +++++++++++++++++- app/Controller/TestController.php | 13 +- 5 files changed, 213 insertions(+), 30 deletions(-) create mode 100644 app/Component/Generate/ClassFile/ClassConstant.php diff --git a/app/Component/Generate/ClassFile/ClassBase.php b/app/Component/Generate/ClassFile/ClassBase.php index b9228b8..ec4703b 100644 --- a/app/Component/Generate/ClassFile/ClassBase.php +++ b/app/Component/Generate/ClassFile/ClassBase.php @@ -39,6 +39,11 @@ class ClassBase extends BaseObject */ protected $name; + /** + * @var mixed + */ + protected $default; + /** * @return bool */ diff --git a/app/Component/Generate/ClassFile/ClassConstant.php b/app/Component/Generate/ClassFile/ClassConstant.php new file mode 100644 index 0000000..9247824 --- /dev/null +++ b/app/Component/Generate/ClassFile/ClassConstant.php @@ -0,0 +1,19 @@ +const; + } +} diff --git a/app/Component/Generate/ClassFile/ClassProperty.php b/app/Component/Generate/ClassFile/ClassProperty.php index 247fa07..3c9c153 100644 --- a/app/Component/Generate/ClassFile/ClassProperty.php +++ b/app/Component/Generate/ClassFile/ClassProperty.php @@ -4,27 +4,5 @@ class ClassProperty extends ClassBase { - /** - * @var bool - */ - private $const = false; - /** - * @return bool - */ - public function getConst(): bool - { - return $this->const; - } - - /** - * @param bool $const - * - * @return ClassProperty - */ - public function setConst(bool $const = true): ClassProperty - { - $this->const = $const; - return $this; - } } diff --git a/app/Component/Generate/ClassFile/Config.php b/app/Component/Generate/ClassFile/Config.php index 2161caa..a28eb61 100644 --- a/app/Component/Generate/ClassFile/Config.php +++ b/app/Component/Generate/ClassFile/Config.php @@ -3,9 +3,25 @@ namespace App\Component\Generate\ClassFile; use App\Component\Generate\AbstractConfig; +use Lengbin\Helper\YiiSoft\StringHelper; class Config extends AbstractConfig { + /** + * @var bool + */ + private $final = false; + + /** + * @var bool + */ + private $abstract = false; + + /** + * @var bool + */ + private $interface = false; + /** * @var ?string */ @@ -29,13 +45,18 @@ class Config extends AbstractConfig /** * @var array */ - private $comments; + private $comments = []; /** * @var array */ private $implements = []; + /** + * @var ClassConstant[] + */ + private $constants = []; + /** * @var ClassMethod[] */ @@ -206,6 +227,150 @@ public function getFileName(): string return $this->getClassname(); } + public function addUse(string $use): Config + { + $this->uses[] = $use; + return $this; + } + + /** + * @param string $comment + * + * @return $this + */ + public function addComment(string $comment): Config + { + $this->comments[] = $comment; + return $this; + } + + /** + * @param string $implement + * + * @return $this + */ + public function addImplement(string $implement): Config + { + $this->implements[] = $implement; + return $this; + } + + /** + * @param ClassMethod $classMethod + * + * @return $this + */ + public function addMethod(ClassMethod $classMethod): Config + { + $this->methods[] = $classMethod; + return $this; + } + + /** + * @param ClassProperty $classProperty + * + * @return $this + */ + public function addProperty(ClassProperty $classProperty): Config + { + $this->properties[] = $classProperty; + return $this; + } + + /** + * @param ClassConstant $constant + * + * @return $this + */ + public function addCont(ClassConstant $constant): Config + { + $this->constants[] = $constant; + return $this; + } + + /** + * @return bool + */ + public function getFinal(): bool + { + return $this->final; + } + + /** + * @param bool $final + * + * @return Config + */ + public function setFinal(bool $final): Config + { + $this->final = $final; + if ($final === true) { + $this->setAbstract(false); + } + return $this; + } + + /** + * @return bool + */ + public function getAbstract(): bool + { + return $this->abstract; + } + + /** + * @param bool $abstract + * + * @return Config + */ + public function setAbstract(bool $abstract): Config + { + $this->abstract = $abstract; + if ($abstract === true) { + $this->setFinal(false); + } + return $this; + } + + /** + * @return ClassConstant[] + */ + public function getConstants(): array + { + return $this->constants; + } + + /** + * @param ClassConstant[] $constants + * + * @return Config + */ + public function setConstants(array $constants): Config + { + $this->constants = $constants; + return $this; + } + + /** + * @return bool + */ + public function getInterface(): bool + { + return $this->interface; + } + + /** + * @param bool $interface + * + * @return Config + */ + public function setInterface(bool $interface): Config + { + $this->interface = $interface; + return $this; + } + + /** * @param string $str * @param array $comments @@ -223,6 +388,8 @@ protected function renderComment(string $str, array $comments = []): string } /** + * 获取 作用域 + * * @param ClassBase $classBase * * @return string @@ -259,7 +426,7 @@ protected function renderProperty(string $str): string if (!empty($classProperty->getComments())) { $str = $this->renderComment($str, $classProperty->getComments()); } - $str .= "{$this->getScope($classProperty)} $" . $classProperty->getName() . ";\n"; + $str .= "{$this->getScope($classProperty)}" . StringHelper::strtoupper($classProperty->getName(), 'utf8') . ";\n"; } // property foreach ($this->getProperties() as $classProperty) { @@ -305,8 +472,17 @@ public function getContent(): string if (!empty($this->getComments())) { $str = $this->renderComment($str, $this->getComments()); } - // class + + // + if ($this->getFinal()) { + + } + + if ($this->getAbstract()) { + + } + $str .= "class {$this->getClassname()}"; if (!empty($this->getInheritance())) { $str .= " extends {$this->getInheritance()}"; @@ -315,8 +491,8 @@ public function getContent(): string $implement = implode(', ', $this->getImplements()); $str .= " implements {$implement}"; } - $str .= "\n{\n"; + $str .= "\n{\n"; if (empty($this->getProperties()) && empty($this->getMethods())) { $str .= "{$this->getSpaces()}\n"; } else { diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index 0cb5e25..08f59e0 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -7,6 +7,7 @@ use App\Component\AntDesign\Table; use App\Component\Generate\ClassFile\Config; use App\Component\Generate\Generate; +use App\Constant\Status\AdminStatus; use App\Service\Admin\AdminService; use Hyperf\Di\Annotation\Inject; use Hyperf\HttpServer\Annotation\GetMapping; @@ -218,10 +219,14 @@ public function generate() '@RouterAuthAnnotation(isPublic=true)', ], 'inheritance' => 'BaseController', -// 'properties' => [ -// ["name" => 'abc'], -// ["name" => 'abc2'], -// ], + 'constants' => [ + ['name' => 'success', 'default' => 0], + ], + 'properties' => [ + ["name" => 'abc', 'default' => 1.3], + ["name" => 'abc2', 'default' => "hello world"], + ["name" => 'abc3', 'default' => true], + ], ]; $generate = new Generate(); From e81d84b4b900a76cb504739a1fd225d2dbc3856f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Thu, 17 Dec 2020 01:48:23 +0800 Subject: [PATCH 51/82] =?UTF-8?q?class=20=E6=96=87=E4=BB=B6=20=E7=94=9F?= =?UTF-8?q?=E6=88=90=204,=20=E5=B7=AE=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Generate/ClassFile/ClassBase.php | 58 ++++- .../Generate/ClassFile/ClassConstant.php | 11 - app/Component/Generate/ClassFile/Config.php | 201 +++++++++++------- app/Controller/TestController.php | 19 +- composer.json | 3 +- 5 files changed, 199 insertions(+), 93 deletions(-) diff --git a/app/Component/Generate/ClassFile/ClassBase.php b/app/Component/Generate/ClassFile/ClassBase.php index ec4703b..cc5ceb7 100644 --- a/app/Component/Generate/ClassFile/ClassBase.php +++ b/app/Component/Generate/ClassFile/ClassBase.php @@ -76,7 +76,7 @@ public function getPrivate(): bool * * @return ClassBase */ - public function setPrivate(bool $private = true): ClassBase + public function setPrivate(bool $private): ClassBase { $this->private = $private; if ($private === true) { @@ -99,7 +99,7 @@ public function getProtected(): bool * * @return ClassBase */ - public function setProtected(bool $protected = true): ClassBase + public function setProtected(bool $protected): ClassBase { $this->protected = $protected; if ($protected === true) { @@ -122,7 +122,7 @@ public function getPublic(): bool * * @return ClassBase */ - public function setPublic(bool $public = true): ClassBase + public function setPublic(bool $public): ClassBase { $this->public = $public; if ($public === true) { @@ -180,4 +180,56 @@ public function addComment(string $comment): ClassBase $this->comments[] = $comment; return $this; } + + /** + * @return mixed + */ + public function getDefault() + { + return $this->default; + } + + /** + * @param mixed $default + * + * @return ClassBase + */ + public function setDefault($default): ClassBase + { + $this->default = $default; + return $this; + } + + /** + * @param $value + * + * @return string + */ + public function getValueType($value): string + { + switch (gettype($value)) { + case 'boolean': + $value = $value ? 'true' : 'false'; + break; + case 'integer': + case 'double': + $value = (string)$value; + break; + case 'string': + $value = "'" . $value . "'"; + break; + case 'resource': + $value = '{resource}'; + break; + case 'NULL': + $value = 'null'; + break; + case 'unknown type': + $value = '{unknown}'; + break; + default: + break; + } + return $value; + } } diff --git a/app/Component/Generate/ClassFile/ClassConstant.php b/app/Component/Generate/ClassFile/ClassConstant.php index 9247824..b485284 100644 --- a/app/Component/Generate/ClassFile/ClassConstant.php +++ b/app/Component/Generate/ClassFile/ClassConstant.php @@ -4,16 +4,5 @@ class ClassConstant extends ClassBase { - /** - * @var bool - */ - private $const = true; - /** - * @return bool - */ - public function getConst(): bool - { - return $this->const; - } } diff --git a/app/Component/Generate/ClassFile/Config.php b/app/Component/Generate/ClassFile/Config.php index a28eb61..8064549 100644 --- a/app/Component/Generate/ClassFile/Config.php +++ b/app/Component/Generate/ClassFile/Config.php @@ -3,7 +3,6 @@ namespace App\Component\Generate\ClassFile; use App\Component\Generate\AbstractConfig; -use Lengbin\Helper\YiiSoft\StringHelper; class Config extends AbstractConfig { @@ -227,6 +226,11 @@ public function getFileName(): string return $this->getClassname(); } + /** + * @param string $use + * + * @return $this + */ public function addUse(string $use): Config { $this->uses[] = $use; @@ -356,6 +360,7 @@ public function setConstants(array $constants): Config */ public function getInterface(): bool { + $this->setImplements([]); return $this->interface; } @@ -370,23 +375,81 @@ public function setInterface(bool $interface): Config return $this; } + /** + * @return string + */ + protected function renderUses(): string + { + $data = []; + if (!empty($this->getUses())) { + foreach ($this->getUses() as $use) { + $data[] = "use {$use};"; + } + } + return implode("\n", $data); + } /** - * @param string $str - * @param array $comments + * @param array $comments + * @param int $level * * @return string */ - protected function renderComment(string $str, array $comments = []): string + protected function renderComment(array $comments = [], int $level = 0): string + { + $data = []; + if (!empty($comments)) { + $data[] = "{$this->getSpaces($level)}/**"; + foreach ($comments as $comment) { + $data[] = "{$this->getSpaces($level)} * {$comment}"; + } + $data[] = "{$this->getSpaces($level)} */"; + } + return implode("\n", $data); + } + + /** + * @return string + */ + protected function renderClassname(): string { - $str .= "/**\n"; - foreach ($comments as $comment) { - $str .= " * {$comment}\n"; + $str = ''; + if ($this->getFinal()) { + $str .= "final"; + } + if ($this->getAbstract()) { + $str .= "abstract"; + } + + $str .= ($this->getInterface() ? 'interface' : 'class') . " {$this->getClassname()}"; + + if (!empty($this->getInheritance())) { + $str .= " extends {$this->getInheritance()}"; + } + if (!empty($this->getImplements())) { + $implement = implode(', ', $this->getImplements()); + $str .= " implements {$implement}"; } - $str .= " */\n"; return $str; } + /** + * @return string + */ + protected function renderConst(): string + { + $data = []; + if (!empty($this->getConstants())) { + foreach ($this->getConstants() as $constant) { + if (!empty($constant->getComments())) { + $data[] = $this->renderComment($constant->getComments(), 1); + } + $data[] = ("{$this->getSpaces()}{$this->getScope($constant)} const " . strtoupper($constant->getName()) . " = " . $constant->getValueType($constant->getDefault()) . ";\n"); + } + } + return implode("\n", $data); + } + /** * 获取 作用域 * @@ -415,93 +478,79 @@ protected function getScope(ClassBase $classBase): string return $str; } - protected function renderProperty(string $str): string + /** + * @return string + */ + protected function renderProperty(): string { + $data = []; if (!empty($this->getProperties())) { - // constant foreach ($this->getProperties() as $classProperty) { - if (!$classProperty->getConst()) { - continue; + // if not comment, add default value type + if (empty($classProperty->getComments()) && !is_null($classProperty->getDefault())) { + $classProperty->addComment("@var " . gettype($classProperty->getDefault())); } if (!empty($classProperty->getComments())) { - $str = $this->renderComment($str, $classProperty->getComments()); + $data[] = $this->renderComment($classProperty->getComments(), 1); } - $str .= "{$this->getScope($classProperty)}" . StringHelper::strtoupper($classProperty->getName(), 'utf8') . ";\n"; - } - // property - foreach ($this->getProperties() as $classProperty) { - if ($classProperty->getConst()) { - continue; - } - if (!empty($classProperty->getComments())) { - $str = $this->renderComment($str, $classProperty->getComments()); + $property = "{$this->getSpaces()}{$this->getScope($classProperty)} $" . $classProperty->getName(); + if (is_null($classProperty->getDefault())) { + $property .= ";"; + } else { + $property .= (" = " . $classProperty->getValueType($classProperty->getDefault()) . ";"); } - $str .= "{$this->getScope($classProperty)} $" . $classProperty->getName() . ";\n"; + $data[] = $property . "\n"; } } - return $str; + return implode("\n", $data); } - protected function renderMethod(string $str): string + /** + * @return string + */ + protected function renderMethod(): string { - return $str; + $data = []; + return implode("\n", $data); } /** * @return string */ - public function getContent(): string + protected function renderClass(): string { - // getNamespace())) { - $str .= "namespace {$this->getNamespace()};\n\n"; - } - - // uses - if (!empty($this->getUses())) { - foreach ($this->getUses() as $use) { - $str .= "use {$use};\n"; - } - $str .= "\n"; - } - - // class comment - if (!empty($this->getComments())) { - $str = $this->renderComment($str, $this->getComments()); - } - // class - - // - if ($this->getFinal()) { - - } - - if ($this->getAbstract()) { - - } - - $str .= "class {$this->getClassname()}"; - if (!empty($this->getInheritance())) { - $str .= " extends {$this->getInheritance()}"; - } - if (!empty($this->getImplements())) { - $implement = implode(', ', $this->getImplements()); - $str .= " implements {$implement}"; - } - - $str .= "\n{\n"; - if (empty($this->getProperties()) && empty($this->getMethods())) { - $str .= "{$this->getSpaces()}\n"; - } else { + return implode("\n", array_filter([ + // class comment + !empty($this->getComments()) ? $this->renderComment($this->getComments()) : "", + // classname + $this->renderClassname(), + '{', + // const + $this->renderConst(), // properties - $str = $this->renderProperty($str); + $this->renderProperty(), // methods - $str = $this->renderMethod($str); - } - $str .= "}\n"; - return $str; +// $str = $this->renderMethod($str), + '}', + ])); + + } + + /** + * @return string + */ + public function getContent(): string + { + return implode("\n\n", array_filter([ + // getNamespace()) ? "namespace {$this->getNamespace()};" : "", + // uses + $this->renderUses(), + // class + $this->renderClass(), + ])); } } diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index 08f59e0..a4a0b04 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -26,7 +26,6 @@ */ class TestController extends BaseController { - /** * @Inject() * @var AdminService @@ -220,12 +219,28 @@ public function generate() ], 'inheritance' => 'BaseController', 'constants' => [ - ['name' => 'success', 'default' => 0], + [ + 'name' => 'success', + 'default' => 1, + 'comments' => [ + '成功', + '@Message("成功")', + ], + ], + [ + 'name' => 'fail', + 'default' => "2", + 'comments' => [ + '失败', + '@Message("失败")', + ], + ], ], 'properties' => [ ["name" => 'abc', 'default' => 1.3], ["name" => 'abc2', 'default' => "hello world"], ["name" => 'abc3', 'default' => true], + ["name" => 'abc4'], ], ]; diff --git a/composer.json b/composer.json index c51682c..92f3dd2 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,8 @@ "lengbin/hyperf-common": "dev-master", "lengbin/hyperf-error-code": "dev-main", "daodao97/apidog": "^1.5", - "lengbin/hyperf-yii-rbac": "9999999-dev" + "lengbin/hyperf-yii-rbac": "9999999-dev", + "ext-json": "*" }, "require-dev": { "swoole/ide-helper": "^4.4", From fa281c078b22e5af7eeb3e15a96c82289b213183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Thu, 17 Dec 2020 01:48:47 +0800 Subject: [PATCH 52/82] =?UTF-8?q?class=20=E6=96=87=E4=BB=B6=20=E7=94=9F?= =?UTF-8?q?=E6=88=90=204,=20=E5=B7=AE=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/Generate/ClassFile/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Component/Generate/ClassFile/Config.php b/app/Component/Generate/ClassFile/Config.php index 8064549..be4a96a 100644 --- a/app/Component/Generate/ClassFile/Config.php +++ b/app/Component/Generate/ClassFile/Config.php @@ -530,7 +530,7 @@ protected function renderClass(): string // properties $this->renderProperty(), // methods -// $str = $this->renderMethod($str), + $this->renderMethod(), '}', ])); From 8ea18c0dea6a543f64de81f5adcdb327ced3c322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Thu, 17 Dec 2020 11:39:22 +0800 Subject: [PATCH 53/82] =?UTF-8?q?class=20=E6=96=87=E4=BB=B6=20=E7=94=9F?= =?UTF-8?q?=E6=88=905=EF=BC=8C=20=E4=BC=98=E5=8C=96=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Generate/ClassFile/ClassBase.php | 24 ----------- .../Generate/ClassFile/ClassConstant.php | 22 ++++++++++ .../Generate/ClassFile/ClassMethod.php | 41 +++++++++++++++---- .../Generate/ClassFile/ClassProperty.php | 22 ++++++++++ app/Component/Generate/ClassFile/Config.php | 9 ++++ app/Controller/TestController.php | 27 ++++++------ 6 files changed, 100 insertions(+), 45 deletions(-) diff --git a/app/Component/Generate/ClassFile/ClassBase.php b/app/Component/Generate/ClassFile/ClassBase.php index cc5ceb7..7419325 100644 --- a/app/Component/Generate/ClassFile/ClassBase.php +++ b/app/Component/Generate/ClassFile/ClassBase.php @@ -39,11 +39,6 @@ class ClassBase extends BaseObject */ protected $name; - /** - * @var mixed - */ - protected $default; - /** * @return bool */ @@ -181,25 +176,6 @@ public function addComment(string $comment): ClassBase return $this; } - /** - * @return mixed - */ - public function getDefault() - { - return $this->default; - } - - /** - * @param mixed $default - * - * @return ClassBase - */ - public function setDefault($default): ClassBase - { - $this->default = $default; - return $this; - } - /** * @param $value * diff --git a/app/Component/Generate/ClassFile/ClassConstant.php b/app/Component/Generate/ClassFile/ClassConstant.php index b485284..d06f6c4 100644 --- a/app/Component/Generate/ClassFile/ClassConstant.php +++ b/app/Component/Generate/ClassFile/ClassConstant.php @@ -4,5 +4,27 @@ class ClassConstant extends ClassBase { + /** + * @var mixed + */ + protected $default; + /** + * @return mixed + */ + public function getDefault() + { + return $this->default; + } + + /** + * @param mixed $default + * + * @return ClassBase + */ + public function setDefault($default): ClassBase + { + $this->default = $default; + return $this; + } } diff --git a/app/Component/Generate/ClassFile/ClassMethod.php b/app/Component/Generate/ClassFile/ClassMethod.php index 6bd2278..d90de4e 100644 --- a/app/Component/Generate/ClassFile/ClassMethod.php +++ b/app/Component/Generate/ClassFile/ClassMethod.php @@ -14,6 +14,11 @@ class ClassMethod extends ClassBase */ private $params = []; + /** + * @var mixed + */ + private $return; + /** * @return bool */ @@ -49,18 +54,36 @@ public function getParams(): array public function setParams(array $params): ClassMethod { $this->params = $params; - $this->init(); return $this; } - public function init() + + /** + * @return mixed + */ + public function getReturn() + { + return $this->return; + } + + /** + * @param mixed $return + * + * @return ClassMethod + */ + public function setReturn($return): ClassMethod { - parent::init(); - if (!empty($this->getParams())) { - foreach ($this->getParams() as $params) { - $name = '$' . $params->getName(); - $this->addComment("@param {$params->getType()} {$name}"); - } - } + $this->return = $return; + return $this; } + /** + * @param ClassParams $params + * + * @return $this + */ + public function addParams(ClassParams $params): ClassMethod + { + $this->params[] = $params; + return $this; + } } diff --git a/app/Component/Generate/ClassFile/ClassProperty.php b/app/Component/Generate/ClassFile/ClassProperty.php index 3c9c153..5734f78 100644 --- a/app/Component/Generate/ClassFile/ClassProperty.php +++ b/app/Component/Generate/ClassFile/ClassProperty.php @@ -4,5 +4,27 @@ class ClassProperty extends ClassBase { + /** + * @var mixed + */ + protected $default; + /** + * @return mixed + */ + public function getDefault() + { + return $this->default; + } + + /** + * @param mixed $default + * + * @return ClassBase + */ + public function setDefault($default): ClassBase + { + $this->default = $default; + return $this; + } } diff --git a/app/Component/Generate/ClassFile/Config.php b/app/Component/Generate/ClassFile/Config.php index be4a96a..932e286 100644 --- a/app/Component/Generate/ClassFile/Config.php +++ b/app/Component/Generate/ClassFile/Config.php @@ -441,6 +441,10 @@ protected function renderConst(): string $data = []; if (!empty($this->getConstants())) { foreach ($this->getConstants() as $constant) { + // if not comment, add name + if (empty($constant->getComments()) && !is_null($constant->getDefault())) { + $constant->addComment($constant->getName()); + } if (!empty($constant->getComments())) { $data[] = $this->renderComment($constant->getComments(), 1); } @@ -511,6 +515,9 @@ protected function renderProperty(): string protected function renderMethod(): string { $data = []; + if (!empty($this->getMethods())) { + var_dump($this->getMethods()); + } return implode("\n", $data); } @@ -524,6 +531,7 @@ protected function renderClass(): string !empty($this->getComments()) ? $this->renderComment($this->getComments()) : "", // classname $this->renderClassname(), + // start '{', // const $this->renderConst(), @@ -531,6 +539,7 @@ protected function renderClass(): string $this->renderProperty(), // methods $this->renderMethod(), + // end '}', ])); diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index a4a0b04..02b6fbc 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -220,20 +220,14 @@ public function generate() 'inheritance' => 'BaseController', 'constants' => [ [ - 'name' => 'success', - 'default' => 1, - 'comments' => [ - '成功', - '@Message("成功")', - ], + 'name' => 'success', + 'default' => 1, + ], [ - 'name' => 'fail', - 'default' => "2", - 'comments' => [ - '失败', - '@Message("失败")', - ], + 'name' => 'fail', + 'default' => "2", + ], ], 'properties' => [ @@ -242,6 +236,15 @@ public function generate() ["name" => 'abc3', 'default' => true], ["name" => 'abc4'], ], +// 'methods' => [ +// [ +// "name" => 'abc', +// 'params' => [ +// [], +// ], +// 'return' => 'int', +// ], +// ], ]; $generate = new Generate(); From 6b027d97c9b31e30f8be6ad5adf7a2ba4ee0ed95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Fri, 18 Dec 2020 01:45:45 +0800 Subject: [PATCH 54/82] =?UTF-8?q?class=20=E6=96=87=E4=BB=B6=E7=94=9F?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Generate/ClassFile/ClassBase.php | 21 +++++++++ .../Generate/ClassFile/ClassConstant.php | 4 +- .../Generate/ClassFile/ClassMethod.php | 25 ++++++++++ .../Generate/ClassFile/ClassParams.php | 24 ++++++++++ .../Generate/ClassFile/ClassProperty.php | 4 +- app/Component/Generate/ClassFile/Config.php | 46 ++++++++++++++++++- app/Controller/TestController.php | 28 ++++++----- 7 files changed, 135 insertions(+), 17 deletions(-) diff --git a/app/Component/Generate/ClassFile/ClassBase.php b/app/Component/Generate/ClassFile/ClassBase.php index 7419325..5d7faf2 100644 --- a/app/Component/Generate/ClassFile/ClassBase.php +++ b/app/Component/Generate/ClassFile/ClassBase.php @@ -176,6 +176,27 @@ public function addComment(string $comment): ClassBase return $this; } + public function valueType($value): string + { + switch (gettype($value)) { + case 'boolean': + $value = 'bool'; + break; + case 'integer': + $value = 'int'; + break; + case 'double': + $value = 'float'; + break; + case 'NULL': + $value = 'null'; + break; + default: + break; + } + return $value; + } + /** * @param $value * diff --git a/app/Component/Generate/ClassFile/ClassConstant.php b/app/Component/Generate/ClassFile/ClassConstant.php index d06f6c4..777d0fa 100644 --- a/app/Component/Generate/ClassFile/ClassConstant.php +++ b/app/Component/Generate/ClassFile/ClassConstant.php @@ -20,9 +20,9 @@ public function getDefault() /** * @param mixed $default * - * @return ClassBase + * @return ClassConstant */ - public function setDefault($default): ClassBase + public function setDefault($default): ClassConstant { $this->default = $default; return $this; diff --git a/app/Component/Generate/ClassFile/ClassMethod.php b/app/Component/Generate/ClassFile/ClassMethod.php index d90de4e..0ad22d4 100644 --- a/app/Component/Generate/ClassFile/ClassMethod.php +++ b/app/Component/Generate/ClassFile/ClassMethod.php @@ -19,6 +19,11 @@ class ClassMethod extends ClassBase */ private $return; + /** + * @var ?string + */ + private $content; + /** * @return bool */ @@ -86,4 +91,24 @@ public function addParams(ClassParams $params): ClassMethod $this->params[] = $params; return $this; } + + /** + * @return string + */ + public function getContent(): string + { + return $this->content; + } + + /** + * @param ?string $content + * + * @return ClassMethod + */ + public function setContent(?string $content): ClassMethod + { + $this->content = $content; + return $this; + } + } diff --git a/app/Component/Generate/ClassFile/ClassParams.php b/app/Component/Generate/ClassFile/ClassParams.php index cc78d16..4bb332b 100644 --- a/app/Component/Generate/ClassFile/ClassParams.php +++ b/app/Component/Generate/ClassFile/ClassParams.php @@ -21,6 +21,30 @@ class ClassParams extends BaseObject */ private $comment = ''; + /** + * @var mixed + */ + private $default; + + /** + * @return mixed + */ + public function getDefault() + { + return $this->default; + } + + /** + * @param mixed $default + * + * @return ClassParams + */ + public function setDefault($default): ClassParams + { + $this->default = $default; + return $this; + } + /** * @return string */ diff --git a/app/Component/Generate/ClassFile/ClassProperty.php b/app/Component/Generate/ClassFile/ClassProperty.php index 5734f78..706d4bd 100644 --- a/app/Component/Generate/ClassFile/ClassProperty.php +++ b/app/Component/Generate/ClassFile/ClassProperty.php @@ -20,9 +20,9 @@ public function getDefault() /** * @param mixed $default * - * @return ClassBase + * @return ClassProperty */ - public function setDefault($default): ClassBase + public function setDefault($default): ClassProperty { $this->default = $default; return $this; diff --git a/app/Component/Generate/ClassFile/Config.php b/app/Component/Generate/ClassFile/Config.php index 932e286..a0e16e1 100644 --- a/app/Component/Generate/ClassFile/Config.php +++ b/app/Component/Generate/ClassFile/Config.php @@ -516,7 +516,51 @@ protected function renderMethod(): string { $data = []; if (!empty($this->getMethods())) { - var_dump($this->getMethods()); + foreach ($this->getMethods() as $classMethod) { + $params = []; + if (!empty($classMethod->getParams())) { + foreach ($classMethod->getParams() as $classParams) { + $classParamName = "$" . $classParams->getName(); + if (empty($classParams->getType()) && !empty($classParams->getDefault())) { + $classParams->setType($classMethod->valueType($classParams->getDefault())); + } + $classParam = ''; + if (!empty($classParams->getType())) { + $classParam .= "{$classParams->getType()} "; + } else { + $classParams->setType("mixed"); + } + $classParam .= $classParamName; + if (!empty($classParams->getDefault())) { + $classParam .= (" = " . $classMethod->getValueType($classParams->getDefault())); + } + $params[] = $classParam; + $classMethod->addComment("@Params {$classParams->getType()} {$classParamName} {$classParams->getComment()}"); + } + } + $param = implode(", ", $params); + + $method = $this->getSpaces(); + if ($classMethod->getFinal()) { + $method .= "final"; + } + $method .= "{$this->getScope($classMethod)} function {$classMethod->getName()}({$param})"; + if (!empty($classMethod->getReturn())) { + $method .= ": {$classMethod->getReturn()}"; + } else { + $classMethod->setReturn('mixed'); + } + $classMethod->addComment("@return {$classMethod->getReturn()}"); + + $data[] = $this->renderComment($classMethod->getComments(), 1); + $data[] = $method; + $data[] = "{$this->getSpaces()}{"; + if (empty($classMethod->getContent())) { + $classMethod->setContent("{$this->getSpaces(2)}// TODO: Implement {$classMethod->getName()}() method."); + } + $data[] = $classMethod->getContent(); + $data[] = "{$this->getSpaces()}}"; + } } return implode("\n", $data); } diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index 02b6fbc..446668f 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -236,21 +236,25 @@ public function generate() ["name" => 'abc3', 'default' => true], ["name" => 'abc4'], ], -// 'methods' => [ -// [ -// "name" => 'abc', -// 'params' => [ -// [], -// ], -// 'return' => 'int', -// ], -// ], + 'methods' => [ + [ + "name" => 'abc', + 'params' => [ + ['name' => 'a', 'type' => 'int', 'default' => 1, 'comment' => '左边'], + ['name' => 'b', 'default' => 2, 'comment' => '中间'], + ['name' => 'c', 'type' => 'int'], + ['name' => 'd', 'comment' => '右边' ], + ], + 'return' => 'int', + 'content' => '', + ], + ], ]; $generate = new Generate(); $generate->setPath(BASE_PATH . '/app/Controller'); - $generate->setConfig(new Config($data)); - - return $this->success(['a' => $generate->output('php')]); + $config = new Config($data); + $generate->setConfig($config); + return $this->success(['a' => $generate->output('php'), 'b' => $config->__toObjectString(), 'c' => $config->__getClassname()]); } } From 2e2cdbf264853306cdfbeeff824b20fb21d0133a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sat, 26 Dec 2020 20:51:43 +0800 Subject: [PATCH 55/82] fix bug --- .php_cs | 89 --------------------- app/Component/Generate/ClassFile/Config.php | 2 +- app/Controller/TestController.php | 8 +- 3 files changed, 5 insertions(+), 94 deletions(-) diff --git a/.php_cs b/.php_cs index f96a794..e69de29 100644 --- a/.php_cs +++ b/.php_cs @@ -1,89 +0,0 @@ -setRiskyAllowed(true) - ->setRules([ - '@PSR2' => true, - '@Symfony' => true, - '@DoctrineAnnotation' => true, - '@PhpCsFixer' => true, - 'header_comment' => [ - 'commentType' => 'PHPDoc', - 'header' => $header, - 'separate' => 'none', - 'location' => 'after_declare_strict', - ], - 'array_syntax' => [ - 'syntax' => 'short' - ], - 'list_syntax' => [ - 'syntax' => 'short' - ], - 'concat_space' => [ - 'spacing' => 'one' - ], - 'blank_line_before_statement' => [ - 'statements' => [ - 'declare', - ], - ], - 'general_phpdoc_annotation_remove' => [ - 'annotations' => [ - 'author' - ], - ], - 'ordered_imports' => [ - 'imports_order' => [ - 'class', 'function', 'const', - ], - 'sort_algorithm' => 'alpha', - ], - 'single_line_comment_style' => [ - 'comment_types' => [ - ], - ], - 'yoda_style' => [ - 'always_move_variable' => false, - 'equal' => false, - 'identical' => false, - ], - 'phpdoc_align' => [ - 'align' => 'left', - ], - 'multiline_whitespace_before_semicolons' => [ - 'strategy' => 'no_multi_line', - ], - 'class_attributes_separation' => true, - 'combine_consecutive_unsets' => true, - 'declare_strict_types' => true, - 'linebreak_after_opening_tag' => true, - 'lowercase_constants' => true, - 'lowercase_static_reference' => true, - 'no_useless_else' => true, - 'no_unused_imports' => true, - 'not_operator_with_successor_space' => true, - 'not_operator_with_space' => false, - 'ordered_class_elements' => true, - 'php_unit_strict' => false, - 'phpdoc_separation' => false, - 'single_quote' => true, - 'standardize_not_equals' => true, - 'multiline_comment_opening_closing' => true, - ]) - ->setFinder( - PhpCsFixer\Finder::create() - ->exclude('public') - ->exclude('runtime') - ->exclude('vendor') - ->in(__DIR__) - ) - ->setUsingCache(false); diff --git a/app/Component/Generate/ClassFile/Config.php b/app/Component/Generate/ClassFile/Config.php index a0e16e1..1075714 100644 --- a/app/Component/Generate/ClassFile/Config.php +++ b/app/Component/Generate/ClassFile/Config.php @@ -535,7 +535,7 @@ protected function renderMethod(): string $classParam .= (" = " . $classMethod->getValueType($classParams->getDefault())); } $params[] = $classParam; - $classMethod->addComment("@Params {$classParams->getType()} {$classParamName} {$classParams->getComment()}"); + $classMethod->addComment("@param {$classParams->getType()} {$classParamName} {$classParams->getComment()}"); } } $param = implode(", ", $params); diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index 446668f..38fd0bc 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -238,14 +238,14 @@ public function generate() ], 'methods' => [ [ - "name" => 'abc', - 'params' => [ + "name" => 'abc', + 'params' => [ ['name' => 'a', 'type' => 'int', 'default' => 1, 'comment' => '左边'], ['name' => 'b', 'default' => 2, 'comment' => '中间'], ['name' => 'c', 'type' => 'int'], - ['name' => 'd', 'comment' => '右边' ], + ['name' => 'd', 'comment' => '右边'], ], - 'return' => 'int', + 'return' => 'int', 'content' => '', ], ], From 0c983b3dd09ce349f02578c0bfe8fa57b35a34b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Mon, 28 Dec 2020 00:55:12 +0800 Subject: [PATCH 56/82] fix bug --- server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.sh b/server.sh index c92579c..9fe752a 100644 --- a/server.sh +++ b/server.sh @@ -10,4 +10,4 @@ php bin/hyperf.php gen:error-code -#php bin/hyperf.php start +# php -d swoole.use_shortname=Off -e bin/hyperf.php start From 26063afe811c54b6c2850c339e46c19b8cf523d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Mon, 28 Dec 2020 23:07:33 +0800 Subject: [PATCH 57/82] add model class --- .../ClassFile/{Config.php => ClassConfig.php} | 2 +- .../Generate/Model/GenerateModel.php | 332 ++++++++++++++++++ app/Component/Generate/Model/stubs/Model.stub | 45 +++ 3 files changed, 378 insertions(+), 1 deletion(-) rename app/Component/Generate/ClassFile/{Config.php => ClassConfig.php} (99%) create mode 100644 app/Component/Generate/Model/GenerateModel.php create mode 100644 app/Component/Generate/Model/stubs/Model.stub diff --git a/app/Component/Generate/ClassFile/Config.php b/app/Component/Generate/ClassFile/ClassConfig.php similarity index 99% rename from app/Component/Generate/ClassFile/Config.php rename to app/Component/Generate/ClassFile/ClassConfig.php index 1075714..dd47c9d 100644 --- a/app/Component/Generate/ClassFile/Config.php +++ b/app/Component/Generate/ClassFile/ClassConfig.php @@ -4,7 +4,7 @@ use App\Component\Generate\AbstractConfig; -class Config extends AbstractConfig +class ClassConfig extends AbstractConfig { /** * @var bool diff --git a/app/Component/Generate/Model/GenerateModel.php b/app/Component/Generate/Model/GenerateModel.php new file mode 100644 index 0000000..9f7a876 --- /dev/null +++ b/app/Component/Generate/Model/GenerateModel.php @@ -0,0 +1,332 @@ +resolver = $this->container->get(ConnectionResolverInterface::class); + $this->config = $this->container->get(ConfigInterface::class); + $this->astParser = (new ParserFactory())->create(ParserFactory::ONLY_PHP7); + $this->printer = new Standard(); + } + + /** + * @param string $poolName + * + * @return MySqlBuilder + */ + protected function getSchemaBuilder(string $poolName): MySqlBuilder + { + $connection = $this->resolver->connection($poolName); + return $connection->getSchemaBuilder(); + } + + /** + * Format column's key to lower case. + * + * @param array $columns + * + * @return array + */ + protected function formatColumns(array $columns): array + { + return array_map(function ($item) { + return array_change_key_case($item, CASE_LOWER); + }, $columns); + } + + /** + * @param string $path + */ + protected function mkdir(string $path): void + { + $dir = dirname($path); + if (!is_dir($dir)) { + @mkdir($dir, 0755, true); + } + } + + /** + * Get the full namespace for a given class, without the class name. + */ + protected function getNamespace(string $name): string + { + return trim(implode('\\', array_slice(explode('\\', $name), 0, -1)), '\\'); + } + + /** + * Replace the namespace for the given stub. + */ + protected function replaceNamespace(string &$stub, string $name): self + { + $stub = str_replace(['%NAMESPACE%'], [$this->getNamespace($name)], $stub); + + return $this; + } + + protected function replaceInheritance(string &$stub, string $inheritance): self + { + $stub = str_replace(['%INHERITANCE%'], [$inheritance], $stub); + + return $this; + } + + protected function replaceConnection(string &$stub, string $connection): self + { + $stub = str_replace(['%CONNECTION%'], [$connection], $stub); + + return $this; + } + + protected function replacePrimaryKey(string &$stub, string $primaryKey): self + { + $stub = str_replace(['%PRIMARY_KEY%'], [$primaryKey], $stub); + + return $this; + } + + protected function replaceUses(string &$stub, string $uses): self + { + $uses = $uses ? "use {$uses};" : ''; + $stub = str_replace(['%USES%'], [$uses], $stub); + + return $this; + } + + /** + * Replace the class name for the given stub. + */ + protected function replaceClass(string &$stub, string $name): self + { + $class = str_replace($this->getNamespace($name) . '\\', '', $name); + + $stub = str_replace('%CLASS%', $class, $stub); + + return $this; + } + + /** + * Replace the table name for the given stub. + */ + protected function replaceTable(string $stub, string $table): string + { + return str_replace('%TABLE%', $table, $stub); + } + + /** + * Get the destination class path. + */ + protected function getPath(string $name): string + { + return BASE_PATH . '/' . str_replace('\\', '/', $name) . '.php'; + } + + /** + * Build the class with the given name. + */ + protected function buildClass(string $table, string $name, string $primaryKey, ModelOption $option): string + { + $stub = file_get_contents(BASE_PATH . '/app/Component/Generate/Model/stubs/Model.stub'); + + return $this->replaceNamespace($stub, $name) + ->replaceInheritance($stub, $option->getInheritance()) + ->replaceConnection($stub, $option->getPool()) + ->replaceUses($stub, $option->getUses()) + ->replaceClass($stub, $name) + ->replacePrimaryKey($stub, $primaryKey) + ->replaceTable($stub, $table); + } + + protected function getColumns($className, $columns, $forceCasts): array + { + /** @var Model $model */ + $model = new $className(); + $dates = $model->getDates(); + $casts = []; + if (!$forceCasts) { + $casts = $model->getCasts(); + } + + foreach ($dates as $date) { + if (!isset($casts[$date])) { + $casts[$date] = 'datetime'; + } + } + + foreach ($columns as $key => $value) { + $columns[$key]['cast'] = $casts[$value['column_name']] ?? null; + } + + return $columns; + } + + protected function getPrimaryKey(array $columns): string + { + $primaryKey = 'id'; + foreach ($columns as $column) { + if ($column['column_key'] === 'PRI') { + $primaryKey = $column['column_name']; + break; + } + } + return $primaryKey; + } + + protected function createModel(string $table, ModelOption $option) + { + $builder = $this->getSchemaBuilder($option->getPool()); + $table = Str::replaceFirst($option->getPrefix(), '', $table); + $columns = $this->formatColumns($builder->getColumnTypeListing($table)); + + $project = new Project(); + $class = $option->getTableMapping()[$table] ?? Str::studly(Str::singular($table)); + $class = $project->namespace($option->getPath()) . $class; + $path = BASE_PATH . '/' . $project->path($class); + + if (!file_exists($path)) { + $this->mkdir($path); + file_put_contents($path, $this->buildClass($table, $class, $this->getPrimaryKey($columns), $option)); + } + + $columns = $this->getColumns($class, $columns, $option->isForceCasts()); + + $stms = $this->astParser->parse(file_get_contents($path)); + $traverser = new NodeTraverser(); + $traverser->addVisitor(make(ModelUpdateVisitor::class, [ + 'class' => $class, + 'columns' => $columns, + 'option' => $option, + ])); + $traverser->addVisitor(make(ModelRewriteConnectionVisitor::class, [$class, $option->getPool()])); + $data = make(ModelData::class)->setClass($class)->setColumns($columns); + foreach ($option->getVisitors() as $visitorClass) { + $traverser->addVisitor(make($visitorClass, [$option, $data])); + } + $stms = $traverser->traverse($stms); + $code = $this->printer->prettyPrintFile($stms); + + file_put_contents($path, $code); + + if ($option->isWithIde()) { + $this->generateIDE($code, $option, $data); + } + } + + protected function generateIDE(string $code, ModelOption $option, ModelData $data) + { + $stms = $this->astParser->parse($code); + $traverser = new NodeTraverser(); + $traverser->addVisitor(make(GenerateModelIDEVisitor::class, [$option, $data])); + $stms = $traverser->traverse($stms); + $code = $this->printer->prettyPrintFile($stms); + $class = str_replace('\\', '_', $data->getClass()); + $path = BASE_PATH . '/runtime/ide/' . $class . '.php'; + $this->mkdir($path); + file_put_contents($path, $code); + } + + protected function isIgnoreTable(string $table, ModelOption $option): bool + { + if (in_array($table, $option->getIgnoreTables())) { + return true; + } + + return $table === $this->config->get('databases.migrations', 'migrations'); + } + + protected function createModels(ModelOption $option) + { + $builder = $this->getSchemaBuilder($option->getPool()); + $tables = []; + + foreach ($builder->getAllTables() as $row) { + $row = (array)$row; + $table = reset($row); + if (!$this->isIgnoreTable($table, $option)) { + $tables[] = $table; + } + } + + foreach ($tables as $table) { + $this->createModel($table, $option); + } + } + + protected function getOption(string $key, string $pool = 'default', $default = null) + { + return $this->config->get("databases.{$pool}.{$key}", $default); + } + + public function create(string $table = '', string $pool = 'default'): bool + { + $option = new ModelOption(); + $option->setPool($pool) + ->setPath($this->getOption('commands.gen:model.path', $pool, 'app/Model')) + ->setPrefix($this->getOption('prefix', $pool, '')) + ->setInheritance($this->getOption('commands.gen:model.inheritance', $pool, 'Model')) + ->setUses($this->getOption('commands.gen:model.uses', $pool, 'Hyperf\DbConnection\Model\Model')) + ->setForceCasts($this->getOption('commands.gen:model.force_casts', $pool, false)) + ->setRefreshFillable($this->getOption('commands.gen:model.refresh_fillable', $pool, false)) + ->setTableMapping($this->getOption('commands.gen:model.table_mapping', $pool, [])) + ->setIgnoreTables($this->getOption('commands.gen:model.ignore_tables', $pool, [])) + ->setWithComments($this->getOption('commands.gen:model.with_comments', $pool, false)) + ->setWithIde($this->getOption('commands.gen:model.with_ide', $pool, false)) + ->setVisitors($this->getOption('commands.gen:model.visitors', $pool, [])) + ->setPropertyCase($this->getOption('commands.gen:model.property_case', $pool)); + + if ($table) { + $this->createModel($table, $option); + } else { + $this->createModels($option); + } + + return true; + } +} diff --git a/app/Component/Generate/Model/stubs/Model.stub b/app/Component/Generate/Model/stubs/Model.stub new file mode 100644 index 0000000..1810c39 --- /dev/null +++ b/app/Component/Generate/Model/stubs/Model.stub @@ -0,0 +1,45 @@ + Date: Mon, 28 Dec 2020 23:17:20 +0800 Subject: [PATCH 58/82] fix bug --- .../Generate/ClassFile/ClassConfig.php | 72 +++++++++---------- app/Controller/TestController.php | 35 ++++++++- 2 files changed, 69 insertions(+), 38 deletions(-) diff --git a/app/Component/Generate/ClassFile/ClassConfig.php b/app/Component/Generate/ClassFile/ClassConfig.php index dd47c9d..0a2cdf6 100644 --- a/app/Component/Generate/ClassFile/ClassConfig.php +++ b/app/Component/Generate/ClassFile/ClassConfig.php @@ -77,9 +77,9 @@ public function getNamespace(): ?string /** * @param string $namespace * - * @return Config + * @return ClassConfig */ - public function setNamespace(string $namespace): Config + public function setNamespace(string $namespace): ClassConfig { $this->namespace = $namespace; return $this; @@ -96,9 +96,9 @@ public function getUses(): array /** * @param array $uses * - * @return Config + * @return ClassConfig */ - public function setUses(array $uses): Config + public function setUses(array $uses): ClassConfig { $this->uses = $uses; return $this; @@ -115,9 +115,9 @@ public function getClassname(): string /** * @param string $classname * - * @return Config + * @return ClassConfig */ - public function setClassname(string $classname): Config + public function setClassname(string $classname): ClassConfig { $this->classname = $classname; return $this; @@ -134,9 +134,9 @@ public function getInheritance(): ?string /** * @param string $inheritance * - * @return Config + * @return ClassConfig */ - public function setInheritance(string $inheritance): Config + public function setInheritance(string $inheritance): ClassConfig { $this->inheritance = $inheritance; return $this; @@ -153,9 +153,9 @@ public function getImplements(): array /** * @param array $implements * - * @return Config + * @return ClassConfig */ - public function setImplements(array $implements): Config + public function setImplements(array $implements): ClassConfig { $this->implements = $implements; return $this; @@ -172,9 +172,9 @@ public function getMethods(): array /** * @param ClassMethod[] $methods * - * @return Config + * @return ClassConfig */ - public function setMethods(array $methods): Config + public function setMethods(array $methods): ClassConfig { $this->methods = $methods; return $this; @@ -191,9 +191,9 @@ public function getProperties(): ?array /** * @param ClassProperty[] $properties * - * @return Config + * @return ClassConfig */ - public function setProperties(array $properties): Config + public function setProperties(array $properties): ClassConfig { $this->properties = $properties; return $this; @@ -210,9 +210,9 @@ public function getComments(): array /** * @param array $comments * - * @return Config + * @return ClassConfig */ - public function setComments(array $comments): Config + public function setComments(array $comments): ClassConfig { $this->comments = $comments; return $this; @@ -229,9 +229,9 @@ public function getFileName(): string /** * @param string $use * - * @return $this + * @return ClassConfig */ - public function addUse(string $use): Config + public function addUse(string $use): ClassConfig { $this->uses[] = $use; return $this; @@ -240,9 +240,9 @@ public function addUse(string $use): Config /** * @param string $comment * - * @return $this + * @return ClassConfig */ - public function addComment(string $comment): Config + public function addComment(string $comment): ClassConfig { $this->comments[] = $comment; return $this; @@ -251,9 +251,9 @@ public function addComment(string $comment): Config /** * @param string $implement * - * @return $this + * @return ClassConfig */ - public function addImplement(string $implement): Config + public function addImplement(string $implement): ClassConfig { $this->implements[] = $implement; return $this; @@ -262,9 +262,9 @@ public function addImplement(string $implement): Config /** * @param ClassMethod $classMethod * - * @return $this + * @return ClassConfig */ - public function addMethod(ClassMethod $classMethod): Config + public function addMethod(ClassMethod $classMethod): ClassConfig { $this->methods[] = $classMethod; return $this; @@ -273,9 +273,9 @@ public function addMethod(ClassMethod $classMethod): Config /** * @param ClassProperty $classProperty * - * @return $this + * @return ClassConfig */ - public function addProperty(ClassProperty $classProperty): Config + public function addProperty(ClassProperty $classProperty): ClassConfig { $this->properties[] = $classProperty; return $this; @@ -284,9 +284,9 @@ public function addProperty(ClassProperty $classProperty): Config /** * @param ClassConstant $constant * - * @return $this + * @return ClassConfig */ - public function addCont(ClassConstant $constant): Config + public function addCont(ClassConstant $constant): ClassConfig { $this->constants[] = $constant; return $this; @@ -303,9 +303,9 @@ public function getFinal(): bool /** * @param bool $final * - * @return Config + * @return ClassConfig */ - public function setFinal(bool $final): Config + public function setFinal(bool $final): ClassConfig { $this->final = $final; if ($final === true) { @@ -325,9 +325,9 @@ public function getAbstract(): bool /** * @param bool $abstract * - * @return Config + * @return ClassConfig */ - public function setAbstract(bool $abstract): Config + public function setAbstract(bool $abstract): ClassConfig { $this->abstract = $abstract; if ($abstract === true) { @@ -347,9 +347,9 @@ public function getConstants(): array /** * @param ClassConstant[] $constants * - * @return Config + * @return ClassConfig */ - public function setConstants(array $constants): Config + public function setConstants(array $constants): ClassConfig { $this->constants = $constants; return $this; @@ -367,9 +367,9 @@ public function getInterface(): bool /** * @param bool $interface * - * @return Config + * @return ClassConfig */ - public function setInterface(bool $interface): Config + public function setInterface(bool $interface): ClassConfig { $this->interface = $interface; return $this; diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index 38fd0bc..0426367 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -5,7 +5,7 @@ use App\Component\AntDesign\Constant\Type\FormDateType; use App\Component\AntDesign\Constant\Type\ValueType; use App\Component\AntDesign\Table; -use App\Component\Generate\ClassFile\Config; +use App\Component\Generate\ClassFile\ClassConfig; use App\Component\Generate\Generate; use App\Constant\Status\AdminStatus; use App\Service\Admin\AdminService; @@ -198,6 +198,37 @@ public function remove() return $this->success($this->request->post()); } + protected function generateCurd(array $params): array + { + $params = [ + 'controller' => 'app/Controller/AdminController', + 'model' => 'app/Model/Ad', + 'actions' => [], + ]; + return [ + 'namespace' => 'App\Controller', + 'classname' => 'AdminController', + 'uses' => [ + 'Hyperf\HttpServer\Annotation\Controller', + 'Lengbin\Hyperf\Auth\RouterAuthAnnotation', + 'Lengbin\Hyperf\Common\Framework\BaseController', + ], + 'comments' => [ + 'Class AdminController', + '@package App\Controller', + '@Controller()', + '@RouterAuthAnnotation(isPublic=true)', + ], + 'inheritance' => 'BaseController', + 'properties' => [ + + ], + 'methods' => [ + + ], + ]; + } + /** * @GetMapping(path="/generate") */ @@ -253,7 +284,7 @@ public function generate() $generate = new Generate(); $generate->setPath(BASE_PATH . '/app/Controller'); - $config = new Config($data); + $config = new ClassConfig($data); $generate->setConfig($config); return $this->success(['a' => $generate->output('php'), 'b' => $config->__toObjectString(), 'c' => $config->__getClassname()]); } From 5f390077857e5a6e5b090f49fb53ebcf4c0cb062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Thu, 31 Dec 2020 23:07:59 +0800 Subject: [PATCH 59/82] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=99=A8=20=E5=87=86=E5=A4=87=E5=89=8D=20demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/AntDesign/Column/Column.php | 8 +- .../AntDesign/Constant/Type/LinkTarget.php | 28 ++ .../AntDesign/Constant/Type/LinkType.php | 23 ++ app/Component/AntDesign/Link.php | 115 +++++- app/Component/AntDesign/Table.php | 5 - .../Generate/Model/GenerateModel.php | 332 ------------------ app/Component/Generate/Model/stubs/Model.stub | 45 --- .../V1/System/GenerateCodeController.php | 10 + .../Admin/V1/System/MenuController.php | 10 + app/Controller/TestController.php | 174 +++++---- app/Entity/GenerateCodeEntity.php | 212 +++++++++++ app/Service/Generate/GenerateService.php | 92 +++++ 12 files changed, 588 insertions(+), 466 deletions(-) create mode 100644 app/Component/AntDesign/Constant/Type/LinkTarget.php create mode 100644 app/Component/AntDesign/Constant/Type/LinkType.php delete mode 100644 app/Component/Generate/Model/GenerateModel.php delete mode 100644 app/Component/Generate/Model/stubs/Model.stub create mode 100644 app/Controller/Admin/V1/System/GenerateCodeController.php create mode 100644 app/Controller/Admin/V1/System/MenuController.php create mode 100644 app/Entity/GenerateCodeEntity.php create mode 100644 app/Service/Generate/GenerateService.php diff --git a/app/Component/AntDesign/Column/Column.php b/app/Component/AntDesign/Column/Column.php index 8ac7e3d..1675098 100644 --- a/app/Component/AntDesign/Column/Column.php +++ b/app/Component/AntDesign/Column/Column.php @@ -84,9 +84,9 @@ public function getCopyable(): bool /** * @param bool $copyable * - * @return BaseColumn + * @return Column */ - public function setCopyable(bool $copyable): BaseColumn + public function setCopyable(bool $copyable): Column { $this->copyable = $copyable; return $this; @@ -103,9 +103,9 @@ public function getEllipsis(): bool /** * @param bool $ellipsis * - * @return BaseColumn + * @return Column */ - public function setEllipsis(bool $ellipsis): BaseColumn + public function setEllipsis(bool $ellipsis): Column { $this->ellipsis = $ellipsis; return $this; diff --git a/app/Component/AntDesign/Constant/Type/LinkTarget.php b/app/Component/AntDesign/Constant/Type/LinkTarget.php new file mode 100644 index 0000000..1ab5f73 --- /dev/null +++ b/app/Component/AntDesign/Constant/Type/LinkTarget.php @@ -0,0 +1,28 @@ +name; + } + + /** + * @param string $name + * + * @return Link + */ + public function setName(string $name): Link + { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getPath(): string + { + return $this->path; + } + + /** + * @param string $path + * + * @return Link + */ + public function setPath(string $path): Link + { + $this->path = $path; + return $this; + } + + /** + * @return LinkTarget + */ + public function getTarget(): LinkTarget + { + return $this->target; + } + + /** + * @param LinkTarget $target + * + * @return Link + */ + public function setTarget(LinkTarget $target): Link + { + $this->target = $target; + return $this; + } + + /** + * @return LinkType + */ + public function getType(): LinkType + { + return $this->type; + } + + /** + * @param LinkType $type + * + * @return Link + */ + public function setType(LinkType $type): Link + { + $this->type = $type; + return $this; + } + + /** + * @return ValueEnumTypeStatus + */ + public function getStatus(): ValueEnumTypeStatus + { + return $this->status; + } + + /** + * @param ValueEnumTypeStatus $status + * + * @return Link + */ + public function setStatus(ValueEnumTypeStatus $status): Link + { + $this->status = $status; + return $this; + } } diff --git a/app/Component/AntDesign/Table.php b/app/Component/AntDesign/Table.php index 26a17a0..7df8144 100644 --- a/app/Component/AntDesign/Table.php +++ b/app/Component/AntDesign/Table.php @@ -34,11 +34,6 @@ class Table extends BaseObject */ public $pageConfig; - /** - * @var array - */ - public $search; - /** * @var Form[] */ diff --git a/app/Component/Generate/Model/GenerateModel.php b/app/Component/Generate/Model/GenerateModel.php deleted file mode 100644 index 9f7a876..0000000 --- a/app/Component/Generate/Model/GenerateModel.php +++ /dev/null @@ -1,332 +0,0 @@ -resolver = $this->container->get(ConnectionResolverInterface::class); - $this->config = $this->container->get(ConfigInterface::class); - $this->astParser = (new ParserFactory())->create(ParserFactory::ONLY_PHP7); - $this->printer = new Standard(); - } - - /** - * @param string $poolName - * - * @return MySqlBuilder - */ - protected function getSchemaBuilder(string $poolName): MySqlBuilder - { - $connection = $this->resolver->connection($poolName); - return $connection->getSchemaBuilder(); - } - - /** - * Format column's key to lower case. - * - * @param array $columns - * - * @return array - */ - protected function formatColumns(array $columns): array - { - return array_map(function ($item) { - return array_change_key_case($item, CASE_LOWER); - }, $columns); - } - - /** - * @param string $path - */ - protected function mkdir(string $path): void - { - $dir = dirname($path); - if (!is_dir($dir)) { - @mkdir($dir, 0755, true); - } - } - - /** - * Get the full namespace for a given class, without the class name. - */ - protected function getNamespace(string $name): string - { - return trim(implode('\\', array_slice(explode('\\', $name), 0, -1)), '\\'); - } - - /** - * Replace the namespace for the given stub. - */ - protected function replaceNamespace(string &$stub, string $name): self - { - $stub = str_replace(['%NAMESPACE%'], [$this->getNamespace($name)], $stub); - - return $this; - } - - protected function replaceInheritance(string &$stub, string $inheritance): self - { - $stub = str_replace(['%INHERITANCE%'], [$inheritance], $stub); - - return $this; - } - - protected function replaceConnection(string &$stub, string $connection): self - { - $stub = str_replace(['%CONNECTION%'], [$connection], $stub); - - return $this; - } - - protected function replacePrimaryKey(string &$stub, string $primaryKey): self - { - $stub = str_replace(['%PRIMARY_KEY%'], [$primaryKey], $stub); - - return $this; - } - - protected function replaceUses(string &$stub, string $uses): self - { - $uses = $uses ? "use {$uses};" : ''; - $stub = str_replace(['%USES%'], [$uses], $stub); - - return $this; - } - - /** - * Replace the class name for the given stub. - */ - protected function replaceClass(string &$stub, string $name): self - { - $class = str_replace($this->getNamespace($name) . '\\', '', $name); - - $stub = str_replace('%CLASS%', $class, $stub); - - return $this; - } - - /** - * Replace the table name for the given stub. - */ - protected function replaceTable(string $stub, string $table): string - { - return str_replace('%TABLE%', $table, $stub); - } - - /** - * Get the destination class path. - */ - protected function getPath(string $name): string - { - return BASE_PATH . '/' . str_replace('\\', '/', $name) . '.php'; - } - - /** - * Build the class with the given name. - */ - protected function buildClass(string $table, string $name, string $primaryKey, ModelOption $option): string - { - $stub = file_get_contents(BASE_PATH . '/app/Component/Generate/Model/stubs/Model.stub'); - - return $this->replaceNamespace($stub, $name) - ->replaceInheritance($stub, $option->getInheritance()) - ->replaceConnection($stub, $option->getPool()) - ->replaceUses($stub, $option->getUses()) - ->replaceClass($stub, $name) - ->replacePrimaryKey($stub, $primaryKey) - ->replaceTable($stub, $table); - } - - protected function getColumns($className, $columns, $forceCasts): array - { - /** @var Model $model */ - $model = new $className(); - $dates = $model->getDates(); - $casts = []; - if (!$forceCasts) { - $casts = $model->getCasts(); - } - - foreach ($dates as $date) { - if (!isset($casts[$date])) { - $casts[$date] = 'datetime'; - } - } - - foreach ($columns as $key => $value) { - $columns[$key]['cast'] = $casts[$value['column_name']] ?? null; - } - - return $columns; - } - - protected function getPrimaryKey(array $columns): string - { - $primaryKey = 'id'; - foreach ($columns as $column) { - if ($column['column_key'] === 'PRI') { - $primaryKey = $column['column_name']; - break; - } - } - return $primaryKey; - } - - protected function createModel(string $table, ModelOption $option) - { - $builder = $this->getSchemaBuilder($option->getPool()); - $table = Str::replaceFirst($option->getPrefix(), '', $table); - $columns = $this->formatColumns($builder->getColumnTypeListing($table)); - - $project = new Project(); - $class = $option->getTableMapping()[$table] ?? Str::studly(Str::singular($table)); - $class = $project->namespace($option->getPath()) . $class; - $path = BASE_PATH . '/' . $project->path($class); - - if (!file_exists($path)) { - $this->mkdir($path); - file_put_contents($path, $this->buildClass($table, $class, $this->getPrimaryKey($columns), $option)); - } - - $columns = $this->getColumns($class, $columns, $option->isForceCasts()); - - $stms = $this->astParser->parse(file_get_contents($path)); - $traverser = new NodeTraverser(); - $traverser->addVisitor(make(ModelUpdateVisitor::class, [ - 'class' => $class, - 'columns' => $columns, - 'option' => $option, - ])); - $traverser->addVisitor(make(ModelRewriteConnectionVisitor::class, [$class, $option->getPool()])); - $data = make(ModelData::class)->setClass($class)->setColumns($columns); - foreach ($option->getVisitors() as $visitorClass) { - $traverser->addVisitor(make($visitorClass, [$option, $data])); - } - $stms = $traverser->traverse($stms); - $code = $this->printer->prettyPrintFile($stms); - - file_put_contents($path, $code); - - if ($option->isWithIde()) { - $this->generateIDE($code, $option, $data); - } - } - - protected function generateIDE(string $code, ModelOption $option, ModelData $data) - { - $stms = $this->astParser->parse($code); - $traverser = new NodeTraverser(); - $traverser->addVisitor(make(GenerateModelIDEVisitor::class, [$option, $data])); - $stms = $traverser->traverse($stms); - $code = $this->printer->prettyPrintFile($stms); - $class = str_replace('\\', '_', $data->getClass()); - $path = BASE_PATH . '/runtime/ide/' . $class . '.php'; - $this->mkdir($path); - file_put_contents($path, $code); - } - - protected function isIgnoreTable(string $table, ModelOption $option): bool - { - if (in_array($table, $option->getIgnoreTables())) { - return true; - } - - return $table === $this->config->get('databases.migrations', 'migrations'); - } - - protected function createModels(ModelOption $option) - { - $builder = $this->getSchemaBuilder($option->getPool()); - $tables = []; - - foreach ($builder->getAllTables() as $row) { - $row = (array)$row; - $table = reset($row); - if (!$this->isIgnoreTable($table, $option)) { - $tables[] = $table; - } - } - - foreach ($tables as $table) { - $this->createModel($table, $option); - } - } - - protected function getOption(string $key, string $pool = 'default', $default = null) - { - return $this->config->get("databases.{$pool}.{$key}", $default); - } - - public function create(string $table = '', string $pool = 'default'): bool - { - $option = new ModelOption(); - $option->setPool($pool) - ->setPath($this->getOption('commands.gen:model.path', $pool, 'app/Model')) - ->setPrefix($this->getOption('prefix', $pool, '')) - ->setInheritance($this->getOption('commands.gen:model.inheritance', $pool, 'Model')) - ->setUses($this->getOption('commands.gen:model.uses', $pool, 'Hyperf\DbConnection\Model\Model')) - ->setForceCasts($this->getOption('commands.gen:model.force_casts', $pool, false)) - ->setRefreshFillable($this->getOption('commands.gen:model.refresh_fillable', $pool, false)) - ->setTableMapping($this->getOption('commands.gen:model.table_mapping', $pool, [])) - ->setIgnoreTables($this->getOption('commands.gen:model.ignore_tables', $pool, [])) - ->setWithComments($this->getOption('commands.gen:model.with_comments', $pool, false)) - ->setWithIde($this->getOption('commands.gen:model.with_ide', $pool, false)) - ->setVisitors($this->getOption('commands.gen:model.visitors', $pool, [])) - ->setPropertyCase($this->getOption('commands.gen:model.property_case', $pool)); - - if ($table) { - $this->createModel($table, $option); - } else { - $this->createModels($option); - } - - return true; - } -} diff --git a/app/Component/Generate/Model/stubs/Model.stub b/app/Component/Generate/Model/stubs/Model.stub deleted file mode 100644 index 1810c39..0000000 --- a/app/Component/Generate/Model/stubs/Model.stub +++ /dev/null @@ -1,45 +0,0 @@ -success($this->request->post()); } - protected function generateCurd(array $params): array - { - $params = [ - 'controller' => 'app/Controller/AdminController', - 'model' => 'app/Model/Ad', - 'actions' => [], - ]; - return [ - 'namespace' => 'App\Controller', - 'classname' => 'AdminController', - 'uses' => [ - 'Hyperf\HttpServer\Annotation\Controller', - 'Lengbin\Hyperf\Auth\RouterAuthAnnotation', - 'Lengbin\Hyperf\Common\Framework\BaseController', - ], - 'comments' => [ - 'Class AdminController', - '@package App\Controller', - '@Controller()', - '@RouterAuthAnnotation(isPublic=true)', - ], - 'inheritance' => 'BaseController', - 'properties' => [ - - ], - 'methods' => [ - - ], - ]; - } - /** * @GetMapping(path="/generate") */ public function generate() { - $data = [ - 'namespace' => 'App\Controller', - 'classname' => 'AdminController', - 'uses' => [ - 'Hyperf\HttpServer\Annotation\Controller', - 'Lengbin\Hyperf\Auth\RouterAuthAnnotation', - 'Lengbin\Hyperf\Common\Framework\BaseController', - ], - 'comments' => [ - 'Class AdminController', - '@package App\Controller', - '@Controller()', - '@RouterAuthAnnotation(isPublic=true)', - ], - 'inheritance' => 'BaseController', - 'constants' => [ - [ - 'name' => 'success', - 'default' => 1, +// $data = [ +// 'namespace' => 'App\Controller', +// 'classname' => 'AdminController', +// 'uses' => [ +// 'Hyperf\HttpServer\Annotation\Controller', +// 'Lengbin\Hyperf\Auth\RouterAuthAnnotation', +// 'Lengbin\Hyperf\Common\Framework\BaseController', +// ], +// 'comments' => [ +// 'Class AdminController', +// '@package App\Controller', +// '@Controller()', +// '@RouterAuthAnnotation(isPublic=true)', +// ], +// 'inheritance' => 'BaseController', +// 'constants' => [ +// [ +// 'name' => 'success', +// 'default' => 1, +// +// ], +// [ +// 'name' => 'fail', +// 'default' => "2", +// +// ], +// ], +// 'properties' => [ +// ["name" => 'abc', 'default' => 1.3], +// ["name" => 'abc2', 'default' => "hello world"], +// ["name" => 'abc3', 'default' => true], +// ["name" => 'abc4'], +// ], +// 'methods' => [ +// [ +// "name" => 'abc', +// 'params' => [ +// ['name' => 'a', 'type' => 'int', 'default' => 1, 'comment' => '左边'], +// ['name' => 'b', 'default' => 2, 'comment' => '中间'], +// ['name' => 'c', 'type' => 'int'], +// ['name' => 'd', 'comment' => '右边'], +// ], +// 'return' => 'int', +// 'content' => '', +// ], +// ], +// ]; +// $generate = new Generate(); +// $generate->setPath(BASE_PATH . '/app/Controller'); +// $config = new ClassConfig($data); +// $generate->setConfig($config); +// return $this->success(['a' => $generate->output('php'), 'b' => $config->__toObjectString(), 'c' => $config->__getClassname()]); +// + $params = [ + 'controller' => 'app/Controller/AdController', + 'model' => 'app/Model/Ad', + 'pool' => 'default', + 'service' => 'app/Service/AdService', + 'actions' => [ + [ + 'name' => '批量删除', + 'type' => 'action', + 'target' => 'button', + 'path' => 'remove', ], [ - 'name' => 'fail', - 'default' => "2", - + 'name' => '创建', + 'type' => 'action', + 'target' => 'button', + 'path' => 'add', ], - ], - 'properties' => [ - ["name" => 'abc', 'default' => 1.3], - ["name" => 'abc2', 'default' => "hello world"], - ["name" => 'abc3', 'default' => true], - ["name" => 'abc4'], - ], - 'methods' => [ [ - "name" => 'abc', - 'params' => [ - ['name' => 'a', 'type' => 'int', 'default' => 1, 'comment' => '左边'], - ['name' => 'b', 'default' => 2, 'comment' => '中间'], - ['name' => 'c', 'type' => 'int'], - ['name' => 'd', 'comment' => '右边'], - ], - 'return' => 'int', - 'content' => '', + 'name' => '编辑', + 'type' => 'operation', + 'target' => 'link', + 'path' => 'detail', + ], + [ + 'name' => '删除', + 'type' => 'operation', + 'target' => 'link', + 'path' => 'remove', ], ], - ]; + 'list' => [ + + ], + 'search' => [ - $generate = new Generate(); - $generate->setPath(BASE_PATH . '/app/Controller'); - $config = new ClassConfig($data); - $generate->setConfig($config); - return $this->success(['a' => $generate->output('php'), 'b' => $config->__toObjectString(), 'c' => $config->__getClassname()]); + ], + 'form' => [ + + ], + ]; + $generateCodeEntity = new GenerateCodeEntity($params); + $this->generateService->file($generateCodeEntity); + return $this->success($generateCodeEntity->toArray()); } } diff --git a/app/Entity/GenerateCodeEntity.php b/app/Entity/GenerateCodeEntity.php new file mode 100644 index 0000000..585e701 --- /dev/null +++ b/app/Entity/GenerateCodeEntity.php @@ -0,0 +1,212 @@ +controller; + } + + /** + * @param string $controller + * + * @return GenerateCodeEntity + */ + public function setController(string $controller): GenerateCodeEntity + { + $this->controller = $controller; + return $this; + } + + /** + * @return string + */ + public function getModel(): string + { + return $this->model; + } + + /** + * @param string $model + * + * @return GenerateCodeEntity + */ + public function setModel(string $model): GenerateCodeEntity + { + $this->model = $model; + return $this; + } + + /** + * @return string + */ + public function getService(): string + { + return $this->service; + } + + /** + * @param string $service + * + * @return GenerateCodeEntity + */ + public function setService(string $service): GenerateCodeEntity + { + $this->service = $service; + return $this; + } + + /** + * @return Link[] + */ + public function getActions(): array + { + return $this->actions; + } + + /** + * @param Link[] $actions + * + * @return GenerateCodeEntity + */ + public function setActions(array $actions): GenerateCodeEntity + { + $this->actions = $actions; + return $this; + } + + /** + * @return Table + */ + public function getTable(): Table + { + return $this->table; + } + + /** + * @param Table $table + * + * @return GenerateCodeEntity + */ + public function setTable(Table $table): GenerateCodeEntity + { + $this->table = $table; + return $this; + } + + /** + * @return array + */ + public function getSearch(): array + { + return $this->search; + } + + /** + * @param array $search + * + * @return GenerateCodeEntity + */ + public function setSearch(array $search): GenerateCodeEntity + { + $this->search = $search; + return $this; + } + + /** + * @return Form + */ + public function getForm(): Form + { + return $this->form; + } + + /** + * @param Form $form + * + * @return GenerateCodeEntity + */ + public function setForm(Form $form): GenerateCodeEntity + { + $this->form = $form; + return $this; + } + + /** + * @return string + */ + public function getPool(): string + { + return $this->pool; + } + + /** + * @param string $pool + * + * @return GenerateCodeEntity + */ + public function setPool(string $pool): GenerateCodeEntity + { + $this->pool = $pool; + return $this; + } +} diff --git a/app/Service/Generate/GenerateService.php b/app/Service/Generate/GenerateService.php new file mode 100644 index 0000000..48e3c26 --- /dev/null +++ b/app/Service/Generate/GenerateService.php @@ -0,0 +1,92 @@ +getPath($name)))); + } + + protected function controllerPhpFile(string $path, array $actions): array + { + $namespace = $this->getNamespace(StringHelper::dirname($path)); + $classname = StringHelper::basename($path); + return [ + 'namespace' => $namespace, + 'classname' => $classname, + 'uses' => [ + 'Hyperf\HttpServer\Annotation\Controller', + 'Lengbin\Hyperf\Auth\RouterAuthAnnotation', + 'Lengbin\Hyperf\Common\Framework\BaseController', + ], + 'comments' => [ + 'Class AdminController', + '@package App\Controller', + '@Controller()', + '@RouterAuthAnnotation(isPublic=true)', + ], + 'inheritance' => 'BaseController', + 'properties' => [ + + ], + 'methods' => [ + + ], + ]; + } + + protected function servicePhpFile(string $path, array $actions): array + { + return [ + 'namespace' => 'App\Controller', + 'classname' => 'AdminController', + 'uses' => [ + 'Hyperf\HttpServer\Annotation\Controller', + 'Lengbin\Hyperf\Auth\RouterAuthAnnotation', + 'Lengbin\Hyperf\Common\Framework\BaseController', + ], + 'comments' => [ + 'Class AdminController', + '@package App\Controller', + '@Controller()', + '@RouterAuthAnnotation(isPublic=true)', + ], + 'inheritance' => 'BaseController', + 'properties' => [ + + ], + 'methods' => [ + + ], + ]; + } + + protected function modelPhpFile(string $path, string $pool): array + { + $model = new GenerateModel(); + $model->create('ad'); + } + + public function file(GenerateCodeEntity $generateCodeEntity) + { + $this->controllerPhpFile($generateCodeEntity->getController(), $generateCodeEntity->getActions()); + $this->servicePhpFile($generateCodeEntity->getService(), $generateCodeEntity->getActions()); + $this->modelPhpFile($generateCodeEntity->getModel(), $generateCodeEntity->getPool()); + } +} From a5ee320dbe8afeb9e80fc34ce780bf9a8b403a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Thu, 31 Dec 2020 23:47:20 +0800 Subject: [PATCH 60/82] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=99=A8=20=E5=87=86=E5=A4=87=E5=89=8D=20demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AntDesign/Constant/Type/FormMethod.php | 33 ++++++++++++ app/Component/AntDesign/Link.php | 6 +++ .../Admin/V1/System/MenuController.php | 41 +++++++++++++++ .../Admin/V1/System/PermissionController.php | 51 +++++++++++++++++++ .../Admin/V1/System/RoleController.php | 51 +++++++++++++++++++ app/Controller/Controller.php | 12 ----- app/Controller/TestController.php | 6 ++- .../{Generate => System}/GenerateService.php | 3 +- app/Service/System/MenuService.php | 10 ++++ app/Service/System/PermissionService.php | 10 ++++ app/Service/System/RoleService.php | 10 ++++ 11 files changed, 218 insertions(+), 15 deletions(-) create mode 100644 app/Component/AntDesign/Constant/Type/FormMethod.php create mode 100644 app/Controller/Admin/V1/System/PermissionController.php create mode 100644 app/Controller/Admin/V1/System/RoleController.php rename app/Service/{Generate => System}/GenerateService.php (98%) create mode 100644 app/Service/System/MenuService.php create mode 100644 app/Service/System/PermissionService.php create mode 100644 app/Service/System/RoleService.php diff --git a/app/Component/AntDesign/Constant/Type/FormMethod.php b/app/Component/AntDesign/Constant/Type/FormMethod.php new file mode 100644 index 0000000..6420aad --- /dev/null +++ b/app/Component/AntDesign/Constant/Type/FormMethod.php @@ -0,0 +1,33 @@ +getValidateData(); + $data = $this->menuService->getList($params); + return $this->success($data); + } + + public function create() + { + $params = $this->getValidateData(); + $this->menuService->create($params); + return $this->success([]); + } + + public function update() + { + $params = $this->getValidateData(); + $this->menuService->update($params); + return $this->success([]); + } + + public function detail() + { + $params = $this->getValidateData(); + $this->menuService->detail($params); + return $this->success([]); + } + + public function remove() + { + $params = $this->getValidateData(); + $this->menuService->remove($params); + return $this->success([]); + } } diff --git a/app/Controller/Admin/V1/System/PermissionController.php b/app/Controller/Admin/V1/System/PermissionController.php new file mode 100644 index 0000000..cb21ff3 --- /dev/null +++ b/app/Controller/Admin/V1/System/PermissionController.php @@ -0,0 +1,51 @@ +getValidateData(); + $data = $this->permissionService->getList($params); + return $this->success($data); + } + + public function create() + { + $params = $this->getValidateData(); + $this->permissionService->create($params); + return $this->success([]); + } + + public function update() + { + $params = $this->getValidateData(); + $this->permissionService->update($params); + return $this->success([]); + } + + public function detail() + { + $params = $this->getValidateData(); + $this->permissionService->detail($params); + return $this->success([]); + } + + public function remove() + { + $params = $this->getValidateData(); + $this->permissionService->remove($params); + return $this->success([]); + } +} diff --git a/app/Controller/Admin/V1/System/RoleController.php b/app/Controller/Admin/V1/System/RoleController.php new file mode 100644 index 0000000..e809bf4 --- /dev/null +++ b/app/Controller/Admin/V1/System/RoleController.php @@ -0,0 +1,51 @@ +getValidateData(); + $data = $this->roleService->getList($params); + return $this->success($data); + } + + public function create() + { + $params = $this->getValidateData(); + $this->roleService->create($params); + return $this->success([]); + } + + public function update() + { + $params = $this->getValidateData(); + $this->roleService->update($params); + return $this->success([]); + } + + public function detail() + { + $params = $this->getValidateData(); + $this->roleService->detail($params); + return $this->success([]); + } + + public function remove() + { + $params = $this->getValidateData(); + $this->roleService->remove($params); + return $this->success([]); + } +} diff --git a/app/Controller/Controller.php b/app/Controller/Controller.php index 9f47c52..813dfab 100644 --- a/app/Controller/Controller.php +++ b/app/Controller/Controller.php @@ -5,7 +5,6 @@ use Hyperf\Contract\ConfigInterface; use Hyperf\Utils\Context; use Lengbin\Auth\User\UserInterface; -use Lengbin\Hyperf\Common\Exception\MethodNotImplException; use Lengbin\Hyperf\Common\Framework\BaseController; class Controller extends BaseController @@ -28,15 +27,4 @@ public function getValidateData(): array { return Context::get('validator.data', []); } - - /** - * 初始化 配置参数 设置 - * @return array - * @throws MethodNotImplException - */ - public function init(): array - { - throw new MethodNotImplException(); - } - } diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index f2cfd3e..b2c69d7 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -10,7 +10,7 @@ use App\Constant\Status\AdminStatus; use App\Entity\GenerateCodeEntity; use App\Service\Admin\AdminService; -use App\Service\Generate\GenerateService; +use App\Service\System\GenerateService; use Hyperf\Di\Annotation\Inject; use Hyperf\HttpServer\Annotation\GetMapping; use Hyperf\HttpServer\Annotation\PostMapping; @@ -276,24 +276,28 @@ public function generate() 'type' => 'action', 'target' => 'button', 'path' => 'remove', + 'method' => 'post', ], [ 'name' => '创建', 'type' => 'action', 'target' => 'button', 'path' => 'add', + 'method' => 'post', ], [ 'name' => '编辑', 'type' => 'operation', 'target' => 'link', 'path' => 'detail', + 'method' => 'post', ], [ 'name' => '删除', 'type' => 'operation', 'target' => 'link', 'path' => 'remove', + 'method' => 'post', ], ], 'list' => [ diff --git a/app/Service/Generate/GenerateService.php b/app/Service/System/GenerateService.php similarity index 98% rename from app/Service/Generate/GenerateService.php rename to app/Service/System/GenerateService.php index 48e3c26..b96e56f 100644 --- a/app/Service/Generate/GenerateService.php +++ b/app/Service/System/GenerateService.php @@ -1,10 +1,9 @@ Date: Sat, 2 Jan 2021 23:39:52 +0800 Subject: [PATCH 61/82] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=99=A8=20=E5=87=86=E5=A4=87=E5=89=8D=20demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Component/AntDesign/Link.php | 19 ++++++++++ .../{ => Admin/V1}/LoginController.php | 13 ++++--- .../Admin/V1/System/MenuController.php | 24 +++++++++++- .../Admin/V1/System/PermissionController.php | 2 +- .../Admin/V1/System/RoleController.php | 2 +- app/Service/Admin/AdminLoginService.php | 2 +- app/Service/System/Manager/ManagerService.php | 37 +++++++++++++++++++ app/Service/System/Manager/MenuService.php | 22 +++++++++++ .../System/Manager/PermissionService.php | 8 ++++ app/Service/System/Manager/RoleService.php | 8 ++++ app/Service/System/MenuService.php | 10 ----- app/Service/System/PermissionService.php | 10 ----- app/Service/System/RoleService.php | 10 ----- migrations/2020_11_15_160222_init.php | 3 +- 14 files changed, 127 insertions(+), 43 deletions(-) rename app/Controller/{ => Admin/V1}/LoginController.php (80%) create mode 100644 app/Service/System/Manager/ManagerService.php create mode 100644 app/Service/System/Manager/MenuService.php create mode 100644 app/Service/System/Manager/PermissionService.php create mode 100644 app/Service/System/Manager/RoleService.php delete mode 100644 app/Service/System/MenuService.php delete mode 100644 app/Service/System/PermissionService.php delete mode 100644 app/Service/System/RoleService.php diff --git a/app/Component/AntDesign/Link.php b/app/Component/AntDesign/Link.php index 93ca79d..0793638 100644 --- a/app/Component/AntDesign/Link.php +++ b/app/Component/AntDesign/Link.php @@ -137,4 +137,23 @@ public function setStatus(ValueEnumTypeStatus $status): Link $this->status = $status; return $this; } + + /** + * @return FormMethod + */ + public function getMethod(): FormMethod + { + return $this->method; + } + + /** + * @param FormMethod $method + * + * @return Link + */ + public function setMethod(FormMethod $method): Link + { + $this->method = $method; + return $this; + } } diff --git a/app/Controller/LoginController.php b/app/Controller/Admin/V1/LoginController.php similarity index 80% rename from app/Controller/LoginController.php rename to app/Controller/Admin/V1/LoginController.php index 89bb7f6..2015d43 100644 --- a/app/Controller/LoginController.php +++ b/app/Controller/Admin/V1/LoginController.php @@ -1,7 +1,8 @@ getValidateData(), 'token'); + $token = ArrayHelper::get($this->getValidateData(), 'Token'); $this->loginService->logout($token, $this->request->getClientIp()); return $this->success([]); } diff --git a/app/Controller/Admin/V1/System/MenuController.php b/app/Controller/Admin/V1/System/MenuController.php index e505d9b..d8542dd 100644 --- a/app/Controller/Admin/V1/System/MenuController.php +++ b/app/Controller/Admin/V1/System/MenuController.php @@ -3,9 +3,20 @@ namespace App\Controller\Admin\V1\System; use App\Controller\Controller; -use App\Service\System\MenuService; +use App\Service\System\Manager\MenuService; +use Hyperf\Apidog\Annotation\ApiController; +use Hyperf\Apidog\Annotation\ApiResponse; +use Hyperf\Apidog\Annotation\Body; +use Hyperf\Apidog\Annotation\PostApi; use Hyperf\Di\Annotation\Inject; +use Lengbin\Hyperf\Common\Entity\PageEntity; +/** + * Class MenuController + * @package App\Controller\Admin\V1\System + * + * @ApiController(tag="菜单", description="菜单管理") + */ class MenuController extends Controller { /** @@ -14,10 +25,19 @@ class MenuController extends Controller */ protected $menuService; + /** + * @PostApi(path="/admin/v1/menu/list", summary="菜单列表", description="菜单列表") + * @Body(rules={ + * "page|页":"int|min:1", + * "pageSize|页数":"int|min:1" + * }) + * @ApiResponse(code="0", template="page") + */ public function list() { $params = $this->getValidateData(); - $data = $this->menuService->getList($params); + $page = new PageEntity($params); + $data = $this->menuService->getList($params, [], $page); return $this->success($data); } diff --git a/app/Controller/Admin/V1/System/PermissionController.php b/app/Controller/Admin/V1/System/PermissionController.php index cb21ff3..99675c6 100644 --- a/app/Controller/Admin/V1/System/PermissionController.php +++ b/app/Controller/Admin/V1/System/PermissionController.php @@ -3,7 +3,7 @@ namespace App\Controller\Admin\V1\System; use App\Controller\Controller; -use App\Service\System\PermissionService; +use App\Service\System\Manager\PermissionService; use Hyperf\Di\Annotation\Inject; class PermissionController extends Controller diff --git a/app/Controller/Admin/V1/System/RoleController.php b/app/Controller/Admin/V1/System/RoleController.php index e809bf4..08a0af1 100644 --- a/app/Controller/Admin/V1/System/RoleController.php +++ b/app/Controller/Admin/V1/System/RoleController.php @@ -3,7 +3,7 @@ namespace App\Controller\Admin\V1\System; use App\Controller\Controller; -use App\Service\System\RoleService; +use App\Service\System\Manager\RoleService; use Hyperf\Di\Annotation\Inject; class RoleController extends Controller diff --git a/app/Service/Admin/AdminLoginService.php b/app/Service/Admin/AdminLoginService.php index 912fe6b..bdd2fee 100644 --- a/app/Service/Admin/AdminLoginService.php +++ b/app/Service/Admin/AdminLoginService.php @@ -27,7 +27,7 @@ class AdminLoginService extends BaseService * * @param Admin|null $admin */ - protected function checkAdminStatus($admin): void + protected function checkAdminStatus(?Admin $admin): void { if (StringHelper::isEmpty($admin) || $admin->status === AdminStatus::FROZEN) { throw new BusinessException(AdminError::ERROR_ADMIN_FREEZE); diff --git a/app/Service/System/Manager/ManagerService.php b/app/Service/System/Manager/ManagerService.php new file mode 100644 index 0000000..8df2c6e --- /dev/null +++ b/app/Service/System/Manager/ManagerService.php @@ -0,0 +1,37 @@ +getPageSize(); + $offset = ($pageEntity->getPage() - 1) * $pageSize; + $list = array_slice($params, $offset, $pageSize); + return [ + 'list' => $list, + 'pageSize' => $pageSize, + 'total' => $total, + 'totalPage' => ceil($total / $pageSize), + ]; + } +} diff --git a/app/Service/System/Manager/MenuService.php b/app/Service/System/Manager/MenuService.php new file mode 100644 index 0000000..7f2ceb0 --- /dev/null +++ b/app/Service/System/Manager/MenuService.php @@ -0,0 +1,22 @@ +manager->getMenus(); + return $this->pageByArray($menus, $pageEntity); + } +} diff --git a/app/Service/System/Manager/PermissionService.php b/app/Service/System/Manager/PermissionService.php new file mode 100644 index 0000000..55618bd --- /dev/null +++ b/app/Service/System/Manager/PermissionService.php @@ -0,0 +1,8 @@ +bigIncrements('admin_id'); - $table->string('account', 32)->comment('账号'); $table->string('password', 255)->comment('密码'); $table->string('role', 255)->comment('角色'); $table->string('nickname', 32)->comment('昵称'); $table->unsignedInteger('number')->default(1)->comment('工号'); $table->unsignedTinyInteger('status')->default(0)->comment('状态,1正常2冻结'); - $table->unsignedTinyInteger('enable')->comment('状态'); $table->unsignedInteger('create_at'); $table->unsignedInteger('update_at'); From 833d2cea09625b16c431b463c80cf1d8f515b1e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Mon, 4 Jan 2021 22:54:54 +0800 Subject: [PATCH 62/82] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constant/Error.php | 20 +++ app/Constant/Errors/System/MenuError.php | 28 +++++ .../Admin/V1/System/MenuController.php | 47 ++++++- app/Service/System/Manager/ManagerService.php | 1 + app/Service/System/Manager/MenuService.php | 118 +++++++++++++++++- server.sh | 2 +- 6 files changed, 210 insertions(+), 6 deletions(-) create mode 100644 app/Constant/Errors/System/MenuError.php diff --git a/app/Constant/Error.php b/app/Constant/Error.php index 6cef55b..b18d154 100644 --- a/app/Constant/Error.php +++ b/app/Constant/Error.php @@ -38,6 +38,26 @@ class Error extends BaseEnum */ const ERROR_COMMENTERRORCODE_INVALID_TOKEN = 'F-000-000-403'; + /** + * @Message("菜单不存在") + */ + const ERROR_SYSTEM_MENUERROR_ERROR_MENU_NOT_FOUND = 'B-001-002-001'; + + /** + * @Message("菜单创建失败") + */ + const ERROR_SYSTEM_MENUERROR_ERROR_MENU_CREATE_FAIL = 'B-001-002-002'; + + /** + * @Message("菜单更新失败") + */ + const ERROR_SYSTEM_MENUERROR_ERROR_MENU_UPDATE_FAIL = 'B-001-002-003'; + + /** + * @Message("菜单删除失败") + */ + const ERROR_SYSTEM_MENUERROR_ERROR_MENU_REMOVE_FAIL = 'B-001-002-004'; + /** * @Message("账号被冻结,请联系管理员") */ diff --git a/app/Constant/Errors/System/MenuError.php b/app/Constant/Errors/System/MenuError.php new file mode 100644 index 0000000..0562ab7 --- /dev/null +++ b/app/Constant/Errors/System/MenuError.php @@ -0,0 +1,28 @@ +success($data); } + /** + * @PostApi(path="/admin/v1/menu/create", summary="菜单创建", description="菜单创建") + * @Body(rules={ + * "name|菜单名称":"required|string|max:64", + * "pid|上一级":"string|max:64", + * "icon|菜单图标":"required|string|max:64", + * "path|菜单路由":"string|max:255", + * "template|模版":"string|max:64", + * "role|角色":"required|string|max:64", + * "sort|排序":"required|int", + * }) + * @ApiResponse(code="0", template="success") + */ public function create() { $params = $this->getValidateData(); @@ -48,6 +62,19 @@ public function create() return $this->success([]); } + /** + * @PostApi(path="/admin/v1/menu/update", summary="菜单更新", description="菜单更新") + * @Body(rules={ + * "name|菜单名称":"required|string|max:64", + * "pid|上一级":"string|max:64", + * "icon|菜单图标":"required|string|max:64", + * "path|菜单路由":"string|max:255", + * "template|模版":"string|max:64", + * "role|角色":"required|string|max:64", + * "sort|排序":"required|int", + * }) + * @ApiResponse(code="0", template="success") + */ public function update() { $params = $this->getValidateData(); @@ -55,13 +82,27 @@ public function update() return $this->success([]); } + /** + * @PostApi(path="/admin/v1/menu/detail", summary="菜单详情", description="菜单详情") + * @Body(rules={ + * "name|菜单名称":"required|string|max:64" + * }) + * @ApiResponse(code="0", template="success") + */ public function detail() { $params = $this->getValidateData(); - $this->menuService->detail($params); - return $this->success([]); + $data = $this->menuService->detail($params); + return $this->success($data); } + /** + * @PostApi(path="/admin/v1/menu/remove", summary="菜单移除", description="菜单移除") + * @Body(rules={ + * "name|菜单名称":"required|string|max:64" + * }) + * @ApiResponse(code="0", template="success") + */ public function remove() { $params = $this->getValidateData(); diff --git a/app/Service/System/Manager/ManagerService.php b/app/Service/System/Manager/ManagerService.php index 8df2c6e..5c30892 100644 --- a/app/Service/System/Manager/ManagerService.php +++ b/app/Service/System/Manager/ManagerService.php @@ -26,6 +26,7 @@ public function pageByArray(array $params, PageEntity $pageEntity): array $total = count($params); $pageSize = $pageEntity->getPageSize(); $offset = ($pageEntity->getPage() - 1) * $pageSize; + $params = array_values($params); $list = array_slice($params, $offset, $pageSize); return [ 'list' => $list, diff --git a/app/Service/System/Manager/MenuService.php b/app/Service/System/Manager/MenuService.php index 7f2ceb0..4bbf96a 100644 --- a/app/Service/System/Manager/MenuService.php +++ b/app/Service/System/Manager/MenuService.php @@ -2,11 +2,32 @@ namespace App\Service\System\Manager; +use App\Constant\Errors\System\MenuError; use Lengbin\Hyperf\Common\Entity\PageEntity; +use Lengbin\Hyperf\Common\Exception\BusinessException; +use Lengbin\YiiSoft\Rbac\Menu; +use Throwable; class MenuService extends ManagerService { + /** + * @param array $params + * + * @return array + */ + public function getMenus(array $params): array + { + $role = $params['role'] ?? ''; + $menus = $this->manager->getMenus($role); + if (empty($params['pid'])) { + $params['pid'] = ''; + } + return array_filter($menus, function ($menu) use ($params) { + return $menu->getPid() === $params['pid']; + }); + } + /** * @param array $params * @param array|string[] $field @@ -16,7 +37,100 @@ class MenuService extends ManagerService */ public function getList(array $params = [], array $field = ['*'], ?PageEntity $pageEntity = null): array { - $menus = $this->manager->getMenus(); - return $this->pageByArray($menus, $pageEntity); + $menus = $this->getMenus($params); + $results = $this->pageByArray($menus, $pageEntity); + return $this->toArray($results, function ($result) { + $result = $result->getAttributes(); + $result['create_at'] = date('Y-m-d H:i:s', $result['created_at']); + $result['update_at'] = date('Y-m-d H:i:s', $result['updated_at']); + return $result; + }); + } + + /** + * @param array $params + * + * @return Menu + */ + protected function populateMenu(array $params): Menu + { + return (new Menu($params['name']))->withPid($params['pid']) + ->withIcon($params['icon']) + ->withPath($params['path']) + ->withSort($params['sort']) + ->withTemplate($params['template']) + ->withRole($params['role']); + } + + /** + * @param array $params + * + * @return array + */ + public function create(array $params): array + { + try { + $menu = $this->populateMenu($params); + $this->manager->add($menu); + return $params; + } catch (Throwable $exception) { + throw new BusinessException(MenuError::ERROR_MENU_CREATE_FAIL); + } + } + + /** + * @param array $params + * + * @return array + */ + public function update(array $params): array + { + try { + $menu = $this->populateMenu($params); + $this->manager->update($params['name'], $menu); + return $params; + } catch (Throwable $exception) { + throw new BusinessException(MenuError::ERROR_MENU_UPDATE_FAIL); + } + } + + public function findOne(string $name): Menu + { + $menu = $this->manager->getMenu($name); + if (!$menu) { + throw new BusinessException(MenuError::ERROR_MENU_NOT_FOUND); + } + return $menu; + } + + /** + * @param array $params + * @param array|string[] $field + * + * @return array + */ + public function detail(array $params, array $field = ['*']): array + { + $menu = $this->findOne($params['name']); + $result = $menu->getAttributes(); + $result['create_at'] = date('Y-m-d H:i:s', $result['created_at']); + $result['update_at'] = date('Y-m-d H:i:s', $result['updated_at']); + return $result; + } + + /** + * @param array $params + * + * @return int + */ + public function remove(array $params): int + { + try { + $menu = $this->findOne($params['name']); + $this->manager->remove($menu); + return 1; + } catch (Throwable $exception) { + throw new BusinessException(MenuError::ERROR_MENU_REMOVE_FAIL); + } } } diff --git a/server.sh b/server.sh index 9fe752a..b80456f 100644 --- a/server.sh +++ b/server.sh @@ -8,6 +8,6 @@ # #rm -rf runtime/container -php bin/hyperf.php gen:error-code +php -d swoole.use_shortname=Off bin/hyperf.php gen:error-code # php -d swoole.use_shortname=Off -e bin/hyperf.php start From 3e9bb1eac35084c82578dde47de3e6b70bffe271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Wed, 6 Jan 2021 19:50:26 +0800 Subject: [PATCH 63/82] =?UTF-8?q?=E8=A7=92=E8=89=B2=20=E6=9D=83=E9=99=90?= =?UTF-8?q?=20=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constant/Error.php | 40 ++++ .../Errors/System/PermissionError.php | 28 +++ app/Constant/Errors/System/RoleError.php | 28 +++ .../Admin/V1/System/PermissionController.php | 68 ++++++- .../Admin/V1/System/RoleController.php | 58 +++++- app/Service/System/Manager/ManagerService.php | 38 ---- app/Service/System/Manager/MenuService.php | 20 +- .../System/Manager/PermissionService.php | 180 +++++++++++++++++- app/Service/System/Manager/RoleService.php | 164 +++++++++++++++- migrations/2020_11_15_160222_init.php | 1 + 10 files changed, 575 insertions(+), 50 deletions(-) create mode 100644 app/Constant/Errors/System/PermissionError.php create mode 100644 app/Constant/Errors/System/RoleError.php delete mode 100644 app/Service/System/Manager/ManagerService.php diff --git a/app/Constant/Error.php b/app/Constant/Error.php index b18d154..2842c11 100644 --- a/app/Constant/Error.php +++ b/app/Constant/Error.php @@ -38,6 +38,26 @@ class Error extends BaseEnum */ const ERROR_COMMENTERRORCODE_INVALID_TOKEN = 'F-000-000-403'; + /** + * @Message("权限不存在") + */ + const ERROR_SYSTEM_PERMISSIONERROR_ERROR_PERMISSION_NOT_FOUND = 'B-001-004-001'; + + /** + * @Message("权限创建失败") + */ + const ERROR_SYSTEM_PERMISSIONERROR_ERROR_PERMISSION_CREATE_FAIL = 'B-001-004-002'; + + /** + * @Message("权限更新失败") + */ + const ERROR_SYSTEM_PERMISSIONERROR_ERROR_PERMISSION_UPDATE_FAIL = 'B-001-004-003'; + + /** + * @Message("权限删除失败") + */ + const ERROR_SYSTEM_PERMISSIONERROR_ERROR_PERMISSION_REMOVE_FAIL = 'B-001-004-004'; + /** * @Message("菜单不存在") */ @@ -58,6 +78,26 @@ class Error extends BaseEnum */ const ERROR_SYSTEM_MENUERROR_ERROR_MENU_REMOVE_FAIL = 'B-001-002-004'; + /** + * @Message("角色不存在") + */ + const ERROR_SYSTEM_ROLEERROR_ERROR_ROLE_NOT_FOUND = 'B-001-003-001'; + + /** + * @Message("角色创建失败") + */ + const ERROR_SYSTEM_ROLEERROR_ERROR_ROLE_CREATE_FAIL = 'B-001-003-002'; + + /** + * @Message("角色更新失败") + */ + const ERROR_SYSTEM_ROLEERROR_ERROR_ROLE_UPDATE_FAIL = 'B-001-003-003'; + + /** + * @Message("角色删除失败") + */ + const ERROR_SYSTEM_ROLEERROR_ERROR_ROLE_REMOVE_FAIL = 'B-001-003-004'; + /** * @Message("账号被冻结,请联系管理员") */ diff --git a/app/Constant/Errors/System/PermissionError.php b/app/Constant/Errors/System/PermissionError.php new file mode 100644 index 0000000..6d5d16d --- /dev/null +++ b/app/Constant/Errors/System/PermissionError.php @@ -0,0 +1,28 @@ +getValidateData(); - $data = $this->permissionService->getList($params); + $data = $this->permissionService->getPermissions(); return $this->success($data); } + /** + * @PostApi(path="/admin/v1/permission/create", summary="权限创建", description="权限创建") + * @Body(rules={ + * "name|path":"required|string|max:64", + * "description|名称":"required|string", + * "node.*|节点":"required|string|max:64", + * }) + * @ApiResponse(code="0", template="success") + */ public function create() { $params = $this->getValidateData(); @@ -28,6 +51,15 @@ public function create() return $this->success([]); } + /** + * @PostApi(path="/admin/v1/permission/update", summary="权限更新", description="权限更新") + * @Body(rules={ + * "name|path":"required|string|max:64", + * "description|名称":"required|string", + * "node.*|节点":"required|string|max:64", + * }) + * @ApiResponse(code="0", template="success") + */ public function update() { $params = $this->getValidateData(); @@ -35,17 +67,45 @@ public function update() return $this->success([]); } + /** + * @PostApi(path="/admin/v1/permission/detail", summary="权限详情", description="权限详情") + * @Body(rules={ + * "name|权限名称":"required|string|max:64" + * }) + * @ApiResponse(code="0", template="success") + */ public function detail() { $params = $this->getValidateData(); - $this->permissionService->detail($params); - return $this->success([]); + $data = $this->permissionService->detail($params); + return $this->success($data); } + /** + * @PostApi(path="/admin/v1/permission/remove", summary="权限移除", description="权限移除") + * @Body(rules={ + * "name|权限名称":"required|string|max:64" + * }) + * @ApiResponse(code="0", template="success") + */ public function remove() { $params = $this->getValidateData(); $this->permissionService->remove($params); return $this->success([]); } + + /** + * @PostApi(path="/admin/v1/permission/search", summary="权限节点筛选", description="权限节点筛选") + * @Body(rules={ + * "name|权限名称":"required|string|max:64" + * }) + * @ApiResponse(code="0", template="success") + */ + public function search() + { + $params = $this->getValidateData(); + $data = $this->permissionService->search($params['name']); + return $this->success($data); + } } diff --git a/app/Controller/Admin/V1/System/RoleController.php b/app/Controller/Admin/V1/System/RoleController.php index 08a0af1..4a2bfbf 100644 --- a/app/Controller/Admin/V1/System/RoleController.php +++ b/app/Controller/Admin/V1/System/RoleController.php @@ -5,7 +5,18 @@ use App\Controller\Controller; use App\Service\System\Manager\RoleService; use Hyperf\Di\Annotation\Inject; +use Hyperf\Apidog\Annotation\ApiController; +use Hyperf\Apidog\Annotation\ApiResponse; +use Hyperf\Apidog\Annotation\Body; +use Hyperf\Apidog\Annotation\PostApi; +use Lengbin\Hyperf\Common\Entity\PageEntity; +/** + * Class RoleController + * @package App\Controller\Admin\V1\System + * + * @ApiController(tag="角色", description="角色管理") + */ class RoleController extends Controller { /** @@ -14,13 +25,31 @@ class RoleController extends Controller */ protected $roleService; + /** + * @PostApi(path="/admin/v1/role/list", summary="角色列表", description="角色列表") + * @Body(rules={ + * "page|页":"int|min:1", + * "pageSize|页数":"int|min:1", + * }) + * @ApiResponse(code="0", template="page") + */ public function list() { $params = $this->getValidateData(); - $data = $this->roleService->getList($params); + $page = new PageEntity($params); + $data = $this->roleService->getList($params, [], $page); return $this->success($data); } + /** + * @PostApi(path="/admin/v1/role/create", summary="角色创建", description="角色创建") + * @Body(rules={ + * "name|角色名称":"required|string|max:64", + * "description|描述":"string", + * "permission.*|权限":"required|string|max:64", + * }) + * @ApiResponse(code="0", template="success") + */ public function create() { $params = $this->getValidateData(); @@ -28,6 +57,15 @@ public function create() return $this->success([]); } + /** + * @PostApi(path="/admin/v1/role/update", summary="角色更新", description="角色更新") + * @Body(rules={ + * "name|角色名称":"required|string|max:64", + * "description|描述":"string", + * "permission.*|权限":"required|string|max:64", + * }) + * @ApiResponse(code="0", template="success") + */ public function update() { $params = $this->getValidateData(); @@ -35,13 +73,27 @@ public function update() return $this->success([]); } + /** + * @PostApi(path="/admin/v1/role/detail", summary="角色详情", description="角色详情") + * @Body(rules={ + * "name|角色名称":"required|string|max:64" + * }) + * @ApiResponse(code="0", template="success") + */ public function detail() { $params = $this->getValidateData(); - $this->roleService->detail($params); - return $this->success([]); + $data = $this->roleService->detail($params); + return $this->success($data); } + /** + * @PostApi(path="/admin/v1/role/remove", summary="角色移除", description="角色移除") + * @Body(rules={ + * "name|角色名称":"required|string|max:64" + * }) + * @ApiResponse(code="0", template="success") + */ public function remove() { $params = $this->getValidateData(); diff --git a/app/Service/System/Manager/ManagerService.php b/app/Service/System/Manager/ManagerService.php deleted file mode 100644 index 5c30892..0000000 --- a/app/Service/System/Manager/ManagerService.php +++ /dev/null @@ -1,38 +0,0 @@ -getPageSize(); - $offset = ($pageEntity->getPage() - 1) * $pageSize; - $params = array_values($params); - $list = array_slice($params, $offset, $pageSize); - return [ - 'list' => $list, - 'pageSize' => $pageSize, - 'total' => $total, - 'totalPage' => ceil($total / $pageSize), - ]; - } -} diff --git a/app/Service/System/Manager/MenuService.php b/app/Service/System/Manager/MenuService.php index 4bbf96a..f050ff5 100644 --- a/app/Service/System/Manager/MenuService.php +++ b/app/Service/System/Manager/MenuService.php @@ -3,14 +3,23 @@ namespace App\Service\System\Manager; use App\Constant\Errors\System\MenuError; +use Hyperf\Di\Annotation\Inject; use Lengbin\Hyperf\Common\Entity\PageEntity; use Lengbin\Hyperf\Common\Exception\BusinessException; +use Lengbin\Hyperf\Common\Framework\BaseService; +use Lengbin\YiiSoft\Rbac\ManagerInterface; use Lengbin\YiiSoft\Rbac\Menu; use Throwable; -class MenuService extends ManagerService +class MenuService extends BaseService { + /** + * @Inject() + * @var ManagerInterface + */ + protected $manager; + /** * @param array $params * @@ -23,9 +32,9 @@ public function getMenus(array $params): array if (empty($params['pid'])) { $params['pid'] = ''; } - return array_filter($menus, function ($menu) use ($params) { + return array_values(array_filter($menus, function ($menu) use ($params) { return $menu->getPid() === $params['pid']; - }); + })); } /** @@ -94,6 +103,11 @@ public function update(array $params): array } } + /** + * @param string $name + * + * @return Menu + */ public function findOne(string $name): Menu { $menu = $this->manager->getMenu($name); diff --git a/app/Service/System/Manager/PermissionService.php b/app/Service/System/Manager/PermissionService.php index 55618bd..cc6ba3e 100644 --- a/app/Service/System/Manager/PermissionService.php +++ b/app/Service/System/Manager/PermissionService.php @@ -2,7 +2,185 @@ namespace App\Service\System\Manager; -class PermissionService extends ManagerService +use App\Constant\Errors\System\PermissionError; +use Hyperf\DbConnection\Db; +use Hyperf\Di\Annotation\Inject; +use Lengbin\Helper\YiiSoft\StringHelper; +use Lengbin\Hyperf\Common\Exception\BusinessException; +use Lengbin\Hyperf\Common\Framework\BaseService; +use Lengbin\YiiSoft\Rbac\Item; +use Lengbin\YiiSoft\Rbac\ManagerInterface; +use Lengbin\YiiSoft\Rbac\Permission; +use Throwable; + +class PermissionService extends BaseService { + /** + * @Inject() + * @var ManagerInterface + */ + protected $manager; + + public function populateItem(array $row): Item + { + return (new Permission($row['name']))->withDescription($row['description'] ?? '')->withRuleName($row['rule_name'] ?? null); + } + + /** + * @param array $params + * + * @return array + */ + public function create(array $params): array + { + try { + Db::beginTransaction(); + $permission = $this->populateItem($params); + $this->manager->add($permission); + if (!empty($params['node'])) { + foreach ($params['node'] as $name) { + $node = $this->findOne($name); + if ($this->manager->hasChild($permission, $node) || $this->manager->canAddChild($permission, $node)) { + continue; + } + $this->manager->addChild($permission, $node); + } + } + Db::commit(); + return $params; + } catch (Throwable $exception) { + Db::rollBack(); + throw new BusinessException(PermissionError::ERROR_PERMISSION_CREATE_FAIL); + } + } + + /** + * @param string $name + * + * @return Permission + */ + public function findOne(string $name): Permission + { + $permission = $this->manager->getPermission($name); + if (!$permission) { + throw new BusinessException(PermissionError::ERROR_PERMISSION_NOT_FOUND); + } + return $permission; + } + + /** + * @param array $params + * + * @return array + */ + public function update(array $params): array + { + try { + Db::beginTransaction(); + $this->findOne($params['name']); + $permission = $this->populateItem($params); + $this->manager->update($params['name'], $permission); + $this->manager->removeChildren($permission); + if (!empty($params['node'])) { + foreach ($params['node'] as $name) { + $node = $this->findOne($name); + if ($this->manager->hasChild($permission, $node) || $this->manager->canAddChild($permission, $node)) { + continue; + } + $this->manager->addChild($permission, $node); + } + } + Db::commit(); + return $params; + } catch (Throwable $exception) { + Db::rollBack(); + throw new BusinessException(PermissionError::ERROR_PERMISSION_UPDATE_FAIL); + } + } + + /** + * @param array $params + * @param array|string[] $field + * + * @return array + */ + public function detail(array $params, array $field = ['*']): array + { + $permission = $this->findOne($params['name']); + $nodes = $this->manager->getPermissionsByRole($permission->getName()); + $data = []; + foreach ($nodes as $node) { + $data[] = $node->getName(); + } + $description = explode("-", $permission->getDescription()); + array_shift($description); + return [ + 'name' => $permission->getName(), + 'full_description' => $permission->getDescription(), + 'description' => implode('', $description), + 'rule_name' => $permission->getRuleName(), + 'node' => $data, + 'create_at' => date('Y-m-d H:i:s', $permission->getCreatedAt()), + 'update_at' => date('Y-m-d H:i:s', $permission->getUpdatedAt()), + ]; + } + + /** + * @param array $params + * + * @return int + */ + public function remove(array $params): int + { + try { + $menu = $this->findOne($params['name']); + $this->manager->remove($menu); + Db::commit(); + return 1; + } catch (Throwable $exception) { + Db::rollBack(); + throw new BusinessException(PermissionError::ERROR_PERMISSION_REMOVE_FAIL); + } + } + + /** + * @return array + */ + public function getPermissions(): array + { + $result = []; + $permissions = $this->manager->getPermissions(); + foreach ($permissions as $permission) { + $data = explode("-", $permission->getDescription()); + if (count($data) === 1) { + continue; + } + $title = array_shift($data); + if (empty($result[$title])) { + $result[$title] = []; + } + $result[$title][] = [ + 'name' => $permission->getName(), + 'full_description' => $permission->getDescription(), + 'description' => implode('', $data), + 'rule_name' => $permission->getRuleName(), + 'create_at' => date('Y-m-d H:i:s', $permission->getCreatedAt()), + 'update_at' => date('Y-m-d H:i:s', $permission->getUpdatedAt()), + ]; + } + return $result; + } + /** + * @param string $name + * + * @return array + */ + public function search(string $name): array + { + $permissions = array_keys($this->manager->getPermissions()); + return array_values(array_filter($permissions, function ($permission) use ($name) { + return $permission === $name ? true : StringHelper::matchWildcard($name . '*', $permission); + })); + } } diff --git a/app/Service/System/Manager/RoleService.php b/app/Service/System/Manager/RoleService.php index 9d891ab..c31529b 100644 --- a/app/Service/System/Manager/RoleService.php +++ b/app/Service/System/Manager/RoleService.php @@ -2,7 +2,169 @@ namespace App\Service\System\Manager; -class RoleService extends ManagerService +use App\Constant\Errors\System\RoleError; +use Hyperf\DbConnection\Db; +use Hyperf\Di\Annotation\Inject; +use Lengbin\Hyperf\Common\Entity\PageEntity; +use Lengbin\Hyperf\Common\Exception\BusinessException; +use Lengbin\Hyperf\Common\Framework\BaseService; +use Lengbin\YiiSoft\Rbac\Item; +use Lengbin\YiiSoft\Rbac\ManagerInterface; +use Lengbin\YiiSoft\Rbac\Role; +use Throwable; + +class RoleService extends BaseService { + /** + * @Inject() + * @var ManagerInterface + */ + protected $manager; + + /** + * @Inject + * @var PermissionService + */ + protected $permissionService; + + /** + * @param array $params + * @param array|string[] $field + * @param PageEntity|null $pageEntity + * + * @return array + */ + public function getList(array $params = [], array $field = ['*'], ?PageEntity $pageEntity = null): array + { + $roles = $this->manager->getRoles(); + $results = $this->pageByArray($roles, $pageEntity); + return $this->toArray($results, function ($result) { + $result = [ + 'name' => $result->getName(), + 'description' => $result->getDescription(), + 'create_at' => date('Y-m-d H:i:s', $result->getCreatedAt()), + 'update_at' => date('Y-m-d H:i:s', $result->getUpdatedAt()), + ]; + return $result; + }); + } + + /** + * @param array $row + * + * @return Item + */ + public function populateItem(array $row): Item + { + return (new Role($row['name']))->withDescription($row['description'] ?? '')->withRuleName($row['rule_name'] ?? null); + } + + /** + * @param array $params + * + * @return array + */ + public function create(array $params): array + { + try { + Db::beginTransaction(); + $role = $this->populateItem($params); + $this->manager->add($role); + foreach ($params['permission'] as $name) { + $permission = $this->permissionService->findOne($name); + if ($this->manager->hasChild($role, $permission)) { + continue; + } + $this->manager->addChild($role, $permission); + } + Db::commit(); + return $params; + } catch (Throwable $exception) { + Db::rollBack(); + throw new BusinessException(RoleError::ERROR_ROLE_CREATE_FAIL); + } + } + + /** + * @param string $name + * + * @return Role + */ + public function findOne(string $name): Role + { + $role = $this->manager->getRole($name); + if (!$role) { + throw new BusinessException(RoleError::ERROR_ROLE_NOT_FOUND); + } + return $role; + } + + /** + * @param array $params + * + * @return array + */ + public function update(array $params): array + { + try { + Db::beginTransaction(); + $this->findOne($params['name']); + $role = $this->populateItem($params); + $this->manager->update($params['name'], $role); + $this->manager->removeChildren($role); + foreach ($params['permission'] as $name) { + $permission = $this->permissionService->findOne($name); + if ($this->manager->hasChild($role, $permission)) { + continue; + } + $this->manager->addChild($role, $permission); + } + Db::commit(); + return $params; + } catch (Throwable $exception) { + Db::rollBack(); + throw new BusinessException(RoleError::ERROR_ROLE_UPDATE_FAIL); + } + } + + /** + * @param array $params + * @param array|string[] $field + * + * @return array + */ + public function detail(array $params, array $field = ['*']): array + { + $role = $this->findOne($params['name']); + $permissions = $this->manager->getPermissionsByRole($role->getName()); + $data = []; + foreach ($permissions as $permission) { + $data[] = $permission->getName(); + } + return [ + 'name' => $role->getName(), + 'description' => $role->getDescription(), + 'permission' => $data, + 'create_at' => date('Y-m-d H:i:s', $role->getCreatedAt()), + 'update_at' => date('Y-m-d H:i:s', $role->getUpdatedAt()), + ]; + } + /** + * @param array $params + * + * @return int + */ + public function remove(array $params): int + { + try { + $role = $this->findOne($params['name']); + $this->manager->remove($role); + Db::commit(); + return 1; + } catch (Throwable $exception) { + Db::rollBack(); + throw new BusinessException(RoleError::ERROR_ROLE_REMOVE_FAIL); + } + } } diff --git a/migrations/2020_11_15_160222_init.php b/migrations/2020_11_15_160222_init.php index 736c30a..9de6791 100644 --- a/migrations/2020_11_15_160222_init.php +++ b/migrations/2020_11_15_160222_init.php @@ -19,6 +19,7 @@ public function up(): void $table->string('role', 255)->comment('角色'); $table->string('nickname', 32)->comment('昵称'); $table->unsignedInteger('number')->default(1)->comment('工号'); + $table->unsignedTinyInteger('is_supper_admin')->default(0)->comment('是否超级管理'); $table->unsignedTinyInteger('status')->default(0)->comment('状态,1正常2冻结'); $table->unsignedTinyInteger('enable')->comment('状态'); $table->unsignedInteger('create_at'); From 090f7a5be6dd80ee501ad5f7521a837eb43bc3fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Wed, 6 Jan 2021 19:50:54 +0800 Subject: [PATCH 64/82] =?UTF-8?q?=E8=A7=92=E8=89=B2=20=E6=9D=83=E9=99=90?= =?UTF-8?q?=20=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/Admin/V1/System/PermissionController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Controller/Admin/V1/System/PermissionController.php b/app/Controller/Admin/V1/System/PermissionController.php index 93bb335..6d1d667 100644 --- a/app/Controller/Admin/V1/System/PermissionController.php +++ b/app/Controller/Admin/V1/System/PermissionController.php @@ -9,7 +9,6 @@ use Hyperf\Apidog\Annotation\ApiResponse; use Hyperf\Apidog\Annotation\Body; use Hyperf\Apidog\Annotation\PostApi; -use Lengbin\Hyperf\Common\Entity\PageEntity; /** * Class PermissionController From c1295ade9b9e8704ea4918bfb723e39af805f8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Wed, 6 Jan 2021 22:33:54 +0800 Subject: [PATCH 65/82] =?UTF-8?q?=E8=A7=92=E8=89=B2=20=E6=9D=83=E9=99=90?= =?UTF-8?q?=20=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../System/Manager/PermissionService.php | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/Service/System/Manager/PermissionService.php b/app/Service/System/Manager/PermissionService.php index cc6ba3e..2d40e92 100644 --- a/app/Service/System/Manager/PermissionService.php +++ b/app/Service/System/Manager/PermissionService.php @@ -113,10 +113,11 @@ public function detail(array $params, array $field = ['*']): array $data[] = $node->getName(); } $description = explode("-", $permission->getDescription()); - array_shift($description); + $group = array_shift($description); return [ 'name' => $permission->getName(), 'full_description' => $permission->getDescription(), + 'group' => $group, 'description' => implode('', $description), 'rule_name' => $permission->getRuleName(), 'node' => $data, @@ -151,24 +152,31 @@ public function getPermissions(): array $result = []; $permissions = $this->manager->getPermissions(); foreach ($permissions as $permission) { - $data = explode("-", $permission->getDescription()); - if (count($data) === 1) { + $names = explode("-", $permission->getDescription()); + if (count($names) === 1) { continue; } - $title = array_shift($data); + $title = array_shift($names); if (empty($result[$title])) { $result[$title] = []; } $result[$title][] = [ 'name' => $permission->getName(), 'full_description' => $permission->getDescription(), - 'description' => implode('', $data), + 'description' => implode('', $names), 'rule_name' => $permission->getRuleName(), 'create_at' => date('Y-m-d H:i:s', $permission->getCreatedAt()), 'update_at' => date('Y-m-d H:i:s', $permission->getUpdatedAt()), ]; } - return $result; + $data = []; + foreach ($result as $name => $item) { + $data[] = [ + 'group' => $name, + 'item' => $item, + ]; + } + return $data; } /** From 1eba7d6c6ec4552149762ea77a15c947c3cc4db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Thu, 7 Jan 2021 18:45:53 +0800 Subject: [PATCH 66/82] fix menu manager --- app/Service/System/Manager/MenuService.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Service/System/Manager/MenuService.php b/app/Service/System/Manager/MenuService.php index f050ff5..accc73d 100644 --- a/app/Service/System/Manager/MenuService.php +++ b/app/Service/System/Manager/MenuService.php @@ -50,6 +50,9 @@ public function getList(array $params = [], array $field = ['*'], ?PageEntity $p $results = $this->pageByArray($menus, $pageEntity); return $this->toArray($results, function ($result) { $result = $result->getAttributes(); + if (!is_array($result['role'])) { + $result['role'] = explode(',', $result['role']); + } $result['create_at'] = date('Y-m-d H:i:s', $result['created_at']); $result['update_at'] = date('Y-m-d H:i:s', $result['updated_at']); return $result; @@ -63,12 +66,16 @@ public function getList(array $params = [], array $field = ['*'], ?PageEntity $p */ protected function populateMenu(array $params): Menu { + $role = $params['role']; + if (!is_array($role)) { + $role = [$role]; + } return (new Menu($params['name']))->withPid($params['pid']) ->withIcon($params['icon']) ->withPath($params['path']) ->withSort($params['sort']) ->withTemplate($params['template']) - ->withRole($params['role']); + ->withRole(implode(',', $role)); } /** @@ -127,6 +134,7 @@ public function detail(array $params, array $field = ['*']): array { $menu = $this->findOne($params['name']); $result = $menu->getAttributes(); + $result['role'] = explode(',', $result['role']); $result['create_at'] = date('Y-m-d H:i:s', $result['created_at']); $result['update_at'] = date('Y-m-d H:i:s', $result['updated_at']); return $result; From 365fc89d855ab49383f1a54a9bd589708f72d34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Fri, 8 Jan 2021 16:08:29 +0800 Subject: [PATCH 67/82] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constant/Error.php | 5 + app/Constant/Errors/AdminError.php | 5 + .../Admin/V1/Admin/AdminController.php | 136 +++++++++++++ app/Controller/Admin/V1/LoginController.php | 6 +- .../Admin/V1/System/MenuController.php | 2 + .../Admin/V1/System/PermissionController.php | 2 + .../Admin/V1/System/RoleController.php | 5 +- app/Service/Admin/AdminService.php | 186 +++++++++++++++++- app/Service/System/Manager/MenuService.php | 9 + app/Service/System/Manager/RoleService.php | 28 ++- migrations/2020_11_15_160222_init.php | 1 - 11 files changed, 378 insertions(+), 7 deletions(-) create mode 100644 app/Controller/Admin/V1/Admin/AdminController.php diff --git a/app/Constant/Error.php b/app/Constant/Error.php index 2842c11..e9e98f8 100644 --- a/app/Constant/Error.php +++ b/app/Constant/Error.php @@ -128,4 +128,9 @@ class Error extends BaseEnum */ const ERROR_ADMINERROR_ERROR_ADMIN_ACCOUNT_OR_PASSWORD_FAIL = 'B-001-001-006'; + /** + * @Message("账号已存在") + */ + const ERROR_ADMINERROR_ERROR_ADMIN_EXIST = 'B-001-001-007'; + } diff --git a/app/Constant/Errors/AdminError.php b/app/Constant/Errors/AdminError.php index bb4a029..3302c8a 100644 --- a/app/Constant/Errors/AdminError.php +++ b/app/Constant/Errors/AdminError.php @@ -35,4 +35,9 @@ class AdminError extends BaseEnum * @Message("账号或密码错误") */ public const ERROR_ADMIN_ACCOUNT_OR_PASSWORD_FAIL = 'B-001-001-006'; + + /** + * @Message("账号已存在") + */ + public const ERROR_ADMIN_EXIST = 'B-001-001-007'; } diff --git a/app/Controller/Admin/V1/Admin/AdminController.php b/app/Controller/Admin/V1/Admin/AdminController.php new file mode 100644 index 0000000..52526a0 --- /dev/null +++ b/app/Controller/Admin/V1/Admin/AdminController.php @@ -0,0 +1,136 @@ +getValidateData(); + $page = new PageEntity($params); + $data = $this->adminService->getList($params, [ + 'admin_id', + 'account', + 'role', + 'nickname', + 'number', + 'status', + ], $page); + return $this->success($data); + } + + /** + * @PostApi(path="/admin/v1/admin/create", summary="管理员创建", description="管理员创建") + * @Body(rules={ + * "account|账号":"required|string|max:32", + * "password|密码":"required|string|max:64", + * "role|角色":"required|string|max:255", + * "nickname|昵称":"required|string|max:32", + * }) + * @ApiResponse(code="0", template="success") + */ + public function create() + { + $params = $this->getValidateData(); + $this->adminService->create($params); + return $this->success([]); + } + + /** + * @PostApi(path="/admin/v1/admin/update", summary="管理员更新", description="管理员更新") + * @Body(rules={ + * "admin_id|id":"required|int", + * "password|密码":"string|max:64", + * "role|角色":"string|max:255", + * "nickname|昵称":"string|max:32", + * }) + * @ApiResponse(code="0", template="success") + */ + public function update() + { + $params = $this->getValidateData(); + $this->adminService->update($params); + return $this->success([]); + } + + /** + * @PostApi(path="/admin/v1/admin/detail", summary="管理员详情", description="管理员详情") + * @Body(rules={ + * "admin_id|id":"required|int", + * }) + * @ApiResponse(code="0", template="success") + */ + public function detail() + { + $params = $this->getValidateData(); + $data = $this->adminService->detail($params, [ + 'admin_id', + 'account', + 'role', + 'nickname', + 'number', + 'status', + ]); + return $this->success($data); + } + + /** + * @PostApi(path="/admin/v1/admin/remove", summary="管理员删除", description="管理员删除") + * @Body(rules={ + * "admin_id。*x|id":"required|int", + * }) + * @ApiResponse(code="0", template="success") + */ + public function remove() + { + $params = $this->getValidateData(); + $this->adminService->remove($params); + return $this->success(); + } + + /** + * @PostApi(path="/admin/v1/admin/changeStatus", summary="管理员修改状态", description="管理员修改状态") + * @Body(rules={ + * "admin_id.*|id":"required|int", + * "status|状态":"required|int", + * }) + * @ApiResponse(code="0", template="success") + */ + public function changeStatus() + { + $params = $this->getValidateData(); + $this->adminService->changeStatus($params); + return $this->success(); + } +} diff --git a/app/Controller/Admin/V1/LoginController.php b/app/Controller/Admin/V1/LoginController.php index 2015d43..513cf40 100644 --- a/app/Controller/Admin/V1/LoginController.php +++ b/app/Controller/Admin/V1/LoginController.php @@ -31,7 +31,7 @@ class LoginController extends Controller protected $loginService; /** - * @PostApi(path="/admin/login", summary="登录", description="登录") + * @PostApi(path="/admin/v1/login", summary="登录", description="登录") * @Body(rules={ * "account|账号":"required|string|max:32", * "password|密码":"required|string|max:32" @@ -49,7 +49,7 @@ public function login() } /** - * @PostApi(path="/admin/login/refreshToken", summary="刷新token", description="刷新token") + * @PostApi(path="/admin/v1/login/refreshToken", summary="刷新token", description="刷新token") * @Body(rules={ * "refresh_token|刷新token" : "required|string" * }) @@ -66,7 +66,7 @@ public function refreshToken() } /** - * @PostApi(path="/admin/login/logout", summary="注销", description="退出登录") + * @PostApi(path="/admin/v1/login/logout", summary="注销", description="退出登录") * @Header(key="Token|token", rule="required|string") * * @ApiResponse(code="0", template="success") diff --git a/app/Controller/Admin/V1/System/MenuController.php b/app/Controller/Admin/V1/System/MenuController.php index e6e2297..c40ee60 100644 --- a/app/Controller/Admin/V1/System/MenuController.php +++ b/app/Controller/Admin/V1/System/MenuController.php @@ -7,6 +7,7 @@ use Hyperf\Apidog\Annotation\ApiController; use Hyperf\Apidog\Annotation\ApiResponse; use Hyperf\Apidog\Annotation\Body; +use Hyperf\Apidog\Annotation\Header; use Hyperf\Apidog\Annotation\PostApi; use Hyperf\Di\Annotation\Inject; use Lengbin\Hyperf\Common\Entity\PageEntity; @@ -16,6 +17,7 @@ * @package App\Controller\Admin\V1\System * * @ApiController(tag="菜单", description="菜单管理") + * @Header(key="Token|token", rule="required|string") */ class MenuController extends Controller { diff --git a/app/Controller/Admin/V1/System/PermissionController.php b/app/Controller/Admin/V1/System/PermissionController.php index 6d1d667..1537e1c 100644 --- a/app/Controller/Admin/V1/System/PermissionController.php +++ b/app/Controller/Admin/V1/System/PermissionController.php @@ -4,6 +4,7 @@ use App\Controller\Controller; use App\Service\System\Manager\PermissionService; +use Hyperf\Apidog\Annotation\Header; use Hyperf\Di\Annotation\Inject; use Hyperf\Apidog\Annotation\ApiController; use Hyperf\Apidog\Annotation\ApiResponse; @@ -15,6 +16,7 @@ * @package App\Controller\Admin\V1\System * * @ApiController(tag="权限", description="权限管理") + * @Header(key="Token|token", rule="required|string") */ class PermissionController extends Controller { diff --git a/app/Controller/Admin/V1/System/RoleController.php b/app/Controller/Admin/V1/System/RoleController.php index 4a2bfbf..9411219 100644 --- a/app/Controller/Admin/V1/System/RoleController.php +++ b/app/Controller/Admin/V1/System/RoleController.php @@ -4,6 +4,7 @@ use App\Controller\Controller; use App\Service\System\Manager\RoleService; +use Hyperf\Apidog\Annotation\Header; use Hyperf\Di\Annotation\Inject; use Hyperf\Apidog\Annotation\ApiController; use Hyperf\Apidog\Annotation\ApiResponse; @@ -16,6 +17,7 @@ * @package App\Controller\Admin\V1\System * * @ApiController(tag="角色", description="角色管理") + * @Header(key="Token|token", rule="required|string") */ class RoleController extends Controller { @@ -30,13 +32,14 @@ class RoleController extends Controller * @Body(rules={ * "page|页":"int|min:1", * "pageSize|页数":"int|min:1", + * "isAll|是否获取全部":"int" * }) * @ApiResponse(code="0", template="page") */ public function list() { $params = $this->getValidateData(); - $page = new PageEntity($params); + $page = empty($params['isAll']) ? new PageEntity($params) : null; $data = $this->roleService->getList($params, [], $page); return $this->success($data); } diff --git a/app/Service/Admin/AdminService.php b/app/Service/Admin/AdminService.php index a148224..9c7c3bb 100644 --- a/app/Service/Admin/AdminService.php +++ b/app/Service/Admin/AdminService.php @@ -2,12 +2,29 @@ namespace App\Service\Admin; +use App\Constant\Errors\AdminError; +use App\Constant\Status\AdminStatus; use App\Model\Admin; +use App\Service\System\Manager\RoleService; +use EasySwoole\Utility\SnowFlake; +use Hyperf\DbConnection\Db; +use Hyperf\Di\Annotation\Inject; +use Lengbin\Helper\Util\PasswordHelper; +use Lengbin\Hyperf\Common\Constant\SoftDeleted; use Lengbin\Hyperf\Common\Entity\PageEntity; +use Lengbin\Hyperf\Common\Exception\BusinessException; use Lengbin\Hyperf\Common\Framework\BaseService; +use Throwable; class AdminService extends BaseService { + + /** + * @Inject() + * @var RoleService + */ + protected $roleService; + /** * @param array $params * @param array|string[] $field @@ -18,6 +35,173 @@ class AdminService extends BaseService public function getList(array $params = [], array $field = ['*'], ?PageEntity $pageEntity = null): array { $query = Admin::query(); - return $pageEntity ? $this->page($query, $pageEntity) : $query->get()->all(); + $query->select($field); + $query->where(['enable' => SoftDeleted::ENABLE]); + + if (!empty($params['search'])) { + $query->where([ + ["account", 'like', "%{$params['search']}%"], + ["nickname", 'like', "%{$params['search']}%", 'or'], + ]); + } + + if (!empty($params['status'])) { + $query->where(['status' => $params['status']]); + } + + $results = $pageEntity ? $this->page($query, $pageEntity) : $query->get()->all(); + return $this->toArray($results, [$this, 'formatAdmin']); + } + + /** + * 格式化数据 + * + * @param array $admin + * + * @return array + */ + protected function formatAdmin(array $admin): array + { + if (!empty($admin['status'])) { + $admin['status_message'] = AdminStatus::byValue($admin['status'])->getMessage(); + } + + return $admin; + } + + public function detail(array $params, array $field = ['*']): array + { + $result = $this->findOne($params, $field); + return $this->formatAdmin($result->toArray()); + } + + /** + * @param array $conditions + * @param string[] $field + * + * @return Admin + */ + public function findOne(array $conditions, $field = ['*']): Admin + { + $model = Admin::findOneCondition($conditions, $field); + if (!$model) { + throw new BusinessException(AdminError::ERROR_ADMIN_NOT_FOUND); + } + return $model; + } + + /** + * @return int + */ + protected function getNumber(): int + { + $count = Admin::query()->count(); + return ++$count; } + + /** + * @param array $params + * + * @return array + */ + public function create(array $params): array + { + $check = Admin::existCondition([ + 'account' => $params['account'], + ]); + if ($check) { + throw new BusinessException(AdminError::ERROR_ADMIN_EXIST); + } + $this->roleService->findOne($params['role']); + try { + Db::beginTransaction(); + $model = new Admin(); + $params['admin_id'] = SnowFlake::make(1, 1); + $params['status'] = AdminStatus::NORMAL; + $params['number'] = $this->getNumber(); + $params['enable'] = SoftDeleted::ENABLE; + $params['password'] = PasswordHelper::generatePassword($params['password']); + $status = $model->insert($params); + if (!$status) { + throw new BusinessException(AdminError::ERROR_ADMIN_CREATE_FAIL); + } + $this->roleService->assign($model->role, $model->admin_id); + Db::commit(); + return $model->toArray(); + } catch (Throwable $exception) { + Db::rollBack(); + throw new BusinessException(AdminError::ERROR_ADMIN_CREATE_FAIL); + } + } + + /** + * @param array $params + * + * @return array + */ + public function update(array $params): array + { + $model = $this->findOne([ + 'admin_id' => $params['admin_id'], + ]); + + if (!empty($params['password'])) { + $params['password'] = PasswordHelper::generatePassword($params['password']); + } + + $role = ''; + if (!empty($params['role']) && $model->role !== $params['role']) { + $role = $this->roleService->findOne($params['role']); + } + + try { + Db::beginTransaction(); + $status = $model->update($params); + if (!$status) { + throw new BusinessException(AdminError::ERROR_ADMIN_UPDATE_FAIL); + } + if (!empty($role)) { + $this->roleService->revoke($model->admin_id); + $this->roleService->assign($model->role, $model->admin_id); + } + Db::commit(); + return $model->toArray(); + } catch (Throwable $exception) { + Db::rollBack(); + throw new BusinessException(AdminError::ERROR_ADMIN_UPDATE_FAIL); + } + } + + /** + * @param array $params + * + * @return int + */ + public function remove(array $params): int + { + $status = Admin::softDeleteCondition($params); + if (!$status) { + throw new BusinessException(AdminError::ERROR_ADMIN_DELETE_FAIL); + } + return $status; + } + + /** + * @param array $params + * + * @return int + */ + public function changeStatus(array $params): int + { + $admin = Admin::findAllCondition(['admin_id' => $params['admin_id']]); + if (count($admin) !== count($params['admin_id'])) { + throw new BusinessException(AdminError::ERROR_ADMIN_NOT_FOUND); + } + $status = Admin::updateCondition(['admin_id' => $params['admin_id']], ['status' => $params['status']]); + if (!$status) { + throw new BusinessException(AdminError::ERROR_ADMIN_UPDATE_FAIL); + } + return $status; + } + } diff --git a/app/Service/System/Manager/MenuService.php b/app/Service/System/Manager/MenuService.php index accc73d..6be2859 100644 --- a/app/Service/System/Manager/MenuService.php +++ b/app/Service/System/Manager/MenuService.php @@ -20,6 +20,12 @@ class MenuService extends BaseService */ protected $manager; + /** + * @Inject + * @var RoleService + */ + protected $roleService; + /** * @param array $params * @@ -70,6 +76,9 @@ protected function populateMenu(array $params): Menu if (!is_array($role)) { $role = [$role]; } + foreach ($role as $item) { + $this->roleService->findOne($item); + } return (new Menu($params['name']))->withPid($params['pid']) ->withIcon($params['icon']) ->withPath($params['path']) diff --git a/app/Service/System/Manager/RoleService.php b/app/Service/System/Manager/RoleService.php index c31529b..96793df 100644 --- a/app/Service/System/Manager/RoleService.php +++ b/app/Service/System/Manager/RoleService.php @@ -3,6 +3,7 @@ namespace App\Service\System\Manager; use App\Constant\Errors\System\RoleError; +use Exception; use Hyperf\DbConnection\Db; use Hyperf\Di\Annotation\Inject; use Lengbin\Hyperf\Common\Entity\PageEntity; @@ -37,7 +38,8 @@ class RoleService extends BaseService public function getList(array $params = [], array $field = ['*'], ?PageEntity $pageEntity = null): array { $roles = $this->manager->getRoles(); - $results = $this->pageByArray($roles, $pageEntity); + $roles = array_values($roles); + $results = $pageEntity ? $this->pageByArray($roles, $pageEntity) : $roles; return $this->toArray($results, function ($result) { $result = [ 'name' => $result->getName(), @@ -167,4 +169,28 @@ public function remove(array $params): int throw new BusinessException(RoleError::ERROR_ROLE_REMOVE_FAIL); } } + + /** + * 为用户分配角色或权限。 + * + * @param string $name + * @param string $adminId + * + * @throws Exception + */ + public function assign(string $name, string $adminId) + { + $this->manager->assign($this->findOne($name), $adminId); + } + + /** + * 取消用户的角色或权限。 + * + * @param string $adminId + * + */ + public function revoke(string $adminId) + { + $this->manager->revokeAll($adminId); + } } diff --git a/migrations/2020_11_15_160222_init.php b/migrations/2020_11_15_160222_init.php index 9de6791..736c30a 100644 --- a/migrations/2020_11_15_160222_init.php +++ b/migrations/2020_11_15_160222_init.php @@ -19,7 +19,6 @@ public function up(): void $table->string('role', 255)->comment('角色'); $table->string('nickname', 32)->comment('昵称'); $table->unsignedInteger('number')->default(1)->comment('工号'); - $table->unsignedTinyInteger('is_supper_admin')->default(0)->comment('是否超级管理'); $table->unsignedTinyInteger('status')->default(0)->comment('状态,1正常2冻结'); $table->unsignedTinyInteger('enable')->comment('状态'); $table->unsignedInteger('create_at'); From 950b7763934bd5ea48eaac5eb7b890b448790060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Fri, 8 Jan 2021 19:32:35 +0800 Subject: [PATCH 68/82] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=20-?= =?UTF-8?q?=20action=20=20demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AntDesign/Constant/Type/FormMethod.php | 33 -- .../Constant/Type/LinkConditionType.php | 18 ++ .../AntDesign/Constant/Type/LinkJudgeType.php | 38 +++ app/Component/AntDesign/Link.php | 159 ---------- app/Component/AntDesign/Link/Link.php | 288 ++++++++++++++++++ .../AntDesign/Link/LinkCondition.php | 84 +++++ app/Component/AntDesign/Link/LinkJudge.php | 84 +++++ app/Controller/TestController.php | 42 +-- app/Entity/GenerateCodeEntity.php | 31 +- app/Service/System/GenerateService.php | 1 - 10 files changed, 534 insertions(+), 244 deletions(-) delete mode 100644 app/Component/AntDesign/Constant/Type/FormMethod.php create mode 100644 app/Component/AntDesign/Constant/Type/LinkConditionType.php create mode 100644 app/Component/AntDesign/Constant/Type/LinkJudgeType.php delete mode 100644 app/Component/AntDesign/Link.php create mode 100644 app/Component/AntDesign/Link/Link.php create mode 100644 app/Component/AntDesign/Link/LinkCondition.php create mode 100644 app/Component/AntDesign/Link/LinkJudge.php diff --git a/app/Component/AntDesign/Constant/Type/FormMethod.php b/app/Component/AntDesign/Constant/Type/FormMethod.php deleted file mode 100644 index 6420aad..0000000 --- a/app/Component/AntDesign/Constant/Type/FormMethod.php +++ /dev/null @@ -1,33 +0,0 @@ -'; + + /** + * @Message("大于等于") + */ + public const GREATER_THAN_OR_EQUAL = '>='; + + /** + * @Message("小于") + */ + public const LESS_THAN = '<'; + + /** + * @Message("小于等于") + */ + public const LESS_THAN_OR_EQUAL = '<='; + + /** + * @Message("等于") + */ + public const EQUAL = '='; + + /** + * @Message("不等于") + */ + public const NOT_EQUAL = '!='; +} diff --git a/app/Component/AntDesign/Link.php b/app/Component/AntDesign/Link.php deleted file mode 100644 index 0793638..0000000 --- a/app/Component/AntDesign/Link.php +++ /dev/null @@ -1,159 +0,0 @@ -name; - } - - /** - * @param string $name - * - * @return Link - */ - public function setName(string $name): Link - { - $this->name = $name; - return $this; - } - - /** - * @return string - */ - public function getPath(): string - { - return $this->path; - } - - /** - * @param string $path - * - * @return Link - */ - public function setPath(string $path): Link - { - $this->path = $path; - return $this; - } - - /** - * @return LinkTarget - */ - public function getTarget(): LinkTarget - { - return $this->target; - } - - /** - * @param LinkTarget $target - * - * @return Link - */ - public function setTarget(LinkTarget $target): Link - { - $this->target = $target; - return $this; - } - - /** - * @return LinkType - */ - public function getType(): LinkType - { - return $this->type; - } - - /** - * @param LinkType $type - * - * @return Link - */ - public function setType(LinkType $type): Link - { - $this->type = $type; - return $this; - } - - /** - * @return ValueEnumTypeStatus - */ - public function getStatus(): ValueEnumTypeStatus - { - return $this->status; - } - - /** - * @param ValueEnumTypeStatus $status - * - * @return Link - */ - public function setStatus(ValueEnumTypeStatus $status): Link - { - $this->status = $status; - return $this; - } - - /** - * @return FormMethod - */ - public function getMethod(): FormMethod - { - return $this->method; - } - - /** - * @param FormMethod $method - * - * @return Link - */ - public function setMethod(FormMethod $method): Link - { - $this->method = $method; - return $this; - } -} diff --git a/app/Component/AntDesign/Link/Link.php b/app/Component/AntDesign/Link/Link.php new file mode 100644 index 0000000..f2875aa --- /dev/null +++ b/app/Component/AntDesign/Link/Link.php @@ -0,0 +1,288 @@ +name; + } + + /** + * @param string $name + * + * @return Link + */ + public function setName(string $name): Link + { + $this->name = $name; + if (empty($this->label)) { + $this->setLabel($name); + } + return $this; + } + + /** + * @return string + */ + public function getPath(): string + { + return $this->path; + } + + /** + * @param string $path + * + * @return Link + */ + public function setPath(string $path): Link + { + $this->path = $path; + return $this; + } + + /** + * @return LinkTarget + */ + public function getTarget(): LinkTarget + { + return $this->target; + } + + /** + * @param LinkTarget $target + * + * @return Link + */ + public function setTarget(LinkTarget $target): Link + { + $this->target = $target; + return $this; + } + + /** + * @return LinkType + */ + public function getType(): LinkType + { + return $this->type; + } + + /** + * @param LinkType $type + * + * @return Link + */ + public function setType(LinkType $type): Link + { + $this->type = $type; + return $this; + } + + /** + * @return ValueEnumTypeStatus + */ + public function getStatus(): ValueEnumTypeStatus + { + return $this->status; + } + + /** + * @param ValueEnumTypeStatus $status + * + * @return Link + */ + public function setStatus(ValueEnumTypeStatus $status): Link + { + $this->status = $status; + return $this; + } + + /** + * @return string + */ + public function getIcon(): string + { + return $this->icon; + } + + /** + * @param string $icon + * + * @return Link + */ + public function setIcon(string $icon): Link + { + $this->icon = $icon; + return $this; + } + + /** + * @return string + */ + public function getLabel(): string + { + return $this->label; + } + + /** + * @param string $label + * + * @return Link + */ + public function setLabel(string $label): Link + { + $this->label = $label; + return $this; + } + + /** + * @return array + */ + public function getData(): array + { + return $this->data; + } + + /** + * @param array $data + * + * @return Link + */ + public function setData(array $data): Link + { + $this->data = $data; + return $this; + } + + /** + * @return string + */ + public function getTip(): string + { + return $this->tip; + } + + /** + * @param string $tip + * + * @return Link + */ + public function setTip(string $tip): Link + { + $this->tip = $tip; + return $this; + } + + /** + * @return Form + */ + public function getForm(): Form + { + return $this->form; + } + + /** + * @param Form $form + * + * @return Link + */ + public function setForm(Form $form): Link + { + $this->form = $form; + return $this; + } + + /** + * @return LinkCondition[] + */ + public function getCondition(): array + { + return $this->condition; + } + + /** + * @param LinkCondition[] $condition + * + * @return Link + */ + public function setCondition(array $condition): Link + { + $this->condition = $condition; + return $this; + } +} diff --git a/app/Component/AntDesign/Link/LinkCondition.php b/app/Component/AntDesign/Link/LinkCondition.php new file mode 100644 index 0000000..6f5535e --- /dev/null +++ b/app/Component/AntDesign/Link/LinkCondition.php @@ -0,0 +1,84 @@ +label; + } + + /** + * @param string $label + * + * @return LinkCondition + */ + public function setLabel(string $label): LinkCondition + { + $this->label = $label; + return $this; + } + + /** + * @return LinkConditionType + */ + public function getType(): LinkConditionType + { + return $this->type; + } + + /** + * @param LinkConditionType $type + * + * @return LinkCondition + */ + public function setType(LinkConditionType $type): LinkCondition + { + $this->type = $type; + return $this; + } + + /** + * @return LinkJudge[] + */ + public function getJudge(): array + { + return $this->judge; + } + + /** + * @param LinkJudge[] $judge + * + * @return LinkCondition + */ + public function setJudge(array $judge): LinkCondition + { + $this->judge = $judge; + return $this; + } +} diff --git a/app/Component/AntDesign/Link/LinkJudge.php b/app/Component/AntDesign/Link/LinkJudge.php new file mode 100644 index 0000000..07e1a05 --- /dev/null +++ b/app/Component/AntDesign/Link/LinkJudge.php @@ -0,0 +1,84 @@ +attribute; + } + + /** + * @param string $attribute + * + * @return LinkJudge + */ + public function setAttribute(string $attribute): LinkJudge + { + $this->attribute = $attribute; + return $this; + } + + /** + * @return LinkJudgeType + */ + public function getType(): LinkJudgeType + { + return $this->type; + } + + /** + * @param LinkJudgeType $type + * + * @return LinkJudge + */ + public function setType(LinkJudgeType $type): LinkJudge + { + $this->type = $type; + return $this; + } + + /** + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * @param mixed $value + * + * @return LinkJudge + */ + public function setValue($value) + { + $this->value = $value; + return $this; + } +} diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index b2c69d7..d944609 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -5,12 +5,11 @@ use App\Component\AntDesign\Constant\Type\FormDateType; use App\Component\AntDesign\Constant\Type\ValueType; use App\Component\AntDesign\Table; -use App\Component\Generate\ClassFile\ClassConfig; -use App\Component\Generate\Generate; use App\Constant\Status\AdminStatus; use App\Entity\GenerateCodeEntity; use App\Service\Admin\AdminService; use App\Service\System\GenerateService; +use Hyperf\Contract\ConfigInterface; use Hyperf\Di\Annotation\Inject; use Hyperf\HttpServer\Annotation\GetMapping; use Hyperf\HttpServer\Annotation\PostMapping; @@ -264,53 +263,26 @@ public function generate() // $generate->setConfig($config); // return $this->success(['a' => $generate->output('php'), 'b' => $config->__toObjectString(), 'c' => $config->__getClassname()]); // - + $config = $this->container->get(ConfigInterface::class)->get('genCode'); $params = [ 'controller' => 'app/Controller/AdController', 'model' => 'app/Model/Ad', 'pool' => 'default', 'service' => 'app/Service/AdService', - 'actions' => [ - [ - 'name' => '批量删除', - 'type' => 'action', - 'target' => 'button', - 'path' => 'remove', - 'method' => 'post', - ], - [ - 'name' => '创建', - 'type' => 'action', - 'target' => 'button', - 'path' => 'add', - 'method' => 'post', - ], - [ - 'name' => '编辑', - 'type' => 'operation', - 'target' => 'link', - 'path' => 'detail', - 'method' => 'post', - ], - [ - 'name' => '删除', - 'type' => 'operation', - 'target' => 'link', - 'path' => 'remove', - 'method' => 'post', - ], - ], - 'list' => [ + 'actions' => $config['actions'], + 'table' => [ ], 'search' => [ ], - 'form' => [ + 'tag' => [ ], ]; $generateCodeEntity = new GenerateCodeEntity($params); + var_dump($generateCodeEntity); + die; $this->generateService->file($generateCodeEntity); return $this->success($generateCodeEntity->toArray()); } diff --git a/app/Entity/GenerateCodeEntity.php b/app/Entity/GenerateCodeEntity.php index 585e701..90cc2a2 100644 --- a/app/Entity/GenerateCodeEntity.php +++ b/app/Entity/GenerateCodeEntity.php @@ -2,8 +2,7 @@ namespace App\Entity; -use App\Component\AntDesign\Form\Form; -use App\Component\AntDesign\Link; +use App\Component\AntDesign\Link\Link; use App\Component\AntDesign\Table; use Lengbin\Common\Component\BaseObject; @@ -54,9 +53,9 @@ class GenerateCodeEntity extends BaseObject /** * 表单 * - * @var Form + * @var array */ - private $form; + private $tag; /** * @return string @@ -173,40 +172,40 @@ public function setSearch(array $search): GenerateCodeEntity } /** - * @return Form + * @return string */ - public function getForm(): Form + public function getPool(): string { - return $this->form; + return $this->pool; } /** - * @param Form $form + * @param string $pool * * @return GenerateCodeEntity */ - public function setForm(Form $form): GenerateCodeEntity + public function setPool(string $pool): GenerateCodeEntity { - $this->form = $form; + $this->pool = $pool; return $this; } /** - * @return string + * @return array */ - public function getPool(): string + public function getTag(): array { - return $this->pool; + return $this->tag; } /** - * @param string $pool + * @param array $tag * * @return GenerateCodeEntity */ - public function setPool(string $pool): GenerateCodeEntity + public function setTag(array $tag): GenerateCodeEntity { - $this->pool = $pool; + $this->tag = $tag; return $this; } } diff --git a/app/Service/System/GenerateService.php b/app/Service/System/GenerateService.php index b96e56f..3c97e51 100644 --- a/app/Service/System/GenerateService.php +++ b/app/Service/System/GenerateService.php @@ -2,7 +2,6 @@ namespace App\Service\System; -use App\Component\AntDesign\Link; use App\Entity\GenerateCodeEntity; use Lengbin\Helper\YiiSoft\StringHelper; use Lengbin\Hyperf\Common\Component\Generate\Model\GenerateModel; From 7806aff1fd13263676c97fdc7ea814734e81f91c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Thu, 14 Jan 2021 18:42:10 +0800 Subject: [PATCH 69/82] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=20-?= =?UTF-8?q?=20=E7=BC=BA=E5=A4=B1=20=E5=89=8D=E7=AB=AF=20=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=EF=BC=8C=20=E5=8F=AF=E4=BB=A5=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Constant/Type/SearchJudgeType.php | 11 + app/Component/AntDesign/Form/BaseForm.php | 6 - .../AntDesign/Search/SearchCondition.php | 60 +++++ .../AntDesign/Search/SearchJudge.php | 59 +++++ .../Generate/Build/Action/BaseActionBuild.php | 82 +++++++ .../Controller/BaseActionControllerBuild.php | 79 +++++++ .../DefaultActionControllerBuild.php | 22 ++ .../DetailActionControllerBuild.php | 24 ++ .../Controller/ListActionControllerBuild.php | 34 +++ .../ValidateParse/ApidogValidateParse.php | 19 ++ .../ValidateParse/BaseValidateParse.php | 85 +++++++ .../EasyswoolApidogValidateParse.php | 11 + .../Action/Service/BaseActionServiceBuild.php | 124 +++++++++++ .../Service/ChangeActionServiceBuild.php | 29 +++ .../Service/CreateActionServiceBuild.php | 24 ++ .../Service/DefaultActionServiceBuild.php | 21 ++ .../Service/DetailActionServiceBuild.php | 28 +++ .../Service/FindOneActionServiceBuild.php | 30 +++ .../Service/FormatModelActionServiceBuild.php | 33 +++ .../Action/Service/ListActionServiceBuild.php | 45 ++++ .../Service/RemoveActionServiceBuild.php | 23 ++ .../Service/UpdateActionServiceBuild.php | 25 +++ app/Component/Generate/Build/BaseBuild.php | 113 ++++++++++ app/Component/Generate/Build/BuildClass.php | 207 ++++++++++++++++++ .../Build/Config/BuildActionClassConfig.php | 82 +++++++ .../Build/Config/BuildActionConfig.php | 58 +++++ .../Generate/Build/Config/BuildConfig.php | 157 +++++++++++++ .../Build/Config/BuildControllerConfig.php | 157 +++++++++++++ .../Build/Config/BuildDefaultBaseConfig.php | 33 +++ .../Build/Config/BuildDefaultConfig.php | 109 +++++++++ .../Config/BuildDefaultErrorCodeConfig.php | 30 +++ .../Build/Config/BuildErrorCodeConfig.php | 58 +++++ .../Build/Config/BuildExceptionConfig.php | 58 +++++ .../Build/Config/BuildServiceConfig.php | 58 +++++ .../Generate/Build/ControllerBuild.php | 155 +++++++++++++ .../Generate/Build/ErrorCodeBuild.php | 181 +++++++++++++++ .../Generate/Build/Model/HyperfModelBuild.php | 71 ++++++ app/Component/Generate/Build/ServiceBuild.php | 156 +++++++++++++ .../Generate/ClassFile/ClassBase.php | 3 + .../Generate/ClassFile/ClassConfig.php | 7 +- .../Generate/ClassFile/ClassParams.php | 26 +++ app/Constant/Error.php | 45 ++++ app/Constant/Errors/System/GenerateError.php | 23 ++ app/Controller/TestController.php | 21 +- app/Entity/GenerateCodeEntity.php | 35 ++- app/Model/Admin.php | 39 ++-- app/Service/Admin/AdminService.php | 4 + app/Service/System/GenerateService.php | 97 ++------ 48 files changed, 2734 insertions(+), 123 deletions(-) create mode 100644 app/Component/AntDesign/Constant/Type/SearchJudgeType.php create mode 100644 app/Component/AntDesign/Search/SearchCondition.php create mode 100644 app/Component/AntDesign/Search/SearchJudge.php create mode 100644 app/Component/Generate/Build/Action/BaseActionBuild.php create mode 100644 app/Component/Generate/Build/Action/Controller/BaseActionControllerBuild.php create mode 100644 app/Component/Generate/Build/Action/Controller/DefaultActionControllerBuild.php create mode 100644 app/Component/Generate/Build/Action/Controller/DetailActionControllerBuild.php create mode 100644 app/Component/Generate/Build/Action/Controller/ListActionControllerBuild.php create mode 100644 app/Component/Generate/Build/Action/Controller/ValidateParse/ApidogValidateParse.php create mode 100644 app/Component/Generate/Build/Action/Controller/ValidateParse/BaseValidateParse.php create mode 100644 app/Component/Generate/Build/Action/Controller/ValidateParse/EasyswoolApidogValidateParse.php create mode 100644 app/Component/Generate/Build/Action/Service/BaseActionServiceBuild.php create mode 100644 app/Component/Generate/Build/Action/Service/ChangeActionServiceBuild.php create mode 100644 app/Component/Generate/Build/Action/Service/CreateActionServiceBuild.php create mode 100644 app/Component/Generate/Build/Action/Service/DefaultActionServiceBuild.php create mode 100644 app/Component/Generate/Build/Action/Service/DetailActionServiceBuild.php create mode 100644 app/Component/Generate/Build/Action/Service/FindOneActionServiceBuild.php create mode 100644 app/Component/Generate/Build/Action/Service/FormatModelActionServiceBuild.php create mode 100644 app/Component/Generate/Build/Action/Service/ListActionServiceBuild.php create mode 100644 app/Component/Generate/Build/Action/Service/RemoveActionServiceBuild.php create mode 100644 app/Component/Generate/Build/Action/Service/UpdateActionServiceBuild.php create mode 100644 app/Component/Generate/Build/BaseBuild.php create mode 100644 app/Component/Generate/Build/BuildClass.php create mode 100644 app/Component/Generate/Build/Config/BuildActionClassConfig.php create mode 100644 app/Component/Generate/Build/Config/BuildActionConfig.php create mode 100644 app/Component/Generate/Build/Config/BuildConfig.php create mode 100644 app/Component/Generate/Build/Config/BuildControllerConfig.php create mode 100644 app/Component/Generate/Build/Config/BuildDefaultBaseConfig.php create mode 100644 app/Component/Generate/Build/Config/BuildDefaultConfig.php create mode 100644 app/Component/Generate/Build/Config/BuildDefaultErrorCodeConfig.php create mode 100644 app/Component/Generate/Build/Config/BuildErrorCodeConfig.php create mode 100644 app/Component/Generate/Build/Config/BuildExceptionConfig.php create mode 100644 app/Component/Generate/Build/Config/BuildServiceConfig.php create mode 100644 app/Component/Generate/Build/ControllerBuild.php create mode 100644 app/Component/Generate/Build/ErrorCodeBuild.php create mode 100644 app/Component/Generate/Build/Model/HyperfModelBuild.php create mode 100644 app/Component/Generate/Build/ServiceBuild.php create mode 100644 app/Constant/Errors/System/GenerateError.php diff --git a/app/Component/AntDesign/Constant/Type/SearchJudgeType.php b/app/Component/AntDesign/Constant/Type/SearchJudgeType.php new file mode 100644 index 0000000..983f1ff --- /dev/null +++ b/app/Component/AntDesign/Constant/Type/SearchJudgeType.php @@ -0,0 +1,11 @@ +getName(); - return parent::toArray($object); - } - /** * @return string */ diff --git a/app/Component/AntDesign/Search/SearchCondition.php b/app/Component/AntDesign/Search/SearchCondition.php new file mode 100644 index 0000000..3bc636d --- /dev/null +++ b/app/Component/AntDesign/Search/SearchCondition.php @@ -0,0 +1,60 @@ +type; + } + + /** + * @param LinkConditionType $type + * + * @return SearchCondition + */ + public function setType(LinkConditionType $type): SearchCondition + { + $this->type = $type; + return $this; + } + + /** + * @return SearchJudge[] + */ + public function getJudge(): array + { + return $this->judge; + } + + /** + * @param SearchJudge[] $judge + * + * @return SearchCondition + */ + public function setJudge(array $judge): SearchCondition + { + $this->judge = $judge; + return $this; + } +} diff --git a/app/Component/AntDesign/Search/SearchJudge.php b/app/Component/AntDesign/Search/SearchJudge.php new file mode 100644 index 0000000..5cb8606 --- /dev/null +++ b/app/Component/AntDesign/Search/SearchJudge.php @@ -0,0 +1,59 @@ +attribute; + } + + /** + * @param string $attribute + * + * @return SearchJudge + */ + public function setAttribute(string $attribute): SearchJudge + { + $this->attribute = $attribute; + return $this; + } + + /** + * @return SearchJudgeType + */ + public function getType(): SearchJudgeType + { + return $this->type; + } + + /** + * @param SearchJudgeType $type + * + * @return SearchJudge + */ + public function setType(SearchJudgeType $type): SearchJudge + { + $this->type = $type; + return $this; + } +} diff --git a/app/Component/Generate/Build/Action/BaseActionBuild.php b/app/Component/Generate/Build/Action/BaseActionBuild.php new file mode 100644 index 0000000..ff7f8ef --- /dev/null +++ b/app/Component/Generate/Build/Action/BaseActionBuild.php @@ -0,0 +1,82 @@ +getSpaces(2) . implode("\n" . $this->getSpaces(2), $this->getContent()); + return [ + "name" => $this->getName(), + 'params' => $this->getParams(), + 'return' => $this->getReturn(), + 'content' => $content, + 'comments' => $this->getComment(), + ]; + } + + /** + * @param int $level + * + * @return string + */ + public function getSpaces(int $level = 1): string + { + return str_repeat(' ', $level * 4); + } + + /** + * @var string + */ + protected $name; + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @param string $name + * + * @return BaseActionBuild + */ + public function setName(string $name): BaseActionBuild + { + $this->name = $name; + return $this; + } +} diff --git a/app/Component/Generate/Build/Action/Controller/BaseActionControllerBuild.php b/app/Component/Generate/Build/Action/Controller/BaseActionControllerBuild.php new file mode 100644 index 0000000..d667e42 --- /dev/null +++ b/app/Component/Generate/Build/Action/Controller/BaseActionControllerBuild.php @@ -0,0 +1,79 @@ +getValidateParse()->parse(); + } + + /** + * @var string + */ + private $serviceName; + + /** + * @var BaseValidateParse + */ + private $validateParse; + + + /** + * @return string + */ + public function getServiceName(): string + { + return $this->serviceName; + } + + /** + * @param string $serviceName + * + * @return BaseActionControllerBuild + */ + public function setServiceName(string $serviceName): BaseActionControllerBuild + { + $this->serviceName = $serviceName; + return $this; + } + + /** + * @return BaseValidateParse + */ + public function getValidateParse(): BaseValidateParse + { + return $this->validateParse; + } + + /** + * @param BaseValidateParse $validateParse + * + * @return BaseActionControllerBuild + */ + public function setValidateParse(BaseValidateParse $validateParse): BaseActionControllerBuild + { + $this->validateParse = $validateParse; + return $this; + } +} diff --git a/app/Component/Generate/Build/Action/Controller/DefaultActionControllerBuild.php b/app/Component/Generate/Build/Action/Controller/DefaultActionControllerBuild.php new file mode 100644 index 0000000..1917f6c --- /dev/null +++ b/app/Component/Generate/Build/Action/Controller/DefaultActionControllerBuild.php @@ -0,0 +1,22 @@ +'.$this->getServiceName().'->'.$this->getName().'($params);', + 'return $this->success([]);' + ]; + } +} diff --git a/app/Component/Generate/Build/Action/Controller/DetailActionControllerBuild.php b/app/Component/Generate/Build/Action/Controller/DetailActionControllerBuild.php new file mode 100644 index 0000000..9a65231 --- /dev/null +++ b/app/Component/Generate/Build/Action/Controller/DetailActionControllerBuild.php @@ -0,0 +1,24 @@ +getValidateParse()->getParams(); + return [ + '$params = Context::get("validator.data", []);', + '$data = $this->'.$this->getServiceName().'->'.$this->getName().'($params);', + 'return $this->success($data);' + ]; + } +} diff --git a/app/Component/Generate/Build/Action/Controller/ListActionControllerBuild.php b/app/Component/Generate/Build/Action/Controller/ListActionControllerBuild.php new file mode 100644 index 0000000..be07de9 --- /dev/null +++ b/app/Component/Generate/Build/Action/Controller/ListActionControllerBuild.php @@ -0,0 +1,34 @@ +getValidateParse()->getParams(); + return [ + '$params = Context::get("validator.data", []);', + '$page = new PageEntity($params);', + '$data = $this->' . $this->getServiceName() . '->' . $this->getName() . '($params, ["*"], $page);', + 'return $this->success($data);', + ]; + } +} diff --git a/app/Component/Generate/Build/Action/Controller/ValidateParse/ApidogValidateParse.php b/app/Component/Generate/Build/Action/Controller/ValidateParse/ApidogValidateParse.php new file mode 100644 index 0000000..f67c43d --- /dev/null +++ b/app/Component/Generate/Build/Action/Controller/ValidateParse/ApidogValidateParse.php @@ -0,0 +1,19 @@ +getPath() . '", summary="' . $this->getDescription() . '")', + '@Body(rules={', + $rule, + '})', + ]; + } +} diff --git a/app/Component/Generate/Build/Action/Controller/ValidateParse/BaseValidateParse.php b/app/Component/Generate/Build/Action/Controller/ValidateParse/BaseValidateParse.php new file mode 100644 index 0000000..ff5705d --- /dev/null +++ b/app/Component/Generate/Build/Action/Controller/ValidateParse/BaseValidateParse.php @@ -0,0 +1,85 @@ +params; + } + + /** + * @param array $params + * + * @return BaseValidateParse + */ + public function setParams(array $params): BaseValidateParse + { + $this->params = $params; + return $this; + } + + /** + * @return string + */ + public function getDescription(): string + { + return $this->description; + } + + /** + * @param string $description + * + * @return BaseValidateParse + */ + public function setDescription(string $description): BaseValidateParse + { + $this->description = $description; + return $this; + } + + /** + * @return string + */ + public function getPath(): string + { + return $this->path; + } + + /** + * @param string $path + * + * @return BaseValidateParse + */ + public function setPath(string $path): BaseValidateParse + { + $this->path = $path; + return $this; + } + + /** + * @return array + */ + abstract public function parse(): array; +} diff --git a/app/Component/Generate/Build/Action/Controller/ValidateParse/EasyswoolApidogValidateParse.php b/app/Component/Generate/Build/Action/Controller/ValidateParse/EasyswoolApidogValidateParse.php new file mode 100644 index 0000000..586a8c3 --- /dev/null +++ b/app/Component/Generate/Build/Action/Controller/ValidateParse/EasyswoolApidogValidateParse.php @@ -0,0 +1,11 @@ + 'params', 'type' => 'array', 'comment' => '参数'], + ]; + } + + public function getComment(): array + { + return [ + $this->getDescription() + ]; + } + + /** + * @var array + */ + protected $errors; + + /** + * @var array + */ + protected $model; + + /** + * @var string + */ + protected $exceptionName; + + /** + * @var string + */ + protected $description; + + /** + * @return array + */ + public function getErrors(): array + { + return $this->errors; + } + + /** + * @param array $errors + * + * @return BaseActionServiceBuild + */ + public function setErrors(array $errors): BaseActionServiceBuild + { + $this->errors = $errors; + return $this; + } + + /** + * @return array + */ + public function getModel(): array + { + return $this->model; + } + + /** + * @param array $model + * + * @return BaseActionServiceBuild + */ + public function setModel(array $model): BaseActionServiceBuild + { + $this->model = $model; + return $this; + } + + /** + * @return string + */ + public function getExceptionName(): string + { + return $this->exceptionName; + } + + /** + * @param string $exceptionName + * + * @return BaseActionServiceBuild + */ + public function setExceptionName(string $exceptionName): BaseActionServiceBuild + { + $this->exceptionName = $exceptionName; + return $this; + } + + /** + * @return string + */ + public function getDescription(): string + { + return $this->description; + } + + /** + * @param string $description + * + * @return BaseActionBuild + */ + public function setDescription(string $description): BaseActionBuild + { + $this->description = $description; + return $this; + } +} diff --git a/app/Component/Generate/Build/Action/Service/ChangeActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/ChangeActionServiceBuild.php new file mode 100644 index 0000000..91c46a0 --- /dev/null +++ b/app/Component/Generate/Build/Action/Service/ChangeActionServiceBuild.php @@ -0,0 +1,29 @@ +getModel()['primaryKey']; + return [ + "\$where = ['{$primaryKey}' => \$params['{$primaryKey}']];", + "unset(\$params['{$primaryKey}']);", + "\$models = {$this->getModel()['classname']}::findAllCondition(\$where);", + "if (count(\$models) !== count(\$params['{$primaryKey}'])) {", + $this->getSpaces() . "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant']['notFound']});", + '}', + "\$status = {$this->getModel()['classname']}::updateCondition(\$where, \$params);", + 'if (!$status) {', + $this->getSpaces() . "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant']['update']});", + '}', + 'return $status;', + ]; + } + + public function getReturn(): string + { + return 'int'; + } +} diff --git a/app/Component/Generate/Build/Action/Service/CreateActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/CreateActionServiceBuild.php new file mode 100644 index 0000000..1b7ef7c --- /dev/null +++ b/app/Component/Generate/Build/Action/Service/CreateActionServiceBuild.php @@ -0,0 +1,24 @@ +getModel()['classname']}();", + '$status = $model->insert($params);', + 'if (!$status) {', + $this->getSpaces() . "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant']['create']});", + '}', + 'return $model->toArray();', + ]; + } + + public function getReturn(): string + { + return 'array'; + } +} diff --git a/app/Component/Generate/Build/Action/Service/DefaultActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/DefaultActionServiceBuild.php new file mode 100644 index 0000000..47216fd --- /dev/null +++ b/app/Component/Generate/Build/Action/Service/DefaultActionServiceBuild.php @@ -0,0 +1,21 @@ +getErrors()['constant'][$this->getName()])) { + return []; + } + return [ + $this->getSpaces(2) . "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant'][$this->getName()]});", + ]; + } + + public function getReturn(): string + { + return 'array'; + } +} diff --git a/app/Component/Generate/Build/Action/Service/DetailActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/DetailActionServiceBuild.php new file mode 100644 index 0000000..56017f8 --- /dev/null +++ b/app/Component/Generate/Build/Action/Service/DetailActionServiceBuild.php @@ -0,0 +1,28 @@ +findOne($params, $field);', + 'return $this->formatModel($result->toArray());', + ]; + } + + public function getParams(): array + { + return [ + ['name' => 'params', 'type' => 'array', 'comment' => '条件'], + ['name' => 'field', 'type' => 'array', 'default' => ['*'], 'comment' => '字段'], + ]; + } + + public function getReturn(): string + { + return 'array'; + } +} diff --git a/app/Component/Generate/Build/Action/Service/FindOneActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/FindOneActionServiceBuild.php new file mode 100644 index 0000000..7c26903 --- /dev/null +++ b/app/Component/Generate/Build/Action/Service/FindOneActionServiceBuild.php @@ -0,0 +1,30 @@ +getModel()['classname']}::findOneCondition(\$params, \$field);", + 'if (!$model) {', + $this->getSpaces() . "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant']['notFound']});", + '}', + 'return $model;', + ]; + } + + public function getParams(): array + { + return [ + ['name' => 'params', 'type' => 'array', 'comment' => '条件'], + ['name' => 'field', 'type' => 'array', 'default' => ['*'], 'comment' => '字段'], + ]; + } + + public function getReturn(): string + { + return $this->getModel()['classname']; + } +} diff --git a/app/Component/Generate/Build/Action/Service/FormatModelActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/FormatModelActionServiceBuild.php new file mode 100644 index 0000000..cb8c68c --- /dev/null +++ b/app/Component/Generate/Build/Action/Service/FormatModelActionServiceBuild.php @@ -0,0 +1,33 @@ +getName()} method.", + 'return $result;', + ]; + } + + public function getMethod(): array + { + $method = parent::getMethod(); + $method['protected'] = true; + return $method; + } + + public function getParams(): array + { + return [ + ['name' => 'result', 'type' => 'array', 'comment' => '数据'], + ]; + } + + public function getReturn(): string + { + return 'array'; + } +} diff --git a/app/Component/Generate/Build/Action/Service/ListActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/ListActionServiceBuild.php new file mode 100644 index 0000000..fb2ea91 --- /dev/null +++ b/app/Component/Generate/Build/Action/Service/ListActionServiceBuild.php @@ -0,0 +1,45 @@ +getModel()['classname']}::query();", + '$query->select($field);', + "\$query->where(['enable' => SoftDeleted::ENABLE]);", + ]; + // 判断 条件 search + $data[] = '$results = $pageEntity ? $this->page($query, $pageEntity) : $query->get()->all();'; + $data[] = 'return $this->toArray($results, [$this, "formatModel"]);'; + return $data; + } + + public function getParams(): array + { + return [ + ['name' => 'params', 'type' => 'array', 'default' => [], 'comment' => '条件'], + ['name' => 'field', 'type' => 'array', 'default' => ['*'], 'comment' => '字段' ], + ['name' => 'pageEntity', 'type' => '?PageEntity', 'default' => null, 'comment' => '分页'], + ]; + } + + public function getReturn(): string + { + return 'array'; + } +} diff --git a/app/Component/Generate/Build/Action/Service/RemoveActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/RemoveActionServiceBuild.php new file mode 100644 index 0000000..56e8a03 --- /dev/null +++ b/app/Component/Generate/Build/Action/Service/RemoveActionServiceBuild.php @@ -0,0 +1,23 @@ +getModel()['classname']}::softDeleteCondition(\$params);", + 'if (!$status) {', + $this->getSpaces() . "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant']['remove']});", + '}', + 'return $status;', + ]; + } + + public function getReturn(): string + { + return 'int'; + } +} diff --git a/app/Component/Generate/Build/Action/Service/UpdateActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/UpdateActionServiceBuild.php new file mode 100644 index 0000000..0831201 --- /dev/null +++ b/app/Component/Generate/Build/Action/Service/UpdateActionServiceBuild.php @@ -0,0 +1,25 @@ +getModel()['primaryKey']; + return [ + "\$model = \$this->findOne(['{$primaryKey}' => \$params['{$primaryKey}']]);", + '$status = $model->update($params);', + 'if (!$status) {', + $this->getSpaces() . "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant']['update']});", + '}', + 'return $model->toArray();', + ]; + } + + public function getReturn(): string + { + return 'array'; + } +} diff --git a/app/Component/Generate/Build/BaseBuild.php b/app/Component/Generate/Build/BaseBuild.php new file mode 100644 index 0000000..1f08827 --- /dev/null +++ b/app/Component/Generate/Build/BaseBuild.php @@ -0,0 +1,113 @@ +config; + } + + /** + * @param BuildConfig $config + * + * @return BaseBuild + */ + public function setConfig(BuildConfig $config): BaseBuild + { + $this->config = $config; + return $this; + } + + /** + * @return GenerateCodeEntity + */ + public function getGenerateCodeEntity(): GenerateCodeEntity + { + return $this->generateCodeEntity; + } + + /** + * @param GenerateCodeEntity $generateCodeEntity + * + * @return BaseBuild + */ + public function setGenerateCodeEntity(GenerateCodeEntity $generateCodeEntity): BaseBuild + { + $this->generateCodeEntity = $generateCodeEntity; + return $this; + } + + /** + * @param array $params + * @param string $path + * + * @return bool + */ + protected function output(array $params, string $path): bool + { + $generate = new Generate(); + $generate->setPath($this->getRoot() . '/' . $path); + $generate->setConfig(new ClassConfig($params)); + return $generate->output('php'); + } + + /** + * @param string $name + * + * @return string + */ + protected function getNamespace(string $name): string + { + return implode('\\', array_map(function ($str) { + return StringHelper::ucfirst($str); + }, StringHelper::explode($name, '/'))); + } + + /** + * @return string + */ + public function getRoot(): string + { + return $this->root; + } + + /** + * @param string $root + * + * @return BaseBuild + */ + public function setRoot(string $root): BaseBuild + { + $this->root = $root; + return $this; + } + + abstract public function build(): array; +} diff --git a/app/Component/Generate/Build/BuildClass.php b/app/Component/Generate/Build/BuildClass.php new file mode 100644 index 0000000..403ad11 --- /dev/null +++ b/app/Component/Generate/Build/BuildClass.php @@ -0,0 +1,207 @@ +setRoot($this->getRoot())->setConfig($this->getConfig())->setGenerateCodeEntity($this->getGenerateCodeEntity()); + } + + /** + * @return BaseBuild + */ + public function getModel(): BaseBuild + { + return $this->model; + } + + /** + * @param BaseBuild $model + * + * @return BuildClass + */ + public function setModel(BaseBuild $model): BuildClass + { + $this->model = $model; + return $this; + } + + /** + * @return ServiceBuild + */ + public function getService(): ServiceBuild + { + return $this->init($this->service); + } + + /** + * @param ServiceBuild $service + * + * @return BuildClass + */ + public function setService(ServiceBuild $service): BuildClass + { + $this->service = $service; + return $this; + } + + /** + * @return ErrorCodeBuild + */ + public function getErrorCode(): ErrorCodeBuild + { + return $this->init($this->errorCode); + } + + /** + * @param ErrorCodeBuild $errorCode + * + * @return BuildClass + */ + public function setErrorCode(ErrorCodeBuild $errorCode): BuildClass + { + $this->errorCode = $errorCode; + return $this; + } + + /** + * @return ControllerBuild + */ + public function getController(): ControllerBuild + { + return $this->init($this->controller); + } + + /** + * @param ControllerBuild $controller + * + * @return BuildClass + */ + public function setController(ControllerBuild $controller): BuildClass + { + $this->controller = $controller; + return $this; + } + + /** + * @return BuildConfig + */ + public function getConfig(): BuildConfig + { + return $this->config; + } + + /** + * @param BuildConfig $config + * + * @return BuildClass + */ + public function setConfig(BuildConfig $config): BuildClass + { + $this->config = $config; + return $this; + } + + /** + * @return GenerateCodeEntity + */ + public function getGenerateCodeEntity(): GenerateCodeEntity + { + return $this->generateCodeEntity; + } + + /** + * @param GenerateCodeEntity $generateCodeEntity + * + * @return BuildClass + */ + public function setGenerateCodeEntity(GenerateCodeEntity $generateCodeEntity): BuildClass + { + $this->generateCodeEntity = $generateCodeEntity; + return $this; + } + + /** + * @return string + */ + public function getRoot(): string + { + return $this->root; + } + + /** + * @param string $root + * + * @return BuildClass + */ + public function setRoot(string $root): BuildClass + { + $this->root = $root; + return $this; + } + + public function run(): array + { + $model = $this->getModel()->build(); + $errorCode = $this->getErrorCode()->setModelName($model['classname'])->build(); + $service = $this->getService()->setModel($model)->setErrorCode($errorCode)->build(); + $controller = $this->getController()->setService($service)->build(); + return [ + 'file' => array_map(function ($file) { + return $this->getRoot() . '/' . $file . '.php'; + }, [ + 'model' => $this->generateCodeEntity->getModel(), + 'service' => $this->generateCodeEntity->getService(), + 'controller' => $this->getGenerateCodeEntity()->getController(), + 'errorCode' => $errorCode['path'], + ]), + 'path' => $controller, + ]; + } +} diff --git a/app/Component/Generate/Build/Config/BuildActionClassConfig.php b/app/Component/Generate/Build/Config/BuildActionClassConfig.php new file mode 100644 index 0000000..b7808cb --- /dev/null +++ b/app/Component/Generate/Build/Config/BuildActionClassConfig.php @@ -0,0 +1,82 @@ +namespace; + } + + /** + * @param string $namespace + * + * @return BuildActionClassConfig + */ + public function setNamespace(string $namespace): BuildActionClassConfig + { + $this->namespace = $namespace; + return $this; + } + + /** + * @return string + */ + public function getSuffix(): string + { + return $this->suffix; + } + + /** + * @param string $suffix + * + * @return BuildActionClassConfig + */ + public function setSuffix(string $suffix): BuildActionClassConfig + { + $this->suffix = $suffix; + return $this; + } + + /** + * @return string|null + */ + public function getFirstNamespace(): ?string + { + return $this->firstNamespace; + } + + /** + * @param string|null $firstNamespace + * + * @return BuildActionClassConfig + */ + public function setFirstNamespace(?string $firstNamespace): BuildActionClassConfig + { + $this->firstNamespace = $firstNamespace; + return $this; + } +} diff --git a/app/Component/Generate/Build/Config/BuildActionConfig.php b/app/Component/Generate/Build/Config/BuildActionConfig.php new file mode 100644 index 0000000..be8bb8f --- /dev/null +++ b/app/Component/Generate/Build/Config/BuildActionConfig.php @@ -0,0 +1,58 @@ +service; + } + + /** + * @param BuildActionClassConfig $service + * + * @return BuildActionConfig + */ + public function setService(BuildActionClassConfig $service): BuildActionConfig + { + $this->service = $service; + return $this; + } + + /** + * @return BuildActionClassConfig + */ + public function getController(): BuildActionClassConfig + { + return $this->controller; + } + + /** + * @param BuildActionClassConfig $controller + * + * @return BuildActionConfig + */ + public function setController(BuildActionClassConfig $controller): BuildActionConfig + { + $this->controller = $controller; + return $this; + } +} diff --git a/app/Component/Generate/Build/Config/BuildConfig.php b/app/Component/Generate/Build/Config/BuildConfig.php new file mode 100644 index 0000000..c10ecc8 --- /dev/null +++ b/app/Component/Generate/Build/Config/BuildConfig.php @@ -0,0 +1,157 @@ +default; + } + + /** + * @param BuildDefaultConfig $default + * + * @return BuildConfig + */ + public function setDefault(BuildDefaultConfig $default): BuildConfig + { + $this->default = $default; + return $this; + } + + /** + * @return BuildControllerConfig + */ + public function getController(): BuildControllerConfig + { + return $this->controller; + } + + /** + * @param BuildControllerConfig $controller + * + * @return BuildConfig + */ + public function setController(BuildControllerConfig $controller): BuildConfig + { + $this->controller = $controller; + return $this; + } + + /** + * @return BuildActionConfig + */ + public function getAction(): BuildActionConfig + { + return $this->action; + } + + /** + * @param BuildActionConfig $action + * + * @return BuildConfig + */ + public function setAction(BuildActionConfig $action): BuildConfig + { + $this->action = $action; + return $this; + } + + /** + * @return BuildErrorCodeConfig + */ + public function getErrorCode(): BuildErrorCodeConfig + { + return $this->errorCode; + } + + /** + * @param BuildErrorCodeConfig $errorCode + * + * @return BuildConfig + */ + public function setErrorCode(BuildErrorCodeConfig $errorCode): BuildConfig + { + $this->errorCode = $errorCode; + return $this; + } + + /** + * @return BuildServiceConfig + */ + public function getService(): BuildServiceConfig + { + return $this->service; + } + + /** + * @param BuildServiceConfig $service + * + * @return BuildConfig + */ + public function setService(BuildServiceConfig $service): BuildConfig + { + $this->service = $service; + return $this; + } + + /** + * @return BuildExceptionConfig + */ + public function getException(): BuildExceptionConfig + { + return $this->exception; + } + + /** + * @param BuildExceptionConfig $exception + * + * @return BuildConfig + */ + public function setException(BuildExceptionConfig $exception): BuildConfig + { + $this->exception = $exception; + return $this; + } +} diff --git a/app/Component/Generate/Build/Config/BuildControllerConfig.php b/app/Component/Generate/Build/Config/BuildControllerConfig.php new file mode 100644 index 0000000..aa32cb8 --- /dev/null +++ b/app/Component/Generate/Build/Config/BuildControllerConfig.php @@ -0,0 +1,157 @@ +inheritance; + } + + /** + * @param string $inheritance + * + * @return BuildControllerConfig + */ + public function setInheritance(string $inheritance): BuildControllerConfig + { + $this->inheritance = $inheritance; + return $this; + } + + /** + * @return callable + */ + public function getProperties(): callable + { + return $this->properties; + } + + /** + * @param callable|null $properties + * + * @return BuildControllerConfig + */ + public function setProperties(?callable $properties): BuildControllerConfig + { + $this->properties = $properties; + return $this; + } + + /** + * @return string + */ + public function getAnnotationValidateParse(): string + { + return $this->annotationValidateParse; + } + + /** + * @param string $annotationValidateParse + * + * @return BuildControllerConfig + */ + public function setAnnotationValidateParse(string $annotationValidateParse): BuildControllerConfig + { + $this->annotationValidateParse = $annotationValidateParse; + return $this; + } + + /** + * @return array + */ + public function getUses(): array + { + return $this->uses; + } + + /** + * @param array $uses + * + * @return BuildControllerConfig + */ + public function setUses(array $uses): BuildControllerConfig + { + $this->uses = $uses; + return $this; + } + + /** + * @return callable + */ + public function getComment(): callable + { + return $this->comment; + } + + /** + * @param callable $comment + * + * @return BuildControllerConfig + */ + public function setComment(callable $comment): BuildControllerConfig + { + $this->comment = $comment; + return $this; + } + + /** + * @return string + */ + public function getPrefix(): string + { + return $this->prefix; + } + + /** + * @param string $prefix + * + * @return BuildControllerConfig + */ + public function setPrefix(string $prefix): BuildControllerConfig + { + $this->prefix = $prefix; + return $this; + } +} diff --git a/app/Component/Generate/Build/Config/BuildDefaultBaseConfig.php b/app/Component/Generate/Build/Config/BuildDefaultBaseConfig.php new file mode 100644 index 0000000..03b37a8 --- /dev/null +++ b/app/Component/Generate/Build/Config/BuildDefaultBaseConfig.php @@ -0,0 +1,33 @@ +path; + } + + /** + * @param string $path + * + * @return BuildDefaultBaseConfig + */ + public function setPath(string $path): BuildDefaultBaseConfig + { + $this->path = $path; + return $this; + } +} diff --git a/app/Component/Generate/Build/Config/BuildDefaultConfig.php b/app/Component/Generate/Build/Config/BuildDefaultConfig.php new file mode 100644 index 0000000..fda1960 --- /dev/null +++ b/app/Component/Generate/Build/Config/BuildDefaultConfig.php @@ -0,0 +1,109 @@ +controller; + } + + /** + * @param BuildDefaultBaseConfig $controller + * + * @return BuildDefaultConfig + */ + public function setController(BuildDefaultBaseConfig $controller): BuildDefaultConfig + { + $this->controller = $controller; + return $this; + } + + /** + * @return BuildDefaultBaseConfig + */ + public function getService(): BuildDefaultBaseConfig + { + return $this->service; + } + + /** + * @param BuildDefaultBaseConfig $service + * + * @return BuildDefaultConfig + */ + public function setService(BuildDefaultBaseConfig $service): BuildDefaultConfig + { + $this->service = $service; + return $this; + } + + /** + * @return BuildDefaultErrorCodeConfig + */ + public function getErrorCode(): BuildDefaultErrorCodeConfig + { + return $this->errorCode; + } + + /** + * @param BuildDefaultErrorCodeConfig $errorCode + * + * @return BuildDefaultConfig + */ + public function setErrorCode(BuildDefaultErrorCodeConfig $errorCode): BuildDefaultConfig + { + $this->errorCode = $errorCode; + return $this; + } + + /** + * @return Link[] + */ + public function getAction(): array + { + return $this->action; + } + + /** + * @param Link[] $action + * + * @return BuildDefaultConfig + */ + public function setAction(array $action): BuildDefaultConfig + { + $this->action = $action; + return $this; + } +} diff --git a/app/Component/Generate/Build/Config/BuildDefaultErrorCodeConfig.php b/app/Component/Generate/Build/Config/BuildDefaultErrorCodeConfig.php new file mode 100644 index 0000000..e739f2f --- /dev/null +++ b/app/Component/Generate/Build/Config/BuildDefaultErrorCodeConfig.php @@ -0,0 +1,30 @@ +prefix; + } + + /** + * @param array $prefix + * + * @return BuildDefaultErrorCodeConfig + */ + public function setPrefix(array $prefix): BuildDefaultErrorCodeConfig + { + $this->prefix = $prefix; + return $this; + } +} diff --git a/app/Component/Generate/Build/Config/BuildErrorCodeConfig.php b/app/Component/Generate/Build/Config/BuildErrorCodeConfig.php new file mode 100644 index 0000000..12b6db2 --- /dev/null +++ b/app/Component/Generate/Build/Config/BuildErrorCodeConfig.php @@ -0,0 +1,58 @@ +inheritance; + } + + /** + * @param string $inheritance + * + * @return BuildErrorCodeConfig + */ + public function setInheritance(string $inheritance): BuildErrorCodeConfig + { + $this->inheritance = $inheritance; + return $this; + } + + /** + * @return string + */ + public function getUse(): string + { + return $this->use; + } + + /** + * @param string $use + * + * @return BuildErrorCodeConfig + */ + public function setUse(string $use): BuildErrorCodeConfig + { + $this->use = $use; + return $this; + } +} diff --git a/app/Component/Generate/Build/Config/BuildExceptionConfig.php b/app/Component/Generate/Build/Config/BuildExceptionConfig.php new file mode 100644 index 0000000..a6d4a10 --- /dev/null +++ b/app/Component/Generate/Build/Config/BuildExceptionConfig.php @@ -0,0 +1,58 @@ +inheritance; + } + + /** + * @param string $inheritance + * + * @return BuildExceptionConfig + */ + public function setInheritance(string $inheritance): BuildExceptionConfig + { + $this->inheritance = $inheritance; + return $this; + } + + /** + * @return string + */ + public function getUse(): string + { + return $this->use; + } + + /** + * @param string $use + * + * @return BuildExceptionConfig + */ + public function setUse(string $use): BuildExceptionConfig + { + $this->use = $use; + return $this; + } +} diff --git a/app/Component/Generate/Build/Config/BuildServiceConfig.php b/app/Component/Generate/Build/Config/BuildServiceConfig.php new file mode 100644 index 0000000..181130a --- /dev/null +++ b/app/Component/Generate/Build/Config/BuildServiceConfig.php @@ -0,0 +1,58 @@ +inheritance; + } + + /** + * @param string $inheritance + * + * @return BuildServiceConfig + */ + public function setInheritance(string $inheritance): BuildServiceConfig + { + $this->inheritance = $inheritance; + return $this; + } + + /** + * @return string + */ + public function getUse(): string + { + return $this->use; + } + + /** + * @param string $use + * + * @return BuildServiceConfig + */ + public function setUse(string $use): BuildServiceConfig + { + $this->use = $use; + return $this; + } +} diff --git a/app/Component/Generate/Build/ControllerBuild.php b/app/Component/Generate/Build/ControllerBuild.php new file mode 100644 index 0000000..81023a1 --- /dev/null +++ b/app/Component/Generate/Build/ControllerBuild.php @@ -0,0 +1,155 @@ +service; + } + + /** + * @param array $service + * + * @return ControllerBuild + */ + public function setService(array $service): ControllerBuild + { + $this->service = $service; + return $this; + } + + /** + * @return string + */ + public function getServiceName(): string + { + return $this->serviceName; + } + + /** + * @param string $serviceName + * + * @return ControllerBuild + */ + public function setServiceName(string $serviceName): ControllerBuild + { + $this->serviceName = $serviceName; + return $this; + } + + protected function getActionService(string $name, array $form, string $description = ''): array + { + $config = $this->getConfig()->getAction()->getController(); + $classname = null; + if (!empty($config->getFirstNamespace())) { + $classname = $config->getFirstNamespace() . '\\' . StringHelper::ucfirst($name) . $config->getSuffix(); + if (!class_exists($classname)) { + $classname = null; + } + } + if ($classname === null) { + $classname = $config->getNamespace() . '\\' . StringHelper::ucfirst($name) . $config->getSuffix(); + } + if (!class_exists($classname)) { + $classname = $config->getNamespace() . '\\Default' . $config->getSuffix(); + } + + // path + $paths = [ + $this->getConfig()->getController()->getPrefix(), + ]; + $directory = str_replace($this->getConfig()->getDefault()->getController()->getPath(), '', $this->getGenerateCodeEntity()->getController()); + $controllerPath = StringHelper::dirname($directory); + if ($controllerPath !== '/') { + $paths[] = $controllerPath; + } + $paths[] = StringHelper::basename($directory, 'Controller'); + $paths[] = $name; + + $validateParse = $this->getConfig()->getController()->getAnnotationValidateParse(); + /** + * @var BaseValidateParse $parse + */ + $parse = new $validateParse; + $parse->setParams($form)->setPath(implode('/', array_map(function ($path) { + return StringHelper::strtolower($path); + }, $paths)))->setDescription($this->getGenerateCodeEntity()->getName() . $description); + + /** + * @var BaseActionControllerBuild $model + */ + $model = new $classname; + $model->setName($name)->setValidateParse($parse)->setServiceName($this->getServiceName()); + return [$model->getMethod(), $model->getUses(), $parse->getPath()]; + } + + public function build(): array + { + $this->setServiceName(lcfirst($this->getService()['classname'])); + $properties = call_user_func($this->getConfig()->getController()->getProperties(), $this); + $uses = $this->getConfig()->getController()->getUses(); + $uses[] = $this->getService()['class']; + $routs = $methods = $actions = []; + + // todo 如果有 查询 则有 list + if (1 || !empty($this->getGenerateCodeEntity()->getSearch())) { +// [$method, $use] = $this->getActionService('list', $this->getGenerateCodeEntity()->getSearch(), '列表'); + [$method, $use, $rout] = $this->getActionService('list', [], '列表'); + $methods[] = $method; + $uses = ArrayHelper::merge($uses, $use); + $routs[] = $rout; + } + + foreach ($this->getGenerateCodeEntity()->getActions() as $action) { + if (in_array($action->getPath(), $actions)) { + continue; + } +// [$method, $use] = $this->getActionService($action->getPath(), $action->getForm()->getItem(), $action->getName()); + [$method, $use, $rout] = $this->getActionService($action->getPath(), [], $action->getName()); + $methods[] = $method; + $uses = ArrayHelper::merge($uses, $use); + $actions[] = $action->getPath(); + $routs[] = $rout; + } + + $class = $this->getNamespace($this->getGenerateCodeEntity()->getController()); + $classname = StringHelper::basename($class); + $namespace = StringHelper::dirname($class); + $comment = [ + "class {$classname}", + "@package {$namespace}", + ]; + $comment = ArrayHelper::merge($comment, call_user_func($this->getConfig()->getController()->getComment(), $this)); + $params = [ + 'namespace' => $namespace, + 'classname' => $classname, + 'uses' => $uses, + 'comments' => $comment, + 'inheritance' => $this->getConfig()->getController()->getInheritance(), + 'properties' => $properties, + 'methods' => $methods, + ]; + $this->output($params, StringHelper::dirname($this->getGenerateCodeEntity()->getController())); + return $routs; + } +} diff --git a/app/Component/Generate/Build/ErrorCodeBuild.php b/app/Component/Generate/Build/ErrorCodeBuild.php new file mode 100644 index 0000000..6ef48d4 --- /dev/null +++ b/app/Component/Generate/Build/ErrorCodeBuild.php @@ -0,0 +1,181 @@ +modelName; + } + + /** + * @param string $modelName + * + * @return ErrorCodeBuild + */ + public function setModelName(string $modelName): ErrorCodeBuild + { + $this->modelName = $modelName; + return $this; + } + + /** + * 文件名称 + * @return string + */ + protected function getName(): string + { + return $this->getModelName() . 'Error'; + } + + /** + * 获得 错误字段 值的 前缀 + * + * @param string $path + * + * @return array + */ + protected function getPrefix(string $path): array + { + $defaultErrorCode = $this->getConfig()->getDefault()->getErrorCode(); + $defaultPath = $defaultErrorCode->getPath(); + $directory = str_replace($defaultPath, '', $path); + $errorPrefix = StringHelper::explode($directory, '/', true, true); + // default prefix + $prefix = ArrayHelper::get($defaultErrorCode->getPrefix(), 'default', 'B-001'); + if (!empty($errorPrefix[0])) { + $appErrorPrefix = ArrayHelper::get($defaultErrorCode->getPrefix(), StringHelper::strtolower($errorPrefix[0])); + if (!empty($appErrorPrefix)) { + $prefix = $appErrorPrefix; + $defaultPath .= "/{$errorPrefix[0]}"; + } + } + $scan = FileHelper::scan($this->getRoot() . '/' . $defaultPath); + $number = iterator_count($scan) + 1; + $prefix .= '-' . str_pad($number, 3, "0", STR_PAD_LEFT); + $errorPrefix[] = $this->getModelName(); + array_unshift($errorPrefix, 'errors'); + return [ + 'value' => $prefix, + 'name' => implode("_", $errorPrefix), + ]; + } + + /*** + * 获得 常量 + * + * @param string $path + * + * @return array + */ + protected function getConstant(string $path): array + { + // prefix + $prefix = $this->getPrefix($path); + $constants = []; + $num = 1; + $isChange = false; + foreach ($this->getGenerateCodeEntity()->getActions() as $action) { + if (StringHelper::matchWildcard('change*', $action->getPath())) { + $isChange = true; + } + if (!in_array($action->getPath(), $this->allow) || !empty($constants[$action->getPath()])) { + continue; + } + $constantName = $action->getPath() . '_fail'; + $constantMessage = $action->getName() . '失败'; + $constants[$action->getPath()] = [ + 'name' => StringHelper::strtoupper($prefix['name'] . "_" . $constantName), + 'default' => $prefix['value'] . '-' . str_pad($num, 3, "0", STR_PAD_LEFT), + 'comments' => [ + '@Message("' . $this->getGenerateCodeEntity()->getName() . $constantMessage . '")', + ], + ]; + $num++; + } + + $constants['notFound'] = [ + 'name' => StringHelper::strtoupper($prefix['name'] . "_not_found"), + 'default' => $prefix['value'] . '-' . str_pad($num, 3, "0", STR_PAD_LEFT), + 'comments' => [ + '@Message("' . $this->getGenerateCodeEntity()->getName() . '不存在")', + ], + ]; + + if ($isChange && empty($constants['update'])) { + $num++; + $constants['update'] = [ + 'name' => StringHelper::strtoupper($prefix['name'] . "_update_fail"), + 'default' => $prefix['value'] . '-' . str_pad($num, 3, "0", STR_PAD_LEFT), + 'comments' => [ + '@Message("' . $this->getGenerateCodeEntity()->getName() . '更新失败")', + ], + ]; + } + + return $constants; + } + + public function build(): array + { + $defaultConfig = $this->getConfig()->getDefault(); + // 错误码 目录结构 基于 服务目录结构 + $errorCodePath = str_replace($defaultConfig->getService()->getPath(), $defaultConfig->getErrorCode()->getPath(), + $this->getGenerateCodeEntity()->getService()); + $path = StringHelper::dirname($errorCodePath); + $constants = $this->getConstant($path); + + $class = $this->getNamespace($path . '/' . $this->getName()); + $namespace = StringHelper::dirname($class); + + $params = [ + 'namespace' => $namespace, + 'classname' => $this->getName(), + 'uses' => [ + $this->getConfig()->getErrorCode()->getUse() + ], + 'comments' => [ + "class {$this->getName()}", + "@package {$namespace}", + ], + 'inheritance' => $this->getConfig()->getErrorCode()->getInheritance(), + 'constants' => $constants, + ]; + $this->output($params, $path); + return [ + 'classname' => $this->getName(), + 'class' => $class, + 'path' => $path . '/' . $this->getName(), + 'constant' => array_map(function ($constant) { + return $constant['name']; + }, $constants), + ]; + } +} diff --git a/app/Component/Generate/Build/Model/HyperfModelBuild.php b/app/Component/Generate/Build/Model/HyperfModelBuild.php new file mode 100644 index 0000000..2d5298c --- /dev/null +++ b/app/Component/Generate/Build/Model/HyperfModelBuild.php @@ -0,0 +1,71 @@ +path; + } + + /** + * @param string $path + * + * @return HyperfModelBuild + */ + public function setPath(string $path): HyperfModelBuild + { + $this->path = $path; + return $this; + } + + /** + * @return string + */ + public function getPool(): string + { + return $this->pool; + } + + /** + * @param string $pool + * + * @return HyperfModelBuild + */ + public function setPool(string $pool): HyperfModelBuild + { + $this->pool = $pool; + return $this; + } + + public function build(): array + { + $class = $this->getNamespace($this->getPath()); + $table = StringHelper::basename($class); + $model = new GenerateModel(); + $data = $model->create($table, $this->getPool(), StringHelper::dirname($this->getPath())); + return [ + 'classname' => $table, + 'class' => $class, + 'primaryKey' => $data[$table], + ]; + } +} diff --git a/app/Component/Generate/Build/ServiceBuild.php b/app/Component/Generate/Build/ServiceBuild.php new file mode 100644 index 0000000..2c8333f --- /dev/null +++ b/app/Component/Generate/Build/ServiceBuild.php @@ -0,0 +1,156 @@ +errorCode; + } + + /** + * @param array $errorCode + * + * @return ServiceBuild + */ + public function setErrorCode(array $errorCode): ServiceBuild + { + $this->errorCode = $errorCode; + return $this; + } + + /** + * @return array + */ + public function getModel(): array + { + return $this->model; + } + + /** + * @param array $model + * + * @return ServiceBuild + */ + public function setModel(array $model): ServiceBuild + { + $this->model = $model; + return $this; + } + + protected function getActionService(string $name, string $description = ''): array + { + $config = $this->getConfig()->getAction()->getService(); + $actionName = $name; + if (StringHelper::matchWildcard('change*', $name)) { + $name = 'change'; + } + + $classname = ''; + if (!empty($config->getFirstNamespace())) { + $classname = $config->getFirstNamespace() . '\\' . StringHelper::ucfirst($name) . $config->getSuffix(); + if (!class_exists($classname)) { + $classname = ''; + } + } + + if ($classname === '') { + $classname = $config->getNamespace() . '\\' . StringHelper::ucfirst($name) . $config->getSuffix(); + } + + if (!class_exists($classname)) { + $classname = $config->getNamespace() . '\\Default' . $config->getSuffix(); + } + /** + * @var BaseActionServiceBuild $model + */ + $model = new $classname; + $model->setModel($this->getModel()) + ->setErrors($this->getErrorCode()) + ->setName($actionName) + ->setDescription($description) + ->setExceptionName($this->getConfig()->getException()->getInheritance()); + return [$model->getMethod(), $model->getUses()]; + } + + public function build(): array + { + $uses = [ + $this->getModel()['class'], + $this->getErrorCode()['class'], + $this->getConfig()->getException()->getUse(), + $this->getConfig()->getService()->getUse(), + ]; + + $methods = $actions = []; + // todo 如果有 查询 则有 list + if (1 || !empty($this->getGenerateCodeEntity()->getSearch())) { + [$method, $use] = $this->getActionService('list', '列表'); + $methods[] = $method; + $uses = ArrayHelper::merge($uses, $use); + $actions[] = 'list'; + } + + foreach ($this->getGenerateCodeEntity()->getActions() as $action) { + if (in_array($action->getPath(), $actions)) { + continue; + } + [$method, $use] = $this->getActionService($action->getPath(), $action->getName()); + $methods[] = $method; + $uses = ArrayHelper::merge($uses, $use); + $actions[] = $action->getPath(); + } + + // findOne + if (in_array('update', $actions) || in_array('detail', $actions)) { + [$method, $use] = $this->getActionService('findOne', 'find one model'); + $methods[] = $method; + $uses = ArrayHelper::merge($uses, $use); + } + + // formatModel + if (in_array('list', $actions) || in_array('detail', $actions)) { + [$method, $use] = $this->getActionService('formatModel', '格式化'); + $methods[] = $method; + $uses = ArrayHelper::merge($uses, $use); + } + + $class = $this->getNamespace($this->getGenerateCodeEntity()->getService()); + $classname = StringHelper::basename($class); + $namespace = StringHelper::dirname($class); + $params = [ + 'namespace' => $namespace, + 'classname' => $classname, + 'uses' => $uses, + 'comments' => [ + "class {$classname}", + "@package {$namespace}", + ], + 'inheritance' => $this->getConfig()->getService()->getInheritance(), + 'methods' => $methods, + ]; + $this->output($params, StringHelper::dirname($this->getGenerateCodeEntity()->getService())); + return [ + 'classname' => $classname, + 'class' => $class, + ]; + } +} diff --git a/app/Component/Generate/ClassFile/ClassBase.php b/app/Component/Generate/ClassFile/ClassBase.php index 5d7faf2..e8fd51a 100644 --- a/app/Component/Generate/ClassFile/ClassBase.php +++ b/app/Component/Generate/ClassFile/ClassBase.php @@ -224,6 +224,9 @@ public function getValueType($value): string case 'unknown type': $value = '{unknown}'; break; + case 'array': + $value = json_encode($value); + break; default: break; } diff --git a/app/Component/Generate/ClassFile/ClassConfig.php b/app/Component/Generate/ClassFile/ClassConfig.php index 0a2cdf6..af95146 100644 --- a/app/Component/Generate/ClassFile/ClassConfig.php +++ b/app/Component/Generate/ClassFile/ClassConfig.php @@ -531,11 +531,12 @@ protected function renderMethod(): string $classParams->setType("mixed"); } $classParam .= $classParamName; - if (!empty($classParams->getDefault())) { + if ($classParams->getAssign()) { $classParam .= (" = " . $classMethod->getValueType($classParams->getDefault())); } $params[] = $classParam; - $classMethod->addComment("@param {$classParams->getType()} {$classParamName} {$classParams->getComment()}"); + $type = str_replace('?', 'null|', $classParams->getType()); + $classMethod->addComment("@param {$type} {$classParamName} {$classParams->getComment()}"); } } $param = implode(", ", $params); @@ -559,7 +560,7 @@ protected function renderMethod(): string $classMethod->setContent("{$this->getSpaces(2)}// TODO: Implement {$classMethod->getName()}() method."); } $data[] = $classMethod->getContent(); - $data[] = "{$this->getSpaces()}}"; + $data[] = "{$this->getSpaces()}}\n"; } } return implode("\n", $data); diff --git a/app/Component/Generate/ClassFile/ClassParams.php b/app/Component/Generate/ClassFile/ClassParams.php index 4bb332b..185d269 100644 --- a/app/Component/Generate/ClassFile/ClassParams.php +++ b/app/Component/Generate/ClassFile/ClassParams.php @@ -26,6 +26,12 @@ class ClassParams extends BaseObject */ private $default; + /** + * 是否 赋值 + * @var bool + */ + private $assign = false; + /** * @return mixed */ @@ -41,6 +47,7 @@ public function getDefault() */ public function setDefault($default): ClassParams { + $this->setAssign(true); $this->default = $default; return $this; } @@ -101,4 +108,23 @@ public function setComment(string $comment): ClassParams $this->comment = $comment; return $this; } + + /** + * @return bool + */ + public function getAssign(): bool + { + return $this->assign; + } + + /** + * @param bool $assign + * + * @return ClassParams + */ + public function setAssign(bool $assign): ClassParams + { + $this->assign = $assign; + return $this; + } } diff --git a/app/Constant/Error.php b/app/Constant/Error.php index e9e98f8..c511198 100644 --- a/app/Constant/Error.php +++ b/app/Constant/Error.php @@ -38,6 +38,51 @@ class Error extends BaseEnum */ const ERROR_COMMENTERRORCODE_INVALID_TOKEN = 'F-000-000-403'; + /** + * @Message("管理员删除失败") + */ + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_REMOVE_FAIL = 'B-001-007-001'; + + /** + * @Message("管理员创建失败") + */ + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_CREATE_FAIL = 'B-001-007-002'; + + /** + * @Message("管理员导入失败") + */ + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_IMPORT_FAIL = 'B-001-007-003'; + + /** + * @Message("管理员导出失败") + */ + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_EXPORT_FAIL = 'B-001-007-004'; + + /** + * @Message("管理员不存在") + */ + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_NOT_FOUND = 'B-001-007-005'; + + /** + * @Message("管理员更新失败") + */ + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_UPDATE_FAIL = 'B-001-007-006'; + + /** + * @Message("错误字典生成文件失败") + */ + const ERROR_SYSTEM_GENERATEERROR_ERROR_GENERATE_ERROR_CODE_CREATE_FAIL = 'B-001-005-001'; + + /** + * @Message("服务生成文件失败") + */ + const ERROR_SYSTEM_GENERATEERROR_ERROR_GENERATE_SERVICE_CREATE_FAIL = 'B-001-005-002'; + + /** + * @Message("控制器生成文件失败") + */ + const ERROR_SYSTEM_GENERATEERROR_ERROR_GENERATE_CONTROLLER_CREATE_FAIL = 'B-001-005-003'; + /** * @Message("权限不存在") */ diff --git a/app/Constant/Errors/System/GenerateError.php b/app/Constant/Errors/System/GenerateError.php new file mode 100644 index 0000000..cbc263b --- /dev/null +++ b/app/Constant/Errors/System/GenerateError.php @@ -0,0 +1,23 @@ + 'success', // 'default' => 1, -// // ], // [ // 'name' => 'fail', @@ -263,27 +263,26 @@ public function generate() // $generate->setConfig($config); // return $this->success(['a' => $generate->output('php'), 'b' => $config->__toObjectString(), 'c' => $config->__getClassname()]); // - $config = $this->container->get(ConfigInterface::class)->get('genCode'); + $config = $this->container->get(ConfigInterface::class)->get('genCode.default'); $params = [ - 'controller' => 'app/Controller/AdController', - 'model' => 'app/Model/Ad', + 'name' => '管理员', + 'model' => 'app/Model/Admin', 'pool' => 'default', - 'service' => 'app/Service/AdService', + 'controller' => 'app/Controller/Test/AdminController', + 'service' => 'app/Service/Test/AdminService', 'actions' => $config['actions'], - 'table' => [ + 'list' => [// todo 白名单 ], 'search' => [ ], - 'tag' => [ + 'tag' => [ ], ]; $generateCodeEntity = new GenerateCodeEntity($params); - var_dump($generateCodeEntity); - die; - $this->generateService->file($generateCodeEntity); - return $this->success($generateCodeEntity->toArray()); + $data = $this->generateService->crud($generateCodeEntity); + return $this->success($data); } } diff --git a/app/Entity/GenerateCodeEntity.php b/app/Entity/GenerateCodeEntity.php index 90cc2a2..1a5dae1 100644 --- a/app/Entity/GenerateCodeEntity.php +++ b/app/Entity/GenerateCodeEntity.php @@ -8,6 +8,12 @@ class GenerateCodeEntity extends BaseObject { + /** + * 名称 + * @var string + */ + private $name; + /** * 控制 path * @var string @@ -42,7 +48,7 @@ class GenerateCodeEntity extends BaseObject * 列表 * @var Table */ - private $table; + private $list; /** * 列表 搜索 @@ -136,9 +142,9 @@ public function setActions(array $actions): GenerateCodeEntity /** * @return Table */ - public function getTable(): Table + public function getList(): Table { - return $this->table; + return $this->list; } /** @@ -146,9 +152,9 @@ public function getTable(): Table * * @return GenerateCodeEntity */ - public function setTable(Table $table): GenerateCodeEntity + public function setList(Table $table): GenerateCodeEntity { - $this->table = $table; + $this->list = $table; return $this; } @@ -208,4 +214,23 @@ public function setTag(array $tag): GenerateCodeEntity $this->tag = $tag; return $this; } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @param string $name + * + * @return GenerateCodeEntity + */ + public function setName(string $name): GenerateCodeEntity + { + $this->name = $name; + return $this; + } } diff --git a/app/Model/Admin.php b/app/Model/Admin.php index 4a8067c..159070e 100644 --- a/app/Model/Admin.php +++ b/app/Model/Admin.php @@ -1,33 +1,35 @@ 'string', 'number' => 'integer', 'status' => 'integer', 'enable' => 'integer', 'create_at' => 'datetime', 'update_at' => 'datetime']; - - /** - * Returns an ID that can uniquely identify a user identity. - * @return string an ID that uniquely identifies a user identity. - */ - public function getId(): string - { - return $this->admin_id; - } -} +} \ No newline at end of file diff --git a/app/Service/Admin/AdminService.php b/app/Service/Admin/AdminService.php index 9c7c3bb..f9a8538 100644 --- a/app/Service/Admin/AdminService.php +++ b/app/Service/Admin/AdminService.php @@ -16,6 +16,10 @@ use Lengbin\Hyperf\Common\Framework\BaseService; use Throwable; +/** + * Class AdminService + * @package App\Service\Admin + */ class AdminService extends BaseService { diff --git a/app/Service/System/GenerateService.php b/app/Service/System/GenerateService.php index 3c97e51..3009b1f 100644 --- a/app/Service/System/GenerateService.php +++ b/app/Service/System/GenerateService.php @@ -2,89 +2,36 @@ namespace App\Service\System; +use App\Component\Generate\Build\BuildClass; +use App\Component\Generate\Build\Config\BuildConfig; +use App\Component\Generate\Build\ControllerBuild; +use App\Component\Generate\Build\ErrorCodeBuild; +use App\Component\Generate\Build\Model\HyperfModelBuild; +use App\Component\Generate\Build\ServiceBuild; use App\Entity\GenerateCodeEntity; -use Lengbin\Helper\YiiSoft\StringHelper; -use Lengbin\Hyperf\Common\Component\Generate\Model\GenerateModel; use Lengbin\Hyperf\Common\Framework\BaseService; class GenerateService extends BaseService { - protected function getPath(string $name) + public function crud(GenerateCodeEntity $generateCodeEntity): array { - return str_replace('\\', '/', $name); + $config = new BuildConfig($this->config->get('genCode', [])); + $model = new HyperfModelBuild([ + 'path' => $generateCodeEntity->getModel(), + 'pool' => $generateCodeEntity->getPool(), + ]); + $build = (new BuildClass())->setGenerateCodeEntity($generateCodeEntity) + ->setRoot(BASE_PATH) + ->setConfig($config) + ->setModel($model) + ->setService(new ServiceBuild()) + ->setErrorCode(new ErrorCodeBuild()) + ->setController(new ControllerBuild()); + return $build->run(); } - protected function getNamespace(string $name): string + public function html(GenerateCodeEntity $generateCodeEntity): array { - return implode('\\', array_map(function ($str) { - return StringHelper::ucfirst($str); - }, explode('\\', $this->getPath($name)))); - } - - protected function controllerPhpFile(string $path, array $actions): array - { - $namespace = $this->getNamespace(StringHelper::dirname($path)); - $classname = StringHelper::basename($path); - return [ - 'namespace' => $namespace, - 'classname' => $classname, - 'uses' => [ - 'Hyperf\HttpServer\Annotation\Controller', - 'Lengbin\Hyperf\Auth\RouterAuthAnnotation', - 'Lengbin\Hyperf\Common\Framework\BaseController', - ], - 'comments' => [ - 'Class AdminController', - '@package App\Controller', - '@Controller()', - '@RouterAuthAnnotation(isPublic=true)', - ], - 'inheritance' => 'BaseController', - 'properties' => [ - - ], - 'methods' => [ - - ], - ]; - } - - protected function servicePhpFile(string $path, array $actions): array - { - return [ - 'namespace' => 'App\Controller', - 'classname' => 'AdminController', - 'uses' => [ - 'Hyperf\HttpServer\Annotation\Controller', - 'Lengbin\Hyperf\Auth\RouterAuthAnnotation', - 'Lengbin\Hyperf\Common\Framework\BaseController', - ], - 'comments' => [ - 'Class AdminController', - '@package App\Controller', - '@Controller()', - '@RouterAuthAnnotation(isPublic=true)', - ], - 'inheritance' => 'BaseController', - 'properties' => [ - - ], - 'methods' => [ - - ], - ]; - } - - protected function modelPhpFile(string $path, string $pool): array - { - $model = new GenerateModel(); - $model->create('ad'); - } - - public function file(GenerateCodeEntity $generateCodeEntity) - { - $this->controllerPhpFile($generateCodeEntity->getController(), $generateCodeEntity->getActions()); - $this->servicePhpFile($generateCodeEntity->getService(), $generateCodeEntity->getActions()); - $this->modelPhpFile($generateCodeEntity->getModel(), $generateCodeEntity->getPool()); + // todo 未实现 前端代码 自动生成 } } From 4b2d543a4038e03ad4640343b491808a2c892dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Thu, 14 Jan 2021 18:55:56 +0800 Subject: [PATCH 70/82] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=20-?= =?UTF-8?q?=20=E7=BC=BA=E5=A4=B1=20=E5=89=8D=E7=AB=AF=20=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=EF=BC=8C=E5=8F=AF=E4=BB=A5=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/DefaultActionServiceBuild.php | 2 +- .../Build/Config/BuildDefaultConfig.php | 10 +- .../Config/BuildDefaultErrorCodeConfig.php | 30 ---- .../Build/Config/BuildErrorCodeConfig.php | 24 +++ .../Generate/Build/ErrorCodeBuild.php | 7 +- app/Constant/Error.php | 12 +- config/autoload/genCode.php | 164 ++++++++++++++++++ 7 files changed, 203 insertions(+), 46 deletions(-) delete mode 100644 app/Component/Generate/Build/Config/BuildDefaultErrorCodeConfig.php create mode 100644 config/autoload/genCode.php diff --git a/app/Component/Generate/Build/Action/Service/DefaultActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/DefaultActionServiceBuild.php index 47216fd..98f2e89 100644 --- a/app/Component/Generate/Build/Action/Service/DefaultActionServiceBuild.php +++ b/app/Component/Generate/Build/Action/Service/DefaultActionServiceBuild.php @@ -10,7 +10,7 @@ public function getContent(): array return []; } return [ - $this->getSpaces(2) . "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant'][$this->getName()]});", + "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant'][$this->getName()]});", ]; } diff --git a/app/Component/Generate/Build/Config/BuildDefaultConfig.php b/app/Component/Generate/Build/Config/BuildDefaultConfig.php index fda1960..ab24986 100644 --- a/app/Component/Generate/Build/Config/BuildDefaultConfig.php +++ b/app/Component/Generate/Build/Config/BuildDefaultConfig.php @@ -21,7 +21,7 @@ class BuildDefaultConfig extends BaseObject /** * 错误字典 默认配置 - * @var BuildDefaultErrorCodeConfig + * @var BuildDefaultBaseConfig */ private $errorCode; @@ -70,19 +70,19 @@ public function setService(BuildDefaultBaseConfig $service): BuildDefaultConfig } /** - * @return BuildDefaultErrorCodeConfig + * @return BuildDefaultBaseConfig */ - public function getErrorCode(): BuildDefaultErrorCodeConfig + public function getErrorCode(): BuildDefaultBaseConfig { return $this->errorCode; } /** - * @param BuildDefaultErrorCodeConfig $errorCode + * @param BuildDefaultBaseConfig $errorCode * * @return BuildDefaultConfig */ - public function setErrorCode(BuildDefaultErrorCodeConfig $errorCode): BuildDefaultConfig + public function setErrorCode(BuildDefaultBaseConfig $errorCode): BuildDefaultConfig { $this->errorCode = $errorCode; return $this; diff --git a/app/Component/Generate/Build/Config/BuildDefaultErrorCodeConfig.php b/app/Component/Generate/Build/Config/BuildDefaultErrorCodeConfig.php deleted file mode 100644 index e739f2f..0000000 --- a/app/Component/Generate/Build/Config/BuildDefaultErrorCodeConfig.php +++ /dev/null @@ -1,30 +0,0 @@ -prefix; - } - - /** - * @param array $prefix - * - * @return BuildDefaultErrorCodeConfig - */ - public function setPrefix(array $prefix): BuildDefaultErrorCodeConfig - { - $this->prefix = $prefix; - return $this; - } -} diff --git a/app/Component/Generate/Build/Config/BuildErrorCodeConfig.php b/app/Component/Generate/Build/Config/BuildErrorCodeConfig.php index 12b6db2..371a63e 100644 --- a/app/Component/Generate/Build/Config/BuildErrorCodeConfig.php +++ b/app/Component/Generate/Build/Config/BuildErrorCodeConfig.php @@ -18,6 +18,30 @@ class BuildErrorCodeConfig extends BaseObject */ private $use; + /** + * @var array + */ + private $prefix; + + /** + * @return array + */ + public function getPrefix(): array + { + return $this->prefix; + } + + /** + * @param array $prefix + * + * @return BuildErrorCodeConfig + */ + public function setPrefix(array $prefix): BuildErrorCodeConfig + { + $this->prefix = $prefix; + return $this; + } + /** * @return string */ diff --git a/app/Component/Generate/Build/ErrorCodeBuild.php b/app/Component/Generate/Build/ErrorCodeBuild.php index 6ef48d4..e09d8d1 100644 --- a/app/Component/Generate/Build/ErrorCodeBuild.php +++ b/app/Component/Generate/Build/ErrorCodeBuild.php @@ -64,14 +64,13 @@ protected function getName(): string */ protected function getPrefix(string $path): array { - $defaultErrorCode = $this->getConfig()->getDefault()->getErrorCode(); - $defaultPath = $defaultErrorCode->getPath(); + $defaultPath = $this->getConfig()->getDefault()->getErrorCode()->getPath(); $directory = str_replace($defaultPath, '', $path); $errorPrefix = StringHelper::explode($directory, '/', true, true); // default prefix - $prefix = ArrayHelper::get($defaultErrorCode->getPrefix(), 'default', 'B-001'); + $prefix = ArrayHelper::get($this->getConfig()->getErrorCode()->getPrefix(), 'default', 'B-001'); if (!empty($errorPrefix[0])) { - $appErrorPrefix = ArrayHelper::get($defaultErrorCode->getPrefix(), StringHelper::strtolower($errorPrefix[0])); + $appErrorPrefix = ArrayHelper::get($this->getConfig()->getErrorCode()->getPrefix(), StringHelper::strtolower($errorPrefix[0])); if (!empty($appErrorPrefix)) { $prefix = $appErrorPrefix; $defaultPath .= "/{$errorPrefix[0]}"; diff --git a/app/Constant/Error.php b/app/Constant/Error.php index c511198..57df9db 100644 --- a/app/Constant/Error.php +++ b/app/Constant/Error.php @@ -41,32 +41,32 @@ class Error extends BaseEnum /** * @Message("管理员删除失败") */ - const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_REMOVE_FAIL = 'B-001-007-001'; + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_REMOVE_FAIL = 'B-001-006-001'; /** * @Message("管理员创建失败") */ - const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_CREATE_FAIL = 'B-001-007-002'; + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_CREATE_FAIL = 'B-001-006-002'; /** * @Message("管理员导入失败") */ - const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_IMPORT_FAIL = 'B-001-007-003'; + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_IMPORT_FAIL = 'B-001-006-003'; /** * @Message("管理员导出失败") */ - const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_EXPORT_FAIL = 'B-001-007-004'; + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_EXPORT_FAIL = 'B-001-006-004'; /** * @Message("管理员不存在") */ - const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_NOT_FOUND = 'B-001-007-005'; + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_NOT_FOUND = 'B-001-006-005'; /** * @Message("管理员更新失败") */ - const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_UPDATE_FAIL = 'B-001-007-006'; + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_UPDATE_FAIL = 'B-001-006-006'; /** * @Message("错误字典生成文件失败") diff --git a/config/autoload/genCode.php b/config/autoload/genCode.php new file mode 100644 index 0000000..c43a606 --- /dev/null +++ b/config/autoload/genCode.php @@ -0,0 +1,164 @@ + [ + 'controller' => [ + 'path' => 'app/Controller', + ], + 'service' => [ + 'path' => 'app/Service', + ], + 'errorCode' => [ + 'path' => 'app/Constant/Errors', + ], + // 操作 默认选项配置 + 'actions' => [ + [ + 'name' => '删除', + 'type' => 'action', + 'target' => 'button', + 'path' => 'remove', + 'tip' => '您确定删除吗?', + ], + [ + 'name' => '创建', + 'type' => 'action', + 'target' => 'button', + 'path' => 'create', + 'form' => [], + ], + [ + 'name' => '导入', + 'type' => 'action', + 'target' => 'button', + 'path' => 'import', + ], + [ + 'name' => '导出', + 'type' => 'action', + 'target' => 'button', + 'path' => 'export', + ], + [ + 'name' => '冻结', + 'type' => 'action', + 'target' => 'button', + 'path' => 'changeStatus', + 'data' => [ + 'status' => 2, + ], + ], + [ + 'name' => '编辑', + 'label' => '行内编辑', + 'type' => 'operation', + 'target' => 'link', + 'path' => 'detail', + 'form' => [], + ], + [ + 'name' => '删除', + 'label' => '行内删除', + 'type' => 'operation', + 'target' => 'link', + 'path' => 'remove', + 'tip' => '您确定删除吗?', + ], + [ + 'name' => '修改状态', + 'type' => 'operation', + 'target' => 'link', + 'path' => 'changeStatus', + 'form' => [], + 'condition' => [ + [ + 'judge' => [ + [ + 'attribute' => 'status', + 'type' => '=', + 'value' => 1, + ], + ], + 'type' => 'and', + 'label' => '冻结', + ], + [ + 'judge' => [ + [ + 'attribute' => 'status', + 'type' => '=', + 'value' => 2, + ], + ], + 'type' => 'and', + 'label' => '解冻', + ], + ], + ], + ], + ], + //控制器 继承配置 + 'controller' => [ + 'prefix'=> '/admin', + 'inheritance' => 'Controller', + 'uses' => [ + 'App\Controller\Controller', + 'Hyperf\Apidog\Annotation\ApiController', + 'Hyperf\Apidog\Annotation\Header', + 'Hyperf\Di\Annotation\Inject', + 'Hyperf\Apidog\Annotation\PostApi', + 'Hyperf\Apidog\Annotation\Body', + 'Hyperf\Apidog\Annotation\ApiResponse', + 'Hyperf\Utils\Context' + ], + 'comment' => function ($build) { + $name = $build->getGenerateCodeEntity()->getName(); + return [ + '@ApiController(tag="'.$name.'")', + '@Header(key="Token|token", rule="required|string")' + ]; + }, + 'properties' => function ($build) { + $properties[] = [ + "name" => $build->getServiceName(), + 'comments' => [ + '@Inject()', + "@var {$build->getService()['classname']}", + ], + ]; + return $properties; + }, + 'annotationValidateParse' => 'App\Component\Generate\Build\Action\Controller\ValidateParse\ApidogValidateParse', + ], + 'errorCode' => [ + 'inheritance' => 'BaseEnum', + 'use' => 'Lengbin\Hyperf\ErrorCode\BaseEnum', + // 错误码 业务码 前缀版本 + 'prefix' => [ +// 'api' => 'B-002', // 其他服务应用 +// 'admin' => 'B-001', + 'default' => 'B-001', + ], + ], + 'exception' => [ + 'inheritance' => 'BusinessException', + 'use' => 'Lengbin\Hyperf\Common\Exception\BusinessException', + ], + 'service' => [ + 'inheritance' => 'BaseService', + 'use' => 'Lengbin\Hyperf\Common\Framework\BaseService', + ], + // build action config + 'action' => [ + 'service' => [ + 'namespace' => '\App\Component\Generate\Build\Action\Service', + 'suffix' => 'ActionServiceBuild', + ], + 'controller' => [ + 'namespace' => '\App\Component\Generate\Build\Action\Controller', + 'suffix' => 'ActionControllerBuild', + ], + ], +]; + + From e4cab415c36e75d1a115900a3e6b3d78fe65ca01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sat, 16 Jan 2021 00:59:49 +0800 Subject: [PATCH 71/82] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constant/Error.php | 12 ++++++------ migrations/2020_11_15_160222_init.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Constant/Error.php b/app/Constant/Error.php index 57df9db..c511198 100644 --- a/app/Constant/Error.php +++ b/app/Constant/Error.php @@ -41,32 +41,32 @@ class Error extends BaseEnum /** * @Message("管理员删除失败") */ - const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_REMOVE_FAIL = 'B-001-006-001'; + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_REMOVE_FAIL = 'B-001-007-001'; /** * @Message("管理员创建失败") */ - const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_CREATE_FAIL = 'B-001-006-002'; + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_CREATE_FAIL = 'B-001-007-002'; /** * @Message("管理员导入失败") */ - const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_IMPORT_FAIL = 'B-001-006-003'; + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_IMPORT_FAIL = 'B-001-007-003'; /** * @Message("管理员导出失败") */ - const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_EXPORT_FAIL = 'B-001-006-004'; + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_EXPORT_FAIL = 'B-001-007-004'; /** * @Message("管理员不存在") */ - const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_NOT_FOUND = 'B-001-006-005'; + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_NOT_FOUND = 'B-001-007-005'; /** * @Message("管理员更新失败") */ - const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_UPDATE_FAIL = 'B-001-006-006'; + const ERROR_TEST_ADMINERROR_ERRORS_TEST_ADMIN_UPDATE_FAIL = 'B-001-007-006'; /** * @Message("错误字典生成文件失败") diff --git a/migrations/2020_11_15_160222_init.php b/migrations/2020_11_15_160222_init.php index 736c30a..8769c4b 100644 --- a/migrations/2020_11_15_160222_init.php +++ b/migrations/2020_11_15_160222_init.php @@ -4,7 +4,7 @@ use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -class CreateAdminTable extends Migration +class Init extends Migration { /** * Run the migrations. From 1bb4ab8c0bcdea818adc11e66b526f97a608a23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sat, 16 Jan 2021 01:04:35 +0800 Subject: [PATCH 72/82] fix bug --- app/Component/Generate/Build/ControllerBuild.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/Component/Generate/Build/ControllerBuild.php b/app/Component/Generate/Build/ControllerBuild.php index 81023a1..4357ea3 100644 --- a/app/Component/Generate/Build/ControllerBuild.php +++ b/app/Component/Generate/Build/ControllerBuild.php @@ -75,14 +75,10 @@ protected function getActionService(string $name, array $form, string $descripti } // path - $paths = [ - $this->getConfig()->getController()->getPrefix(), - ]; $directory = str_replace($this->getConfig()->getDefault()->getController()->getPath(), '', $this->getGenerateCodeEntity()->getController()); $controllerPath = StringHelper::dirname($directory); - if ($controllerPath !== '/') { - $paths[] = $controllerPath; - } + $paths = StringHelper::explode($controllerPath, '/', true, true); + array_unshift($paths, $this->getConfig()->getController()->getPrefix()); $paths[] = StringHelper::basename($directory, 'Controller'); $paths[] = $name; From ba2f52af116880c4c4a77b6137099045ee3ed7f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sun, 24 Jan 2021 00:39:49 +0800 Subject: [PATCH 73/82] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=20-?= =?UTF-8?q?=20=E7=BC=BA=E5=A4=B1=20=E5=89=8D=E7=AB=AF=20=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=EF=BC=8C=E5=8F=AF=E4=BB=A5=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Generate/Build/Action/BaseActionBuild.php | 61 ++++++ .../DefaultActionControllerBuild.php | 4 +- .../DetailActionControllerBuild.php | 4 +- .../ListActionControllerBuild.php | 5 +- .../EasyswoolApidogValidateParse.php | 2 +- .../Action/Service/BaseActionServiceBuild.php | 66 +----- .../Service/ChangeActionServiceBuild.php | 29 --- .../Service/DefaultActionServiceBuild.php | 21 -- .../Hyperf/ChangeActionServiceBuild.php | 31 +++ .../{ => Hyperf}/CreateActionServiceBuild.php | 8 +- .../Hyperf/DefaultActionServiceBuild.php | 23 ++ .../{ => Hyperf}/DetailActionServiceBuild.php | 4 +- .../FindOneActionServiceBuild.php | 10 +- .../FormatModelActionServiceBuild.php | 4 +- .../{ => Hyperf}/ListActionServiceBuild.php | 7 +- .../{ => Hyperf}/RemoveActionServiceBuild.php | 8 +- .../{ => Hyperf}/UpdateActionServiceBuild.php | 8 +- app/Component/Generate/Build/BaseBuild.php | 14 +- app/Component/Generate/Build/BuildClass.php | 207 ------------------ .../Build/Collection/BaseBuildCollection.php | 80 +++++++ .../Collection/ControllerBuildCollection.php | 30 +++ .../Collection/ErrorCodeBuildCollection.php | 42 ++++ .../Build/Collection/ModelBuildCollection.php | 30 +++ .../Generate/Build/ControllerBuild.php | 70 +++--- .../Generate/Build/ErrorCodeBuild.php | 49 +++-- .../Build/Model/Hyperf/ModelBuild.php | 21 ++ .../Generate/Build/Model/HyperfModelBuild.php | 71 ------ app/Component/Generate/Build/ServiceBuild.php | 49 +++-- app/Component/Generate/Generate.php | 12 +- .../Admin/V1/Admin/AdminController.php | 2 +- .../Admin/V1/System/MenuController.php | 2 +- .../Admin/V1/System/RoleController.php | 2 +- app/Service/Admin/AdminService.php | 2 +- app/Service/System/GenerateService.php | 42 ++-- app/Service/System/Manager/MenuService.php | 2 +- app/Service/System/Manager/RoleService.php | 2 +- config/autoload/genCode.php | 11 +- 37 files changed, 527 insertions(+), 508 deletions(-) rename app/Component/Generate/Build/Action/Controller/{ => Hyperf}/DefaultActionControllerBuild.php (78%) rename app/Component/Generate/Build/Action/Controller/{ => Hyperf}/DetailActionControllerBuild.php (80%) rename app/Component/Generate/Build/Action/Controller/{ => Hyperf}/ListActionControllerBuild.php (80%) delete mode 100644 app/Component/Generate/Build/Action/Service/ChangeActionServiceBuild.php delete mode 100644 app/Component/Generate/Build/Action/Service/DefaultActionServiceBuild.php create mode 100644 app/Component/Generate/Build/Action/Service/Hyperf/ChangeActionServiceBuild.php rename app/Component/Generate/Build/Action/Service/{ => Hyperf}/CreateActionServiceBuild.php (59%) create mode 100644 app/Component/Generate/Build/Action/Service/Hyperf/DefaultActionServiceBuild.php rename app/Component/Generate/Build/Action/Service/{ => Hyperf}/DetailActionServiceBuild.php (81%) rename app/Component/Generate/Build/Action/Service/{ => Hyperf}/FindOneActionServiceBuild.php (60%) rename app/Component/Generate/Build/Action/Service/{ => Hyperf}/FormatModelActionServiceBuild.php (82%) rename app/Component/Generate/Build/Action/Service/{ => Hyperf}/ListActionServiceBuild.php (81%) rename app/Component/Generate/Build/Action/Service/{ => Hyperf}/RemoveActionServiceBuild.php (50%) rename app/Component/Generate/Build/Action/Service/{ => Hyperf}/UpdateActionServiceBuild.php (64%) delete mode 100644 app/Component/Generate/Build/BuildClass.php create mode 100644 app/Component/Generate/Build/Collection/BaseBuildCollection.php create mode 100644 app/Component/Generate/Build/Collection/ControllerBuildCollection.php create mode 100644 app/Component/Generate/Build/Collection/ErrorCodeBuildCollection.php create mode 100644 app/Component/Generate/Build/Collection/ModelBuildCollection.php create mode 100644 app/Component/Generate/Build/Model/Hyperf/ModelBuild.php delete mode 100644 app/Component/Generate/Build/Model/HyperfModelBuild.php diff --git a/app/Component/Generate/Build/Action/BaseActionBuild.php b/app/Component/Generate/Build/Action/BaseActionBuild.php index ff7f8ef..3248f14 100644 --- a/app/Component/Generate/Build/Action/BaseActionBuild.php +++ b/app/Component/Generate/Build/Action/BaseActionBuild.php @@ -2,6 +2,8 @@ namespace App\Component\Generate\Build\Action; +use App\Component\Generate\Build\Collection\ErrorCodeBuildCollection; + abstract class BaseActionBuild { /** @@ -56,11 +58,51 @@ public function getSpaces(int $level = 1): string return str_repeat(' ', $level * 4); } + /** + * @param string $name + * @param int $level + * + * @return string + */ + public function throwExceptionForError(string $name, int $level = 1): string + { + return $this->getSpaces($level) . "throw new {$this->getExceptionName()}({$this->getError()->getClassname()}::{$this->getError()->getConstant($name)});"; + } + /** * @var string */ protected $name; + /** + * @var string + */ + protected $exceptionName; + + /** + * @var ErrorCodeBuildCollection + */ + protected $error; + + /** + * @return ErrorCodeBuildCollection + */ + public function getError(): ErrorCodeBuildCollection + { + return $this->error; + } + + /** + * @param ErrorCodeBuildCollection $error + * + * @return BaseActionBuild + */ + public function setError(ErrorCodeBuildCollection $error): BaseActionBuild + { + $this->error = $error; + return $this; + } + /** * @return string */ @@ -79,4 +121,23 @@ public function setName(string $name): BaseActionBuild $this->name = $name; return $this; } + + /** + * @return string + */ + public function getExceptionName(): string + { + return $this->exceptionName; + } + + /** + * @param string $exceptionName + * + * @return BaseActionBuild + */ + public function setExceptionName(string $exceptionName): BaseActionBuild + { + $this->exceptionName = $exceptionName; + return $this; + } } diff --git a/app/Component/Generate/Build/Action/Controller/DefaultActionControllerBuild.php b/app/Component/Generate/Build/Action/Controller/Hyperf/DefaultActionControllerBuild.php similarity index 78% rename from app/Component/Generate/Build/Action/Controller/DefaultActionControllerBuild.php rename to app/Component/Generate/Build/Action/Controller/Hyperf/DefaultActionControllerBuild.php index 1917f6c..b3eaff2 100644 --- a/app/Component/Generate/Build/Action/Controller/DefaultActionControllerBuild.php +++ b/app/Component/Generate/Build/Action/Controller/Hyperf/DefaultActionControllerBuild.php @@ -1,6 +1,8 @@ getDescription() + $this->getDescription(), ]; } /** - * @var array - */ - protected $errors; - - /** - * @var array + * @var ModelBuildCollection */ protected $model; - /** - * @var string - */ - protected $exceptionName; - /** * @var string */ protected $description; /** - * @return array - */ - public function getErrors(): array - { - return $this->errors; - } - - /** - * @param array $errors - * - * @return BaseActionServiceBuild + * @return ModelBuildCollection */ - public function setErrors(array $errors): BaseActionServiceBuild - { - $this->errors = $errors; - return $this; - } - - /** - * @return array - */ - public function getModel(): array + public function getModel(): ModelBuildCollection { return $this->model; } /** - * @param array $model + * @param ModelBuildCollection $model * * @return BaseActionServiceBuild */ - public function setModel(array $model): BaseActionServiceBuild + public function setModel(ModelBuildCollection $model): BaseActionServiceBuild { $this->model = $model; return $this; } - /** - * @return string - */ - public function getExceptionName(): string - { - return $this->exceptionName; - } - - /** - * @param string $exceptionName - * - * @return BaseActionServiceBuild - */ - public function setExceptionName(string $exceptionName): BaseActionServiceBuild - { - $this->exceptionName = $exceptionName; - return $this; - } - /** * @return string */ @@ -114,9 +66,9 @@ public function getDescription(): string /** * @param string $description * - * @return BaseActionBuild + * @return BaseActionServiceBuild */ - public function setDescription(string $description): BaseActionBuild + public function setDescription(string $description): BaseActionServiceBuild { $this->description = $description; return $this; diff --git a/app/Component/Generate/Build/Action/Service/ChangeActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/ChangeActionServiceBuild.php deleted file mode 100644 index 91c46a0..0000000 --- a/app/Component/Generate/Build/Action/Service/ChangeActionServiceBuild.php +++ /dev/null @@ -1,29 +0,0 @@ -getModel()['primaryKey']; - return [ - "\$where = ['{$primaryKey}' => \$params['{$primaryKey}']];", - "unset(\$params['{$primaryKey}']);", - "\$models = {$this->getModel()['classname']}::findAllCondition(\$where);", - "if (count(\$models) !== count(\$params['{$primaryKey}'])) {", - $this->getSpaces() . "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant']['notFound']});", - '}', - "\$status = {$this->getModel()['classname']}::updateCondition(\$where, \$params);", - 'if (!$status) {', - $this->getSpaces() . "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant']['update']});", - '}', - 'return $status;', - ]; - } - - public function getReturn(): string - { - return 'int'; - } -} diff --git a/app/Component/Generate/Build/Action/Service/DefaultActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/DefaultActionServiceBuild.php deleted file mode 100644 index 98f2e89..0000000 --- a/app/Component/Generate/Build/Action/Service/DefaultActionServiceBuild.php +++ /dev/null @@ -1,21 +0,0 @@ -getErrors()['constant'][$this->getName()])) { - return []; - } - return [ - "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant'][$this->getName()]});", - ]; - } - - public function getReturn(): string - { - return 'array'; - } -} diff --git a/app/Component/Generate/Build/Action/Service/Hyperf/ChangeActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/ChangeActionServiceBuild.php new file mode 100644 index 0000000..16ca518 --- /dev/null +++ b/app/Component/Generate/Build/Action/Service/Hyperf/ChangeActionServiceBuild.php @@ -0,0 +1,31 @@ +getModel()->getPrimaryKey(); + return [ + "\$where = ['{$primaryKey}' => \$params['{$primaryKey}']];", + "unset(\$params['{$primaryKey}']);", + "\$models = {$this->getModel()->getClassname()}::findAllCondition(\$where);", + "if (count(\$models) !== count(\$params['{$primaryKey}'])) {", + $this->throwExceptionForError('notFound'), + '}', + "\$status = {$this->getModel()->getClassname()}::updateCondition(\$where, \$params);", + 'if (!$status) {', + $this->throwExceptionForError('update'), + '}', + 'return $status;', + ]; + } + + public function getReturn(): string + { + return 'int'; + } +} diff --git a/app/Component/Generate/Build/Action/Service/CreateActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/CreateActionServiceBuild.php similarity index 59% rename from app/Component/Generate/Build/Action/Service/CreateActionServiceBuild.php rename to app/Component/Generate/Build/Action/Service/Hyperf/CreateActionServiceBuild.php index 1b7ef7c..503657c 100644 --- a/app/Component/Generate/Build/Action/Service/CreateActionServiceBuild.php +++ b/app/Component/Generate/Build/Action/Service/Hyperf/CreateActionServiceBuild.php @@ -1,6 +1,8 @@ getModel()['classname']}();", + "\$model = new {$this->getModel()->getClassname()}();", '$status = $model->insert($params);', 'if (!$status) {', - $this->getSpaces() . "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant']['create']});", + $this->throwExceptionForError($this->getName()), '}', 'return $model->toArray();', ]; diff --git a/app/Component/Generate/Build/Action/Service/Hyperf/DefaultActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/DefaultActionServiceBuild.php new file mode 100644 index 0000000..07ee795 --- /dev/null +++ b/app/Component/Generate/Build/Action/Service/Hyperf/DefaultActionServiceBuild.php @@ -0,0 +1,23 @@ +getError()->getConstant($this->getName()))) { + return []; + } + return [ + $this->throwExceptionForError($this->getName()), + ]; + } + + public function getReturn(): string + { + return 'array'; + } +} diff --git a/app/Component/Generate/Build/Action/Service/DetailActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/DetailActionServiceBuild.php similarity index 81% rename from app/Component/Generate/Build/Action/Service/DetailActionServiceBuild.php rename to app/Component/Generate/Build/Action/Service/Hyperf/DetailActionServiceBuild.php index 56017f8..d406fbb 100644 --- a/app/Component/Generate/Build/Action/Service/DetailActionServiceBuild.php +++ b/app/Component/Generate/Build/Action/Service/Hyperf/DetailActionServiceBuild.php @@ -1,6 +1,8 @@ getModel()['classname']}::findOneCondition(\$params, \$field);", + "\$model = {$this->getModel()->getClassname()}::findOneCondition(\$params, \$field);", 'if (!$model) {', - $this->getSpaces() . "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant']['notFound']});", + $this->throwExceptionForError('notFound'), '}', 'return $model;', ]; @@ -25,6 +27,6 @@ public function getParams(): array public function getReturn(): string { - return $this->getModel()['classname']; + return $this->getModel()->getClassname(); } } diff --git a/app/Component/Generate/Build/Action/Service/FormatModelActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/FormatModelActionServiceBuild.php similarity index 82% rename from app/Component/Generate/Build/Action/Service/FormatModelActionServiceBuild.php rename to app/Component/Generate/Build/Action/Service/Hyperf/FormatModelActionServiceBuild.php index cb8c68c..2184098 100644 --- a/app/Component/Generate/Build/Action/Service/FormatModelActionServiceBuild.php +++ b/app/Component/Generate/Build/Action/Service/Hyperf/FormatModelActionServiceBuild.php @@ -1,6 +1,8 @@ getModel()['classname']}::query();", + "\$query = {$this->getModel()->getClassname()}::query();", '$query->select($field);', "\$query->where(['enable' => SoftDeleted::ENABLE]);", ]; diff --git a/app/Component/Generate/Build/Action/Service/RemoveActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/RemoveActionServiceBuild.php similarity index 50% rename from app/Component/Generate/Build/Action/Service/RemoveActionServiceBuild.php rename to app/Component/Generate/Build/Action/Service/Hyperf/RemoveActionServiceBuild.php index 56e8a03..e568a66 100644 --- a/app/Component/Generate/Build/Action/Service/RemoveActionServiceBuild.php +++ b/app/Component/Generate/Build/Action/Service/Hyperf/RemoveActionServiceBuild.php @@ -1,6 +1,8 @@ getModel()['classname']}::softDeleteCondition(\$params);", + "\$status = {$this->getModel()->getClassname()}::softDeleteCondition(\$params);", 'if (!$status) {', - $this->getSpaces() . "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant']['remove']});", + $this->throwExceptionForError($this->getName()), '}', 'return $status;', ]; diff --git a/app/Component/Generate/Build/Action/Service/UpdateActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/UpdateActionServiceBuild.php similarity index 64% rename from app/Component/Generate/Build/Action/Service/UpdateActionServiceBuild.php rename to app/Component/Generate/Build/Action/Service/Hyperf/UpdateActionServiceBuild.php index 0831201..a76a3c3 100644 --- a/app/Component/Generate/Build/Action/Service/UpdateActionServiceBuild.php +++ b/app/Component/Generate/Build/Action/Service/Hyperf/UpdateActionServiceBuild.php @@ -1,18 +1,20 @@ getModel()['primaryKey']; + $primaryKey = $this->getModel()->getPrimaryKey(); return [ "\$model = \$this->findOne(['{$primaryKey}' => \$params['{$primaryKey}']]);", '$status = $model->update($params);', 'if (!$status) {', - $this->getSpaces() . "throw new {$this->getExceptionName()}({$this->getErrors()['classname']}::{$this->getErrors()['constant']['update']});", + $this->throwExceptionForError($this->getName()), '}', 'return $model->toArray();', ]; diff --git a/app/Component/Generate/Build/BaseBuild.php b/app/Component/Generate/Build/BaseBuild.php index 1f08827..e55d458 100644 --- a/app/Component/Generate/Build/BaseBuild.php +++ b/app/Component/Generate/Build/BaseBuild.php @@ -6,6 +6,7 @@ use App\Component\Generate\ClassFile\ClassConfig; use App\Component\Generate\Generate; use App\Entity\GenerateCodeEntity; +use Exception; use Lengbin\Common\Component\BaseObject; use Lengbin\Helper\YiiSoft\StringHelper; @@ -65,16 +66,17 @@ public function setGenerateCodeEntity(GenerateCodeEntity $generateCodeEntity): B } /** - * @param array $params - * @param string $path + * @param ClassConfig $config + * @param string $path * - * @return bool + * @return string + * @throws Exception */ - protected function output(array $params, string $path): bool + protected function output(ClassConfig $config, string $path): string { $generate = new Generate(); $generate->setPath($this->getRoot() . '/' . $path); - $generate->setConfig(new ClassConfig($params)); + $generate->setConfig($config); return $generate->output('php'); } @@ -109,5 +111,5 @@ public function setRoot(string $root): BaseBuild return $this; } - abstract public function build(): array; + abstract public function build(); } diff --git a/app/Component/Generate/Build/BuildClass.php b/app/Component/Generate/Build/BuildClass.php deleted file mode 100644 index 403ad11..0000000 --- a/app/Component/Generate/Build/BuildClass.php +++ /dev/null @@ -1,207 +0,0 @@ -setRoot($this->getRoot())->setConfig($this->getConfig())->setGenerateCodeEntity($this->getGenerateCodeEntity()); - } - - /** - * @return BaseBuild - */ - public function getModel(): BaseBuild - { - return $this->model; - } - - /** - * @param BaseBuild $model - * - * @return BuildClass - */ - public function setModel(BaseBuild $model): BuildClass - { - $this->model = $model; - return $this; - } - - /** - * @return ServiceBuild - */ - public function getService(): ServiceBuild - { - return $this->init($this->service); - } - - /** - * @param ServiceBuild $service - * - * @return BuildClass - */ - public function setService(ServiceBuild $service): BuildClass - { - $this->service = $service; - return $this; - } - - /** - * @return ErrorCodeBuild - */ - public function getErrorCode(): ErrorCodeBuild - { - return $this->init($this->errorCode); - } - - /** - * @param ErrorCodeBuild $errorCode - * - * @return BuildClass - */ - public function setErrorCode(ErrorCodeBuild $errorCode): BuildClass - { - $this->errorCode = $errorCode; - return $this; - } - - /** - * @return ControllerBuild - */ - public function getController(): ControllerBuild - { - return $this->init($this->controller); - } - - /** - * @param ControllerBuild $controller - * - * @return BuildClass - */ - public function setController(ControllerBuild $controller): BuildClass - { - $this->controller = $controller; - return $this; - } - - /** - * @return BuildConfig - */ - public function getConfig(): BuildConfig - { - return $this->config; - } - - /** - * @param BuildConfig $config - * - * @return BuildClass - */ - public function setConfig(BuildConfig $config): BuildClass - { - $this->config = $config; - return $this; - } - - /** - * @return GenerateCodeEntity - */ - public function getGenerateCodeEntity(): GenerateCodeEntity - { - return $this->generateCodeEntity; - } - - /** - * @param GenerateCodeEntity $generateCodeEntity - * - * @return BuildClass - */ - public function setGenerateCodeEntity(GenerateCodeEntity $generateCodeEntity): BuildClass - { - $this->generateCodeEntity = $generateCodeEntity; - return $this; - } - - /** - * @return string - */ - public function getRoot(): string - { - return $this->root; - } - - /** - * @param string $root - * - * @return BuildClass - */ - public function setRoot(string $root): BuildClass - { - $this->root = $root; - return $this; - } - - public function run(): array - { - $model = $this->getModel()->build(); - $errorCode = $this->getErrorCode()->setModelName($model['classname'])->build(); - $service = $this->getService()->setModel($model)->setErrorCode($errorCode)->build(); - $controller = $this->getController()->setService($service)->build(); - return [ - 'file' => array_map(function ($file) { - return $this->getRoot() . '/' . $file . '.php'; - }, [ - 'model' => $this->generateCodeEntity->getModel(), - 'service' => $this->generateCodeEntity->getService(), - 'controller' => $this->getGenerateCodeEntity()->getController(), - 'errorCode' => $errorCode['path'], - ]), - 'path' => $controller, - ]; - } -} diff --git a/app/Component/Generate/Build/Collection/BaseBuildCollection.php b/app/Component/Generate/Build/Collection/BaseBuildCollection.php new file mode 100644 index 0000000..05cd819 --- /dev/null +++ b/app/Component/Generate/Build/Collection/BaseBuildCollection.php @@ -0,0 +1,80 @@ +class; + } + + /** + * @param string $class + * + * @return BaseBuildCollection + */ + public function setClass(string $class): BaseBuildCollection + { + $this->class = $class; + return $this; + } + + /** + * @return string + */ + public function getClassname(): string + { + return $this->classname; + } + + /** + * @param string $classname + * + * @return BaseBuildCollection + */ + public function setClassname(string $classname): BaseBuildCollection + { + $this->classname = $classname; + return $this; + } + + /** + * @return string + */ + public function getFile(): string + { + return $this->file; + } + + /** + * @param string $file + * + * @return BaseBuildCollection + */ + public function setFile(string $file): BaseBuildCollection + { + $this->file = $file; + return $this; + } +} diff --git a/app/Component/Generate/Build/Collection/ControllerBuildCollection.php b/app/Component/Generate/Build/Collection/ControllerBuildCollection.php new file mode 100644 index 0000000..39fac6a --- /dev/null +++ b/app/Component/Generate/Build/Collection/ControllerBuildCollection.php @@ -0,0 +1,30 @@ +rout; + } + + /** + * @param array $rout + * + * @return ControllerBuildCollection + */ + public function setRout(array $rout): ControllerBuildCollection + { + $this->rout = $rout; + return $this; + } +} diff --git a/app/Component/Generate/Build/Collection/ErrorCodeBuildCollection.php b/app/Component/Generate/Build/Collection/ErrorCodeBuildCollection.php new file mode 100644 index 0000000..0a9fc69 --- /dev/null +++ b/app/Component/Generate/Build/Collection/ErrorCodeBuildCollection.php @@ -0,0 +1,42 @@ +constants; + } + + /** + * @param array $constants + * + * @return ErrorCodeBuildCollection + */ + public function setConstants(array $constants): ErrorCodeBuildCollection + { + $this->constants = $constants; + return $this; + } + + /** + * @param string $path + * + * @return string + */ + public function getConstant(string $path): string + { + return ArrayHelper::get($this->getConstants(), $path); + } +} diff --git a/app/Component/Generate/Build/Collection/ModelBuildCollection.php b/app/Component/Generate/Build/Collection/ModelBuildCollection.php new file mode 100644 index 0000000..17c784b --- /dev/null +++ b/app/Component/Generate/Build/Collection/ModelBuildCollection.php @@ -0,0 +1,30 @@ +primaryKey; + } + + /** + * @param string $primaryKey + * + * @return ModelBuildCollection + */ + public function setPrimaryKey(string $primaryKey): ModelBuildCollection + { + $this->primaryKey = $primaryKey; + return $this; + } +} diff --git a/app/Component/Generate/Build/ControllerBuild.php b/app/Component/Generate/Build/ControllerBuild.php index 4357ea3..ea64af2 100644 --- a/app/Component/Generate/Build/ControllerBuild.php +++ b/app/Component/Generate/Build/ControllerBuild.php @@ -4,56 +4,61 @@ use App\Component\Generate\Build\Action\Controller\BaseActionControllerBuild; use App\Component\Generate\Build\Action\Controller\ValidateParse\BaseValidateParse; +use App\Component\Generate\Build\Collection\BaseBuildCollection; +use App\Component\Generate\Build\Collection\ControllerBuildCollection; +use App\Component\Generate\Build\Collection\ErrorCodeBuildCollection; +use App\Component\Generate\ClassFile\ClassConfig; +use Exception; use Lengbin\Helper\YiiSoft\Arrays\ArrayHelper; use Lengbin\Helper\YiiSoft\StringHelper; class ControllerBuild extends BaseBuild { /** - * @var array + * @var BaseBuildCollection */ private $service; /** - * @var string + * @var ErrorCodeBuildCollection */ - private $serviceName; + private $errorCode; /** - * @return array + * @return BaseBuildCollection */ - public function getService(): array + public function getService(): BaseBuildCollection { return $this->service; } /** - * @param array $service - * - * @return ControllerBuild + * @return ErrorCodeBuildCollection */ - public function setService(array $service): ControllerBuild + public function getErrorCode(): ErrorCodeBuildCollection { - $this->service = $service; - return $this; + return $this->errorCode; } /** - * @return string + * @param ErrorCodeBuildCollection $errorCode + * + * @return ControllerBuild */ - public function getServiceName(): string + public function setErrorCode(ErrorCodeBuildCollection $errorCode): ControllerBuild { - return $this->serviceName; + $this->errorCode = $errorCode; + return $this; } /** - * @param string $serviceName + * @param BaseBuildCollection $service * * @return ControllerBuild */ - public function setServiceName(string $serviceName): ControllerBuild + public function setService(BaseBuildCollection $service): ControllerBuild { - $this->serviceName = $serviceName; + $this->service = $service; return $this; } @@ -78,7 +83,10 @@ protected function getActionService(string $name, array $form, string $descripti $directory = str_replace($this->getConfig()->getDefault()->getController()->getPath(), '', $this->getGenerateCodeEntity()->getController()); $controllerPath = StringHelper::dirname($directory); $paths = StringHelper::explode($controllerPath, '/', true, true); - array_unshift($paths, $this->getConfig()->getController()->getPrefix()); + $prefix = $this->getConfig()->getController()->getPrefix(); + if (!StringHelper::isEmpty($prefix)) { + array_unshift($paths, $prefix); + } $paths[] = StringHelper::basename($directory, 'Controller'); $paths[] = $name; @@ -95,16 +103,23 @@ protected function getActionService(string $name, array $form, string $descripti * @var BaseActionControllerBuild $model */ $model = new $classname; - $model->setName($name)->setValidateParse($parse)->setServiceName($this->getServiceName()); + $model->setName($name) + ->setValidateParse($parse) + ->setError($this->getErrorCode()) + ->setExceptionName($this->getConfig()->getException()->getInheritance()) + ->setServiceName(lcfirst($this->getService()->getClassname())); return [$model->getMethod(), $model->getUses(), $parse->getPath()]; } - public function build(): array + /** + * @return ControllerBuildCollection + * @throws Exception + */ + public function build(): ControllerBuildCollection { - $this->setServiceName(lcfirst($this->getService()['classname'])); $properties = call_user_func($this->getConfig()->getController()->getProperties(), $this); $uses = $this->getConfig()->getController()->getUses(); - $uses[] = $this->getService()['class']; + $uses[] = $this->getService()->getClass(); $routs = $methods = $actions = []; // todo 如果有 查询 则有 list @@ -136,7 +151,7 @@ public function build(): array "@package {$namespace}", ]; $comment = ArrayHelper::merge($comment, call_user_func($this->getConfig()->getController()->getComment(), $this)); - $params = [ + $config = [ 'namespace' => $namespace, 'classname' => $classname, 'uses' => $uses, @@ -145,7 +160,12 @@ public function build(): array 'properties' => $properties, 'methods' => $methods, ]; - $this->output($params, StringHelper::dirname($this->getGenerateCodeEntity()->getController())); - return $routs; + $file = $this->output(new ClassConfig($config), StringHelper::dirname($this->getGenerateCodeEntity()->getController())); + return new ControllerBuildCollection([ + 'classname' => $classname, + 'class' => $class, + 'rout' => $routs, + 'file' => $file, + ]); } } diff --git a/app/Component/Generate/Build/ErrorCodeBuild.php b/app/Component/Generate/Build/ErrorCodeBuild.php index e09d8d1..a7d838d 100644 --- a/app/Component/Generate/Build/ErrorCodeBuild.php +++ b/app/Component/Generate/Build/ErrorCodeBuild.php @@ -2,6 +2,11 @@ namespace App\Component\Generate\Build; +use App\Component\Generate\Build\Collection\BaseBuildCollection; +use App\Component\Generate\Build\Collection\ErrorCodeBuildCollection; +use App\Component\Generate\Build\Collection\ModelBuildCollection; +use App\Component\Generate\ClassFile\ClassConfig; +use Exception; use Lengbin\Helper\Util\FileHelper; use Lengbin\Helper\YiiSoft\Arrays\ArrayHelper; use Lengbin\Helper\YiiSoft\StringHelper; @@ -22,27 +27,26 @@ class ErrorCodeBuild extends BaseBuild ]; /** - * 表名 - * @var string + * @var ModelBuildCollection */ - private $modelName; + private $model; /** - * @return string + * @return ModelBuildCollection */ - public function getModelName(): string + public function getModel(): ModelBuildCollection { - return $this->modelName; + return $this->model; } /** - * @param string $modelName + * @param ModelBuildCollection $model * * @return ErrorCodeBuild */ - public function setModelName(string $modelName): ErrorCodeBuild + public function setModel(ModelBuildCollection $model): ErrorCodeBuild { - $this->modelName = $modelName; + $this->model = $model; return $this; } @@ -52,7 +56,7 @@ public function setModelName(string $modelName): ErrorCodeBuild */ protected function getName(): string { - return $this->getModelName() . 'Error'; + return $this->getModel()->getClassname() . 'Error'; } /** @@ -79,7 +83,7 @@ protected function getPrefix(string $path): array $scan = FileHelper::scan($this->getRoot() . '/' . $defaultPath); $number = iterator_count($scan) + 1; $prefix .= '-' . str_pad($number, 3, "0", STR_PAD_LEFT); - $errorPrefix[] = $this->getModelName(); + $errorPrefix[] = $this->getModel()->getClassname(); array_unshift($errorPrefix, 'errors'); return [ 'value' => $prefix, @@ -128,6 +132,7 @@ protected function getConstant(string $path): array ], ]; + // 修改的 归于 更新 if ($isChange && empty($constants['update'])) { $num++; $constants['update'] = [ @@ -142,7 +147,11 @@ protected function getConstant(string $path): array return $constants; } - public function build(): array + /** + * @return ErrorCodeBuildCollection + * @throws Exception + */ + public function build(): ErrorCodeBuildCollection { $defaultConfig = $this->getConfig()->getDefault(); // 错误码 目录结构 基于 服务目录结构 @@ -154,11 +163,11 @@ public function build(): array $class = $this->getNamespace($path . '/' . $this->getName()); $namespace = StringHelper::dirname($class); - $params = [ + $config = [ 'namespace' => $namespace, 'classname' => $this->getName(), 'uses' => [ - $this->getConfig()->getErrorCode()->getUse() + $this->getConfig()->getErrorCode()->getUse(), ], 'comments' => [ "class {$this->getName()}", @@ -167,14 +176,12 @@ public function build(): array 'inheritance' => $this->getConfig()->getErrorCode()->getInheritance(), 'constants' => $constants, ]; - $this->output($params, $path); - return [ + $file = $this->output(new ClassConfig($config), $path); + return new ErrorCodeBuildCollection([ 'classname' => $this->getName(), 'class' => $class, - 'path' => $path . '/' . $this->getName(), - 'constant' => array_map(function ($constant) { - return $constant['name']; - }, $constants), - ]; + 'file' => $file, + 'constants' => ArrayHelper::getColumn($constants, 'name'), + ]); } } diff --git a/app/Component/Generate/Build/Model/Hyperf/ModelBuild.php b/app/Component/Generate/Build/Model/Hyperf/ModelBuild.php new file mode 100644 index 0000000..f41a702 --- /dev/null +++ b/app/Component/Generate/Build/Model/Hyperf/ModelBuild.php @@ -0,0 +1,21 @@ +getNamespace($this->getGenerateCodeEntity()->getModel()); + $table = StringHelper::basename($class); + $model = new GenerateModel(); + $data = $model->create($table, $this->getGenerateCodeEntity()->getPool(), StringHelper::dirname($this->getGenerateCodeEntity()->getModel())); + return new ModelBuildCollection($data[$table]); + } +} diff --git a/app/Component/Generate/Build/Model/HyperfModelBuild.php b/app/Component/Generate/Build/Model/HyperfModelBuild.php deleted file mode 100644 index 2d5298c..0000000 --- a/app/Component/Generate/Build/Model/HyperfModelBuild.php +++ /dev/null @@ -1,71 +0,0 @@ -path; - } - - /** - * @param string $path - * - * @return HyperfModelBuild - */ - public function setPath(string $path): HyperfModelBuild - { - $this->path = $path; - return $this; - } - - /** - * @return string - */ - public function getPool(): string - { - return $this->pool; - } - - /** - * @param string $pool - * - * @return HyperfModelBuild - */ - public function setPool(string $pool): HyperfModelBuild - { - $this->pool = $pool; - return $this; - } - - public function build(): array - { - $class = $this->getNamespace($this->getPath()); - $table = StringHelper::basename($class); - $model = new GenerateModel(); - $data = $model->create($table, $this->getPool(), StringHelper::dirname($this->getPath())); - return [ - 'classname' => $table, - 'class' => $class, - 'primaryKey' => $data[$table], - ]; - } -} diff --git a/app/Component/Generate/Build/ServiceBuild.php b/app/Component/Generate/Build/ServiceBuild.php index 2c8333f..1a9efe2 100644 --- a/app/Component/Generate/Build/ServiceBuild.php +++ b/app/Component/Generate/Build/ServiceBuild.php @@ -3,54 +3,58 @@ namespace App\Component\Generate\Build; use App\Component\Generate\Build\Action\Service\BaseActionServiceBuild; +use App\Component\Generate\Build\Collection\BaseBuildCollection; +use App\Component\Generate\Build\Collection\ErrorCodeBuildCollection; +use App\Component\Generate\Build\Collection\ModelBuildCollection; +use App\Component\Generate\ClassFile\ClassConfig; use Lengbin\Helper\YiiSoft\Arrays\ArrayHelper; use Lengbin\Helper\YiiSoft\StringHelper; class ServiceBuild extends BaseBuild { /** - * @var array + * @var ErrorCodeBuildCollection */ private $errorCode; /** - * @var array + * @var ModelBuildCollection */ private $model; /** - * @return array + * @return ErrorCodeBuildCollection */ - public function getErrorCode(): array + public function getErrorCode(): ErrorCodeBuildCollection { return $this->errorCode; } /** - * @param array $errorCode + * @param ErrorCodeBuildCollection $errorCode * * @return ServiceBuild */ - public function setErrorCode(array $errorCode): ServiceBuild + public function setErrorCode(ErrorCodeBuildCollection $errorCode): ServiceBuild { $this->errorCode = $errorCode; return $this; } /** - * @return array + * @return ModelBuildCollection */ - public function getModel(): array + public function getModel(): ModelBuildCollection { return $this->model; } /** - * @param array $model + * @param ModelBuildCollection $model * * @return ServiceBuild */ - public function setModel(array $model): ServiceBuild + public function setModel(ModelBuildCollection $model): ServiceBuild { $this->model = $model; return $this; @@ -84,18 +88,22 @@ protected function getActionService(string $name, string $description = ''): arr */ $model = new $classname; $model->setModel($this->getModel()) - ->setErrors($this->getErrorCode()) + ->setError($this->getErrorCode()) ->setName($actionName) - ->setDescription($description) - ->setExceptionName($this->getConfig()->getException()->getInheritance()); + ->setExceptionName($this->getConfig()->getException()->getInheritance()) + ->setDescription($description); return [$model->getMethod(), $model->getUses()]; } - public function build(): array + /** + * @return BaseBuildCollection + * @throws \Exception + */ + public function build(): BaseBuildCollection { $uses = [ - $this->getModel()['class'], - $this->getErrorCode()['class'], + $this->getModel()->getClass(), + $this->getErrorCode()->getClass(), $this->getConfig()->getException()->getUse(), $this->getConfig()->getService()->getUse(), ]; @@ -136,7 +144,7 @@ public function build(): array $class = $this->getNamespace($this->getGenerateCodeEntity()->getService()); $classname = StringHelper::basename($class); $namespace = StringHelper::dirname($class); - $params = [ + $config = [ 'namespace' => $namespace, 'classname' => $classname, 'uses' => $uses, @@ -147,10 +155,11 @@ public function build(): array 'inheritance' => $this->getConfig()->getService()->getInheritance(), 'methods' => $methods, ]; - $this->output($params, StringHelper::dirname($this->getGenerateCodeEntity()->getService())); - return [ + $file = $this->output(new ClassConfig($config), StringHelper::dirname($this->getGenerateCodeEntity()->getService())); + return new BaseBuildCollection([ 'classname' => $classname, 'class' => $class, - ]; + 'file' => $file, + ]); } } diff --git a/app/Component/Generate/Generate.php b/app/Component/Generate/Generate.php index 580a680..c69e911 100644 --- a/app/Component/Generate/Generate.php +++ b/app/Component/Generate/Generate.php @@ -2,6 +2,7 @@ namespace App\Component\Generate; +use Exception; use Lengbin\Helper\Util\FileHelper; class Generate @@ -58,14 +59,19 @@ public function setConfig(AbstractConfig $config): Generate /** * @param string $suffix * - * @return bool + * @return string + * @throws Exception */ - public function output(string $suffix): bool + public function output(string $suffix): string { $file = implode(DIRECTORY_SEPARATOR, [ $this->getPath(), $this->getConfig()->getFileName(), ]) . '.' . FileHelper::getExtension($suffix); - return FileHelper::putFile($file, $this->getConfig()->getContent()); + $status = FileHelper::putFile($file, $this->getConfig()->getContent()); + if (!$status) { + throw new Exception("{$file} generate fail"); + } + return $file; } } diff --git a/app/Controller/Admin/V1/Admin/AdminController.php b/app/Controller/Admin/V1/Admin/AdminController.php index 52526a0..5614c1f 100644 --- a/app/Controller/Admin/V1/Admin/AdminController.php +++ b/app/Controller/Admin/V1/Admin/AdminController.php @@ -10,7 +10,7 @@ use Hyperf\Apidog\Annotation\Header; use Hyperf\Apidog\Annotation\PostApi; use Hyperf\Di\Annotation\Inject; -use Lengbin\Hyperf\Common\Entity\PageEntity; +use Lengbin\Common\Component\Entity\PageEntity; /** * Class AdminController diff --git a/app/Controller/Admin/V1/System/MenuController.php b/app/Controller/Admin/V1/System/MenuController.php index c40ee60..4d4c9f8 100644 --- a/app/Controller/Admin/V1/System/MenuController.php +++ b/app/Controller/Admin/V1/System/MenuController.php @@ -10,7 +10,7 @@ use Hyperf\Apidog\Annotation\Header; use Hyperf\Apidog\Annotation\PostApi; use Hyperf\Di\Annotation\Inject; -use Lengbin\Hyperf\Common\Entity\PageEntity; +use Lengbin\Common\Component\Entity\PageEntity; /** * Class MenuController diff --git a/app/Controller/Admin/V1/System/RoleController.php b/app/Controller/Admin/V1/System/RoleController.php index 9411219..673d748 100644 --- a/app/Controller/Admin/V1/System/RoleController.php +++ b/app/Controller/Admin/V1/System/RoleController.php @@ -10,7 +10,7 @@ use Hyperf\Apidog\Annotation\ApiResponse; use Hyperf\Apidog\Annotation\Body; use Hyperf\Apidog\Annotation\PostApi; -use Lengbin\Hyperf\Common\Entity\PageEntity; +use Lengbin\Common\Component\Entity\PageEntity; /** * Class RoleController diff --git a/app/Service/Admin/AdminService.php b/app/Service/Admin/AdminService.php index f9a8538..6c12bb9 100644 --- a/app/Service/Admin/AdminService.php +++ b/app/Service/Admin/AdminService.php @@ -11,7 +11,7 @@ use Hyperf\Di\Annotation\Inject; use Lengbin\Helper\Util\PasswordHelper; use Lengbin\Hyperf\Common\Constant\SoftDeleted; -use Lengbin\Hyperf\Common\Entity\PageEntity; +use Lengbin\Common\Component\Entity\PageEntity; use Lengbin\Hyperf\Common\Exception\BusinessException; use Lengbin\Hyperf\Common\Framework\BaseService; use Throwable; diff --git a/app/Service/System/GenerateService.php b/app/Service/System/GenerateService.php index 3009b1f..d449d0d 100644 --- a/app/Service/System/GenerateService.php +++ b/app/Service/System/GenerateService.php @@ -2,32 +2,44 @@ namespace App\Service\System; -use App\Component\Generate\Build\BuildClass; use App\Component\Generate\Build\Config\BuildConfig; use App\Component\Generate\Build\ControllerBuild; use App\Component\Generate\Build\ErrorCodeBuild; -use App\Component\Generate\Build\Model\HyperfModelBuild; +use App\Component\Generate\Build\Model\Hyperf\ModelBuild; use App\Component\Generate\Build\ServiceBuild; use App\Entity\GenerateCodeEntity; +use Exception; use Lengbin\Hyperf\Common\Framework\BaseService; class GenerateService extends BaseService { + /** + * @param GenerateCodeEntity $generateCodeEntity + * + * @return array + * @throws Exception + */ public function crud(GenerateCodeEntity $generateCodeEntity): array { - $config = new BuildConfig($this->config->get('genCode', [])); - $model = new HyperfModelBuild([ - 'path' => $generateCodeEntity->getModel(), - 'pool' => $generateCodeEntity->getPool(), - ]); - $build = (new BuildClass())->setGenerateCodeEntity($generateCodeEntity) - ->setRoot(BASE_PATH) - ->setConfig($config) - ->setModel($model) - ->setService(new ServiceBuild()) - ->setErrorCode(new ErrorCodeBuild()) - ->setController(new ControllerBuild()); - return $build->run(); + $params = [ + 'config' => new BuildConfig($this->config->get('genCode', [])), + 'root' => BASE_PATH, + 'generateCodeEntity' => $generateCodeEntity, + ]; + $model = (new ModelBuild($params))->build(); + $errorCode = (new ErrorCodeBuild($params))->setModel($model)->build(); + $service = (new ServiceBuild($params))->setModel($model)->setErrorCode($errorCode)->build(); + $controller = (new ControllerBuild($params))->setErrorCode($errorCode)->setService($service)->build(); + var_dump($errorCode, $service, $controller); + return [ + 'file' => [ + 'model' => $model->getFile(), + 'service' => $service->getFile(), + 'controller' => $controller->getFile(), + 'errorCode' => $errorCode->getFile(), + ], + 'rout' => $controller->getRout(), + ]; } public function html(GenerateCodeEntity $generateCodeEntity): array diff --git a/app/Service/System/Manager/MenuService.php b/app/Service/System/Manager/MenuService.php index 6be2859..5386583 100644 --- a/app/Service/System/Manager/MenuService.php +++ b/app/Service/System/Manager/MenuService.php @@ -4,7 +4,7 @@ use App\Constant\Errors\System\MenuError; use Hyperf\Di\Annotation\Inject; -use Lengbin\Hyperf\Common\Entity\PageEntity; +use Lengbin\Common\Component\Entity\PageEntity; use Lengbin\Hyperf\Common\Exception\BusinessException; use Lengbin\Hyperf\Common\Framework\BaseService; use Lengbin\YiiSoft\Rbac\ManagerInterface; diff --git a/app/Service/System/Manager/RoleService.php b/app/Service/System/Manager/RoleService.php index 96793df..a87d344 100644 --- a/app/Service/System/Manager/RoleService.php +++ b/app/Service/System/Manager/RoleService.php @@ -6,7 +6,7 @@ use Exception; use Hyperf\DbConnection\Db; use Hyperf\Di\Annotation\Inject; -use Lengbin\Hyperf\Common\Entity\PageEntity; +use Lengbin\Common\Component\Entity\PageEntity; use Lengbin\Hyperf\Common\Exception\BusinessException; use Lengbin\Hyperf\Common\Framework\BaseService; use Lengbin\YiiSoft\Rbac\Item; diff --git a/config/autoload/genCode.php b/config/autoload/genCode.php index c43a606..586f636 100644 --- a/config/autoload/genCode.php +++ b/config/autoload/genCode.php @@ -119,11 +119,12 @@ ]; }, 'properties' => function ($build) { + $serviceName = $build->getService()->getClassname(); $properties[] = [ - "name" => $build->getServiceName(), + "name" => lcfirst($serviceName), 'comments' => [ '@Inject()', - "@var {$build->getService()['classname']}", + "@var {$serviceName}", ], ]; return $properties; @@ -149,13 +150,15 @@ 'use' => 'Lengbin\Hyperf\Common\Framework\BaseService', ], // build action config + // class = (firstNamespace ? firstNamespace : namespace ). path . suffix 'action' => [ 'service' => [ - 'namespace' => '\App\Component\Generate\Build\Action\Service', + 'namespace' => '\App\Component\Generate\Build\Action\Service\Hyperf', 'suffix' => 'ActionServiceBuild', +// 'firstNamespace' ], 'controller' => [ - 'namespace' => '\App\Component\Generate\Build\Action\Controller', + 'namespace' => '\App\Component\Generate\Build\Action\Controller\Hyperf', 'suffix' => 'ActionControllerBuild', ], ], From 8353eedb189d01afb536c60f699b64658b94f74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sun, 24 Jan 2021 00:40:22 +0800 Subject: [PATCH 74/82] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=20-?= =?UTF-8?q?=20=E7=BC=BA=E5=A4=B1=20=E5=89=8D=E7=AB=AF=20=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=EF=BC=8C=E5=8F=AF=E4=BB=A5=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/System/GenerateService.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Service/System/GenerateService.php b/app/Service/System/GenerateService.php index d449d0d..bf2fb5b 100644 --- a/app/Service/System/GenerateService.php +++ b/app/Service/System/GenerateService.php @@ -30,7 +30,6 @@ public function crud(GenerateCodeEntity $generateCodeEntity): array $errorCode = (new ErrorCodeBuild($params))->setModel($model)->build(); $service = (new ServiceBuild($params))->setModel($model)->setErrorCode($errorCode)->build(); $controller = (new ControllerBuild($params))->setErrorCode($errorCode)->setService($service)->build(); - var_dump($errorCode, $service, $controller); return [ 'file' => [ 'model' => $model->getFile(), From 5ede23e172075e4d0e6af57291e7b7368569830c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Tue, 31 Aug 2021 22:40:58 +0800 Subject: [PATCH 75/82] =?UTF-8?q?=E5=8D=87=E7=BA=A7=202.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 16 - .env.example | 1 + .gitignore | 3 +- .php-cs-fixer.php | 91 + .php_cs | 0 Dockerfile | 21 +- app/Component/AntDesign/Column/Column.php | 305 - .../AntDesign/Column/ProgressType.php | 25 - app/Component/AntDesign/Column/ValueEnum.php | 86 - .../AntDesign/Column/ValueEnumType.php | 65 - .../AntDesign/Config/ColumnConfig.php | 34 - app/Component/AntDesign/Config/PageConfig.php | 187 - app/Component/AntDesign/Config/Pagination.php | 17 - .../AntDesign/Config/RowSelection.php | 39 - .../Constant/Status/ProgressTypeStatus.php | 38 - .../Constant/Status/ValueEnumTypeStatus.php | 42 - .../AntDesign/Constant/Type/FormDateType.php | 26 - .../Constant/Type/FormSelectModeType.php | 18 - .../AntDesign/Constant/Type/InputType.php | 57 - .../Constant/Type/LinkConditionType.php | 18 - .../AntDesign/Constant/Type/LinkJudgeType.php | 38 - .../AntDesign/Constant/Type/LinkTarget.php | 28 - .../AntDesign/Constant/Type/LinkType.php | 23 - .../Constant/Type/RowSelectionType.php | 22 - .../Constant/Type/SearchJudgeType.php | 11 - .../AntDesign/Constant/Type/SizeType.php | 23 - .../AntDesign/Constant/Type/ValueType.php | 139 - .../AntDesign/Constant/Type/WidthType.php | 42 - app/Component/AntDesign/Form/AutoSize.php | 62 - app/Component/AntDesign/Form/BaseForm.php | 188 - app/Component/AntDesign/Form/Form.php | 63 - app/Component/AntDesign/Form/FormCheckbox.php | 60 - .../AntDesign/Form/FormDatePicker.php | 84 - app/Component/AntDesign/Form/FormRate.php | 130 - app/Component/AntDesign/Form/FormSelect.php | 267 - app/Component/AntDesign/Form/FormSlider.php | 132 - app/Component/AntDesign/Form/FormSwitch.php | 109 - app/Component/AntDesign/Form/FormText.php | 81 - .../AntDesign/Form/FormTextPassword.php | 32 - app/Component/AntDesign/Form/FormTextarea.php | 85 - app/Component/AntDesign/Form/Rules.php | 62 - app/Component/AntDesign/Link/Link.php | 288 - .../AntDesign/Link/LinkCondition.php | 84 - app/Component/AntDesign/Link/LinkJudge.php | 84 - .../AntDesign/Search/SearchCondition.php | 60 - .../AntDesign/Search/SearchJudge.php | 59 - app/Component/AntDesign/Table.php | 48 - app/Component/Generate/AbstractConfig.php | 30 - .../Generate/Build/Action/BaseActionBuild.php | 143 - .../Controller/BaseActionControllerBuild.php | 79 - .../Hyperf/DefaultActionControllerBuild.php | 24 - .../Hyperf/DetailActionControllerBuild.php | 26 - .../Hyperf/ListActionControllerBuild.php | 35 - .../ValidateParse/ApidogValidateParse.php | 19 - .../ValidateParse/BaseValidateParse.php | 85 - .../EasyswoolApidogValidateParse.php | 11 - .../Action/Service/BaseActionServiceBuild.php | 76 - .../Hyperf/ChangeActionServiceBuild.php | 31 - .../Hyperf/CreateActionServiceBuild.php | 26 - .../Hyperf/DefaultActionServiceBuild.php | 23 - .../Hyperf/DetailActionServiceBuild.php | 30 - .../Hyperf/FindOneActionServiceBuild.php | 32 - .../Hyperf/FormatModelActionServiceBuild.php | 35 - .../Service/Hyperf/ListActionServiceBuild.php | 46 - .../Hyperf/RemoveActionServiceBuild.php | 25 - .../Hyperf/UpdateActionServiceBuild.php | 27 - app/Component/Generate/Build/BaseBuild.php | 115 - .../Build/Collection/BaseBuildCollection.php | 80 - .../Collection/ControllerBuildCollection.php | 30 - .../Collection/ErrorCodeBuildCollection.php | 42 - .../Build/Collection/ModelBuildCollection.php | 30 - .../Build/Config/BuildActionClassConfig.php | 82 - .../Build/Config/BuildActionConfig.php | 58 - .../Generate/Build/Config/BuildConfig.php | 157 - .../Build/Config/BuildControllerConfig.php | 157 - .../Build/Config/BuildDefaultBaseConfig.php | 33 - .../Build/Config/BuildDefaultConfig.php | 109 - .../Build/Config/BuildErrorCodeConfig.php | 82 - .../Build/Config/BuildExceptionConfig.php | 58 - .../Build/Config/BuildServiceConfig.php | 58 - .../Generate/Build/ControllerBuild.php | 171 - .../Generate/Build/ErrorCodeBuild.php | 187 - .../Build/Model/Hyperf/ModelBuild.php | 21 - app/Component/Generate/Build/ServiceBuild.php | 165 - .../Generate/ClassFile/ClassBase.php | 235 - .../Generate/ClassFile/ClassConfig.php | 610 -- .../Generate/ClassFile/ClassConstant.php | 30 - .../Generate/ClassFile/ClassMethod.php | 114 - .../Generate/ClassFile/ClassParams.php | 130 - .../Generate/ClassFile/ClassProperty.php | 30 - app/Component/Generate/Generate.php | 77 - app/Component/User.php | 60 - app/Constant/Error.php | 181 - app/Constant/Errors/AdminError.php | 43 - app/Constant/Errors/System/GenerateError.php | 23 - app/Constant/Errors/System/MenuError.php | 28 - .../Errors/System/PermissionError.php | 28 - app/Constant/Errors/System/RoleError.php | 28 - app/Constant/Status/AdminStatus.php | 18 - app/Constants/ErrorCode.php | 26 + app/Controller/AbstractController.php | 38 + .../Admin/V1/Admin/AdminController.php | 136 - app/Controller/Admin/V1/LoginController.php | 81 - .../V1/System/GenerateCodeController.php | 10 - .../Admin/V1/System/MenuController.php | 114 - .../Admin/V1/System/PermissionController.php | 112 - .../Admin/V1/System/RoleController.php | 106 - app/Controller/Controller.php | 30 - app/Controller/IndexController.php | 26 + app/Controller/TestController.php | 288 - app/Entity/GenerateCodeEntity.php | 236 - app/Exception/BusinessException.php | 28 + .../Handler/ApiDogExceptionHandler.php | 27 - app/Exception/Handler/AppExceptionHandler.php | 43 + app/Listener/DbQueryExecutedListener.php | 2 +- app/Model/Admin.php | 45 - app/Model/AuthAssignment.php | 32 - app/Model/AuthItem.php | 35 - app/Model/AuthItemChild.php | 31 - app/Model/AuthMenu.php | 38 - app/Model/AuthRule.php | 33 - .../translation.php => app/Model/Model.php | 12 +- app/Service/Admin/AdminLoginService.php | 115 - app/Service/Admin/AdminService.php | 211 - app/Service/System/GenerateService.php | 48 - app/Service/System/Manager/MenuService.php | 167 - .../System/Manager/PermissionService.php | 194 - app/Service/System/Manager/RoleService.php | 196 - bin/hyperf.php | 6 +- composer.json | 58 +- composer.lock | 7466 +++++++++++++++++ config/autoload/annotations.php | 2 +- config/autoload/aspects.php | 2 +- config/autoload/auth.php | 59 - config/autoload/cache.php | 2 +- config/autoload/commands.php | 2 +- config/autoload/databases.php | 2 +- config/autoload/dependencies.php | 2 +- config/autoload/devtool.php | 2 +- config/autoload/exceptions.php | 14 +- config/autoload/genCode.php | 167 - config/autoload/jwt.php | 12 - config/autoload/listeners.php | 2 +- config/autoload/logger.php | 2 +- config/autoload/middlewares.php | 8 +- config/autoload/processes.php | 2 +- config/autoload/rbac.php | 47 - config/autoload/redis.php | 2 +- config/autoload/server.php | 33 +- config/config.php | 3 +- config/container.php | 2 +- config/routes.php | 2 +- doc/swagger/DemoController.php | 167 - phpstan.neon | 4 +- server.sh | 13 - test/Cases/ExampleTest.php | 2 +- test/HttpTestCase.php | 3 +- test/bootstrap.php | 4 +- 158 files changed, 7812 insertions(+), 10206 deletions(-) delete mode 100644 .env create mode 100644 .php-cs-fixer.php delete mode 100644 .php_cs delete mode 100644 app/Component/AntDesign/Column/Column.php delete mode 100644 app/Component/AntDesign/Column/ProgressType.php delete mode 100644 app/Component/AntDesign/Column/ValueEnum.php delete mode 100644 app/Component/AntDesign/Column/ValueEnumType.php delete mode 100644 app/Component/AntDesign/Config/ColumnConfig.php delete mode 100644 app/Component/AntDesign/Config/PageConfig.php delete mode 100644 app/Component/AntDesign/Config/Pagination.php delete mode 100644 app/Component/AntDesign/Config/RowSelection.php delete mode 100644 app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php delete mode 100644 app/Component/AntDesign/Constant/Status/ValueEnumTypeStatus.php delete mode 100644 app/Component/AntDesign/Constant/Type/FormDateType.php delete mode 100644 app/Component/AntDesign/Constant/Type/FormSelectModeType.php delete mode 100644 app/Component/AntDesign/Constant/Type/InputType.php delete mode 100644 app/Component/AntDesign/Constant/Type/LinkConditionType.php delete mode 100644 app/Component/AntDesign/Constant/Type/LinkJudgeType.php delete mode 100644 app/Component/AntDesign/Constant/Type/LinkTarget.php delete mode 100644 app/Component/AntDesign/Constant/Type/LinkType.php delete mode 100644 app/Component/AntDesign/Constant/Type/RowSelectionType.php delete mode 100644 app/Component/AntDesign/Constant/Type/SearchJudgeType.php delete mode 100644 app/Component/AntDesign/Constant/Type/SizeType.php delete mode 100644 app/Component/AntDesign/Constant/Type/ValueType.php delete mode 100644 app/Component/AntDesign/Constant/Type/WidthType.php delete mode 100644 app/Component/AntDesign/Form/AutoSize.php delete mode 100644 app/Component/AntDesign/Form/BaseForm.php delete mode 100644 app/Component/AntDesign/Form/Form.php delete mode 100644 app/Component/AntDesign/Form/FormCheckbox.php delete mode 100644 app/Component/AntDesign/Form/FormDatePicker.php delete mode 100644 app/Component/AntDesign/Form/FormRate.php delete mode 100644 app/Component/AntDesign/Form/FormSelect.php delete mode 100644 app/Component/AntDesign/Form/FormSlider.php delete mode 100644 app/Component/AntDesign/Form/FormSwitch.php delete mode 100644 app/Component/AntDesign/Form/FormText.php delete mode 100644 app/Component/AntDesign/Form/FormTextPassword.php delete mode 100644 app/Component/AntDesign/Form/FormTextarea.php delete mode 100644 app/Component/AntDesign/Form/Rules.php delete mode 100644 app/Component/AntDesign/Link/Link.php delete mode 100644 app/Component/AntDesign/Link/LinkCondition.php delete mode 100644 app/Component/AntDesign/Link/LinkJudge.php delete mode 100644 app/Component/AntDesign/Search/SearchCondition.php delete mode 100644 app/Component/AntDesign/Search/SearchJudge.php delete mode 100644 app/Component/AntDesign/Table.php delete mode 100644 app/Component/Generate/AbstractConfig.php delete mode 100644 app/Component/Generate/Build/Action/BaseActionBuild.php delete mode 100644 app/Component/Generate/Build/Action/Controller/BaseActionControllerBuild.php delete mode 100644 app/Component/Generate/Build/Action/Controller/Hyperf/DefaultActionControllerBuild.php delete mode 100644 app/Component/Generate/Build/Action/Controller/Hyperf/DetailActionControllerBuild.php delete mode 100644 app/Component/Generate/Build/Action/Controller/Hyperf/ListActionControllerBuild.php delete mode 100644 app/Component/Generate/Build/Action/Controller/ValidateParse/ApidogValidateParse.php delete mode 100644 app/Component/Generate/Build/Action/Controller/ValidateParse/BaseValidateParse.php delete mode 100644 app/Component/Generate/Build/Action/Controller/ValidateParse/EasyswoolApidogValidateParse.php delete mode 100644 app/Component/Generate/Build/Action/Service/BaseActionServiceBuild.php delete mode 100644 app/Component/Generate/Build/Action/Service/Hyperf/ChangeActionServiceBuild.php delete mode 100644 app/Component/Generate/Build/Action/Service/Hyperf/CreateActionServiceBuild.php delete mode 100644 app/Component/Generate/Build/Action/Service/Hyperf/DefaultActionServiceBuild.php delete mode 100644 app/Component/Generate/Build/Action/Service/Hyperf/DetailActionServiceBuild.php delete mode 100644 app/Component/Generate/Build/Action/Service/Hyperf/FindOneActionServiceBuild.php delete mode 100644 app/Component/Generate/Build/Action/Service/Hyperf/FormatModelActionServiceBuild.php delete mode 100644 app/Component/Generate/Build/Action/Service/Hyperf/ListActionServiceBuild.php delete mode 100644 app/Component/Generate/Build/Action/Service/Hyperf/RemoveActionServiceBuild.php delete mode 100644 app/Component/Generate/Build/Action/Service/Hyperf/UpdateActionServiceBuild.php delete mode 100644 app/Component/Generate/Build/BaseBuild.php delete mode 100644 app/Component/Generate/Build/Collection/BaseBuildCollection.php delete mode 100644 app/Component/Generate/Build/Collection/ControllerBuildCollection.php delete mode 100644 app/Component/Generate/Build/Collection/ErrorCodeBuildCollection.php delete mode 100644 app/Component/Generate/Build/Collection/ModelBuildCollection.php delete mode 100644 app/Component/Generate/Build/Config/BuildActionClassConfig.php delete mode 100644 app/Component/Generate/Build/Config/BuildActionConfig.php delete mode 100644 app/Component/Generate/Build/Config/BuildConfig.php delete mode 100644 app/Component/Generate/Build/Config/BuildControllerConfig.php delete mode 100644 app/Component/Generate/Build/Config/BuildDefaultBaseConfig.php delete mode 100644 app/Component/Generate/Build/Config/BuildDefaultConfig.php delete mode 100644 app/Component/Generate/Build/Config/BuildErrorCodeConfig.php delete mode 100644 app/Component/Generate/Build/Config/BuildExceptionConfig.php delete mode 100644 app/Component/Generate/Build/Config/BuildServiceConfig.php delete mode 100644 app/Component/Generate/Build/ControllerBuild.php delete mode 100644 app/Component/Generate/Build/ErrorCodeBuild.php delete mode 100644 app/Component/Generate/Build/Model/Hyperf/ModelBuild.php delete mode 100644 app/Component/Generate/Build/ServiceBuild.php delete mode 100644 app/Component/Generate/ClassFile/ClassBase.php delete mode 100644 app/Component/Generate/ClassFile/ClassConfig.php delete mode 100644 app/Component/Generate/ClassFile/ClassConstant.php delete mode 100644 app/Component/Generate/ClassFile/ClassMethod.php delete mode 100644 app/Component/Generate/ClassFile/ClassParams.php delete mode 100644 app/Component/Generate/ClassFile/ClassProperty.php delete mode 100644 app/Component/Generate/Generate.php delete mode 100644 app/Component/User.php delete mode 100644 app/Constant/Error.php delete mode 100644 app/Constant/Errors/AdminError.php delete mode 100644 app/Constant/Errors/System/GenerateError.php delete mode 100644 app/Constant/Errors/System/MenuError.php delete mode 100644 app/Constant/Errors/System/PermissionError.php delete mode 100644 app/Constant/Errors/System/RoleError.php delete mode 100644 app/Constant/Status/AdminStatus.php create mode 100644 app/Constants/ErrorCode.php create mode 100644 app/Controller/AbstractController.php delete mode 100644 app/Controller/Admin/V1/Admin/AdminController.php delete mode 100644 app/Controller/Admin/V1/LoginController.php delete mode 100644 app/Controller/Admin/V1/System/GenerateCodeController.php delete mode 100644 app/Controller/Admin/V1/System/MenuController.php delete mode 100644 app/Controller/Admin/V1/System/PermissionController.php delete mode 100644 app/Controller/Admin/V1/System/RoleController.php delete mode 100644 app/Controller/Controller.php create mode 100644 app/Controller/IndexController.php delete mode 100644 app/Controller/TestController.php delete mode 100644 app/Entity/GenerateCodeEntity.php create mode 100644 app/Exception/BusinessException.php delete mode 100644 app/Exception/Handler/ApiDogExceptionHandler.php create mode 100644 app/Exception/Handler/AppExceptionHandler.php delete mode 100644 app/Model/Admin.php delete mode 100644 app/Model/AuthAssignment.php delete mode 100644 app/Model/AuthItem.php delete mode 100644 app/Model/AuthItemChild.php delete mode 100644 app/Model/AuthMenu.php delete mode 100644 app/Model/AuthRule.php rename config/autoload/translation.php => app/Model/Model.php (67%) delete mode 100644 app/Service/Admin/AdminLoginService.php delete mode 100644 app/Service/Admin/AdminService.php delete mode 100644 app/Service/System/GenerateService.php delete mode 100644 app/Service/System/Manager/MenuService.php delete mode 100644 app/Service/System/Manager/PermissionService.php delete mode 100644 app/Service/System/Manager/RoleService.php create mode 100644 composer.lock delete mode 100644 config/autoload/auth.php delete mode 100644 config/autoload/genCode.php delete mode 100644 config/autoload/jwt.php delete mode 100644 config/autoload/rbac.php delete mode 100644 doc/swagger/DemoController.php delete mode 100644 server.sh diff --git a/.env b/.env deleted file mode 100644 index 6de2e60..0000000 --- a/.env +++ /dev/null @@ -1,16 +0,0 @@ -APP_NAME=skeleton - -DB_DRIVER=mysql -DB_HOST=localhost -DB_PORT=3306 -DB_DATABASE=hyperf_admin -DB_USERNAME=root -DB_PASSWORD= -DB_CHARSET=utf8mb4 -DB_COLLATION=utf8mb4_unicode_ci -DB_PREFIX= - -REDIS_HOST=localhost -REDIS_AUTH=(null) -REDIS_PORT=6379 -REDIS_DB=0 diff --git a/.env.example b/.env.example index 41be784..6879583 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,5 @@ APP_NAME=skeleton +APP_ENV=dev DB_DRIVER=mysql DB_HOST=localhost diff --git a/.gitignore b/.gitignore index 25154e8..aa7c7a5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ vendor/ .phpintel/ .env .DS_Store -*.lock .phpunit* +*.cache public +composer.lock diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..dd164b5 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,91 @@ +setRiskyAllowed(true) + ->setRules([ + '@PSR2' => true, + '@Symfony' => true, + '@DoctrineAnnotation' => true, + '@PhpCsFixer' => true, + 'header_comment' => [ + 'comment_type' => 'PHPDoc', + 'header' => $header, + 'separate' => 'none', + 'location' => 'after_declare_strict', + ], + 'array_syntax' => [ + 'syntax' => 'short' + ], + 'list_syntax' => [ + 'syntax' => 'short' + ], + 'concat_space' => [ + 'spacing' => 'one' + ], + 'blank_line_before_statement' => [ + 'statements' => [ + 'declare', + ], + ], + 'general_phpdoc_annotation_remove' => [ + 'annotations' => [ + 'author' + ], + ], + 'ordered_imports' => [ + 'imports_order' => [ + 'class', 'function', 'const', + ], + 'sort_algorithm' => 'alpha', + ], + 'single_line_comment_style' => [ + 'comment_types' => [ + ], + ], + 'yoda_style' => [ + 'always_move_variable' => false, + 'equal' => false, + 'identical' => false, + ], + 'phpdoc_align' => [ + 'align' => 'left', + ], + 'multiline_whitespace_before_semicolons' => [ + 'strategy' => 'no_multi_line', + ], + 'constant_case' => [ + 'case' => 'lower', + ], + 'class_attributes_separation' => true, + 'combine_consecutive_unsets' => true, + 'declare_strict_types' => true, + 'linebreak_after_opening_tag' => true, + 'lowercase_static_reference' => true, + 'no_useless_else' => true, + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => true, + 'not_operator_with_space' => false, + 'ordered_class_elements' => true, + 'php_unit_strict' => false, + 'phpdoc_separation' => false, + 'single_quote' => true, + 'standardize_not_equals' => true, + 'multiline_comment_opening_closing' => true, + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('public') + ->exclude('runtime') + ->exclude('vendor') + ->in(__DIR__) + ) + ->setUsingCache(false); diff --git a/.php_cs b/.php_cs deleted file mode 100644 index e69de29..0000000 diff --git a/Dockerfile b/Dockerfile index fda28e9..92318ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ # Default Dockerfile # # @link https://www.hyperf.io -# @document https://doc.hyperf.io +# @document https://hyperf.wiki # @contact group@hyperf.io -# @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE +# @license https://github.com/hyperf/hyperf/blob/master/LICENSE -FROM hyperf/hyperf:7.2-alpine-v3.9-cli +FROM hyperf/hyperf:8.0-alpine-v3.12-swoole LABEL maintainer="Hyperf Developers " version="1.0" license="MIT" app.name="Hyperf" ## @@ -15,29 +15,22 @@ LABEL maintainer="Hyperf Developers " version="1.0" license="MI ARG timezone ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \ - COMPOSER_VERSION=1.9.1 \ APP_ENV=prod \ SCAN_CACHEABLE=(true) # update RUN set -ex \ - && apk update \ - # install composer - && cd /tmp \ - && wget https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \ - && chmod u+x composer.phar \ - && mv composer.phar /usr/local/bin/composer \ # show php version and extensions && php -v \ && php -m \ && php --ri swoole \ # ---------- some config ---------- - && cd /etc/php7 \ + && cd /etc/php8 \ # - config PHP && { \ - echo "upload_max_filesize=100M"; \ - echo "post_max_size=108M"; \ - echo "memory_limit=1024M"; \ + echo "upload_max_filesize=128M"; \ + echo "post_max_size=128M"; \ + echo "memory_limit=1G"; \ echo "date.timezone=${TIMEZONE}"; \ } | tee conf.d/99_overrides.ini \ # - config timezone diff --git a/app/Component/AntDesign/Column/Column.php b/app/Component/AntDesign/Column/Column.php deleted file mode 100644 index 1675098..0000000 --- a/app/Component/AntDesign/Column/Column.php +++ /dev/null @@ -1,305 +0,0 @@ -copyable; - } - - /** - * @param bool $copyable - * - * @return Column - */ - public function setCopyable(bool $copyable): Column - { - $this->copyable = $copyable; - return $this; - } - - /** - * @return bool - */ - public function getEllipsis(): bool - { - return $this->ellipsis; - } - - /** - * @param bool $ellipsis - * - * @return Column - */ - public function setEllipsis(bool $ellipsis): Column - { - $this->ellipsis = $ellipsis; - return $this; - } - - /** - * @return ValueType - */ - public function getValueType(): ValueType - { - return $this->valueType; - } - - /** - * @param ValueType $valueType - * - * @return BaseColumn - */ - public function setValueType(ValueType $valueType): BaseColumn - { - $this->valueType = $valueType; - return $this; - } - - /** - * @return bool - */ - public function getFilters(): bool - { - return $this->filters; - } - - /** - * @param bool $filters - * - * @return BaseColumn - */ - public function setFilters(bool $filters): BaseColumn - { - $this->filters = $filters; - return $this; - } - - /** - * @return string - */ - public function getDataIndex(): string - { - return $this->dataIndex; - } - - /** - * @param string $dataIndex - * - * @return BaseColumn - */ - public function setDataIndex(string $dataIndex): BaseColumn - { - $this->dataIndex = $dataIndex; - return $this; - } - - /** - * @return string - */ - public function getTitle(): string - { - return $this->title; - } - - /** - * @param string $title - * - * @return BaseColumn - */ - public function setTitle(string $title): BaseColumn - { - $this->title = $title; - return $this; - } - - /** - * @return string - */ - public function getKey(): string - { - return $this->key; - } - - /** - * @param string $key - * - * @return BaseColumn - */ - public function setKey(string $key): BaseColumn - { - $this->key = $key; - return $this; - } - - /** - * @return string - */ - public function getTooltip(): string - { - return $this->tooltip; - } - - /** - * @param string $tooltip - * - * @return BaseColumn - */ - public function setTooltip(string $tooltip): BaseColumn - { - $this->tooltip = $tooltip; - return $this; - } - - /** - * @return string - */ - public function getWidth(): string - { - return $this->width; - } - - /** - * @param string $width - * - * @return BaseColumn - */ - public function setWidth(string $width): BaseColumn - { - $this->width = $width; - return $this; - } - - /** - * @return array - */ - public function getValueEnum(): array - { - return $this->valueEnum; - } - - /** - * @param ValueEnum[] $valueEnum - * - * @return BaseColumn - */ - public function setValueEnum(array $valueEnum): BaseColumn - { - $this->valueEnum = $valueEnum; - return $this; - } - - protected function check(): void - { - // 必填项验证 - $this->getDataIndex(); - // 进度条 - if ($this->valueType->getValue() === ValueType::PROGRESS) { - $progress = []; - foreach ($this->getValueEnum() as $item) { - $progress[$item->getKey()] = new ProgressType([ - 'text' => $item->getValue(), - 'status' => $item->getStatus(), - ]); - } - $this->valueEnum = $progress; - } - - // 具有 drop 属性 - if (in_array($this->valueType->getValue(), [ - ValueType::SELECT, - ValueType::CHECKBOX, - ValueType::RADIO, - ValueType::RADIO_BUTTON, - ], true)) { - $drops = []; - foreach ($this->getValueEnum() as $item) { - $drops[$item->getKey()] = new ValueEnumType([ - 'text' => $item->getValue(), - 'status' => $item->getStatus(), - ]); - } - $this->valueEnum = $drops; - } - } - - public function toArray(?object $object = null): array - { - $this->check(); - return parent::toArray($object); // TODO: Change the autogenerated stub - } -} diff --git a/app/Component/AntDesign/Column/ProgressType.php b/app/Component/AntDesign/Column/ProgressType.php deleted file mode 100644 index d56de65..0000000 --- a/app/Component/AntDesign/Column/ProgressType.php +++ /dev/null @@ -1,25 +0,0 @@ -key; - } - - /** - * @param mixed $key - * - * @return ValueEnum - */ - public function setKey($key) - { - $this->key = $key; - return $this; - } - - /** - * @return mixed - */ - public function getValue() - { - return $this->value; - } - - /** - * @param mixed $value - * - * @return ValueEnum - */ - public function setValue($value) - { - $this->value = $value; - return $this; - } - - /** - * @return string - */ - public function getStatus(): string - { - return $this->status; - } - - /** - * @param string $status - * - * @return ValueEnum - */ - public function setStatus(string $status): ValueEnum - { - $this->status = $status; - return $this; - } -} diff --git a/app/Component/AntDesign/Column/ValueEnumType.php b/app/Component/AntDesign/Column/ValueEnumType.php deleted file mode 100644 index 21d9aee..0000000 --- a/app/Component/AntDesign/Column/ValueEnumType.php +++ /dev/null @@ -1,65 +0,0 @@ -text; - } - - /** - * @param string $text - * - * @return ValueEnumType - */ - public function setText(string $text): ValueEnumType - { - $this->text = $text; - return $this; - } - - /** - * @return ValueEnumTypeStatus - */ - public function getStatus(): ValueEnumTypeStatus - { - return $this->status; - } - - /** - * @param ValueEnumTypeStatus $status - * - * @return ValueEnumType - */ - public function setStatus(ValueEnumTypeStatus $status): ValueEnumType - { - $this->status = $status; - return $this; - } - -} diff --git a/app/Component/AntDesign/Config/ColumnConfig.php b/app/Component/AntDesign/Config/ColumnConfig.php deleted file mode 100644 index e16e26d..0000000 --- a/app/Component/AntDesign/Config/ColumnConfig.php +++ /dev/null @@ -1,34 +0,0 @@ -searchText; - } - - /** - * @param string $searchText - * - * @return PageConfig - */ - public function setSearchText(string $searchText): PageConfig - { - $this->searchText = $searchText; - return $this; - } - - /** - * @return string - */ - public function getResetText(): string - { - return $this->resetText; - } - - /** - * @param string $resetText - * - * @return PageConfig - */ - public function setResetText(string $resetText): PageConfig - { - $this->resetText = $resetText; - return $this; - } - - /** - * @return string - */ - public function getSubmitText(): string - { - return $this->submitText; - } - - /** - * @param string $submitText - * - * @return PageConfig - */ - public function setSubmitText(string $submitText): PageConfig - { - $this->submitText = $submitText; - return $this; - } - - /** - * @return int|string - */ - public function getLabelWidth() - { - return $this->labelWidth; - } - - /** - * @param int|string $labelWidth - * - * @return PageConfig - */ - public function setLabelWidth($labelWidth) - { - $this->labelWidth = $labelWidth; - return $this; - } - - /** - * @return int - */ - public function getSpan(): int - { - return $this->span; - } - - /** - * @param int $span - * - * @return PageConfig - */ - public function setSpan(int $span): PageConfig - { - $this->span = $span; - return $this; - } - - /** - * @return bool - */ - public function getDefaultCollapsed(): bool - { - return $this->defaultCollapsed; - } - - /** - * @param bool $defaultCollapsed - * - * @return PageConfig - */ - public function setDefaultCollapsed(bool $defaultCollapsed): PageConfig - { - $this->defaultCollapsed = $defaultCollapsed; - return $this; - } - - /** - * @return bool - */ - public function getCollapsed(): bool - { - return $this->collapsed; - } - - /** - * @param bool $collapsed - * - * @return PageConfig - */ - public function setCollapsed(bool $collapsed): PageConfig - { - $this->collapsed = $collapsed; - return $this; - } -} diff --git a/app/Component/AntDesign/Config/Pagination.php b/app/Component/AntDesign/Config/Pagination.php deleted file mode 100644 index e6ebdc9..0000000 --- a/app/Component/AntDesign/Config/Pagination.php +++ /dev/null @@ -1,17 +0,0 @@ -type; - } - - /** - * @param RowSelectionType $type - * - * @return RowSelection - */ - public function setType(RowSelectionType $type): RowSelection - { - $this->type = $type; - return $this; - } -} diff --git a/app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php b/app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php deleted file mode 100644 index 25b30c5..0000000 --- a/app/Component/AntDesign/Constant/Status/ProgressTypeStatus.php +++ /dev/null @@ -1,38 +0,0 @@ -'; - - /** - * @Message("大于等于") - */ - public const GREATER_THAN_OR_EQUAL = '>='; - - /** - * @Message("小于") - */ - public const LESS_THAN = '<'; - - /** - * @Message("小于等于") - */ - public const LESS_THAN_OR_EQUAL = '<='; - - /** - * @Message("等于") - */ - public const EQUAL = '='; - - /** - * @Message("不等于") - */ - public const NOT_EQUAL = '!='; -} diff --git a/app/Component/AntDesign/Constant/Type/LinkTarget.php b/app/Component/AntDesign/Constant/Type/LinkTarget.php deleted file mode 100644 index 1ab5f73..0000000 --- a/app/Component/AntDesign/Constant/Type/LinkTarget.php +++ /dev/null @@ -1,28 +0,0 @@ -操作a, 操作b] - * @Message("操作项") - */ - public const OPTION = 'option'; - - /** - * 选择 配合 Column::valueEnum - * @Message("选择") - */ - public const SELECT = 'select'; - - /** - * 与 text 相同, form 转化时会转为 textarea 组件 - * @Message("文本域") - */ - public const TEXTAREA = 'textarea'; - - /** - * 序号列 - * @Message("序号列") - */ - public const INDEX = 'index'; - - /** - * 带 border 的序号列 - * @Message("带 border 的序号列") - */ - public const INDEX_BORDER = 'indexBorder'; - - /** - * 进度条 - * @Message("进度条") - */ - public const PROGRESS = 'progress'; - - /** - * 格式化数字展示,form 转化时会转为 inputNumber - * @Message("格式化数字展示") - */ - public const DIGIT = 'digit'; - - /** - * 百分比 - * @Message("百分比") - */ - public const PERCENT = 'percent'; - - /** - * 代码块 - * @Message("代码块") - */ - public const CODE = 'code'; - - /** - * 密码相关的展示 - * @Message("密码框") - */ - public const PASSWORD = 'password'; - - /** - * 展示一个头像 - * @Message("头像") - */ - public const AVATAR = 'avatar'; - - /** - * 单选 - * @Message("单选") - */ - public const RADIO = 'radio'; - - /** - * 按钮形式单选 - * @Message("按钮形式单选") - */ - public const RADIO_BUTTON = 'radioButton'; - - /** - * 单选 - * @Message("多选") - */ - public const CHECKBOX = 'checkbox'; - -} diff --git a/app/Component/AntDesign/Constant/Type/WidthType.php b/app/Component/AntDesign/Constant/Type/WidthType.php deleted file mode 100644 index fea3aaf..0000000 --- a/app/Component/AntDesign/Constant/Type/WidthType.php +++ /dev/null @@ -1,42 +0,0 @@ -minRows; - } - - /** - * @param int $minRows - * - * @return AutoSize - */ - public function setMinRows(int $minRows): AutoSize - { - $this->minRows = $minRows; - return $this; - } - - /** - * @return int - */ - public function getMaxRows(): int - { - return $this->maxRows; - } - - /** - * @param int $maxRows - * - * @return AutoSize - */ - public function setMaxRows(int $maxRows): AutoSize - { - $this->maxRows = $maxRows; - return $this; - } -} diff --git a/app/Component/AntDesign/Form/BaseForm.php b/app/Component/AntDesign/Form/BaseForm.php deleted file mode 100644 index c5a1625..0000000 --- a/app/Component/AntDesign/Form/BaseForm.php +++ /dev/null @@ -1,188 +0,0 @@ -name; - } - - /** - * @param string $name - * - * @return BaseForm - */ - public function setName(string $name): BaseForm - { - $this->name = $name; - return $this; - } - - /** - * @return string - */ - public function getLabel(): string - { - return $this->label; - } - - /** - * @param string $label - * - * @return BaseForm - */ - public function setLabel(string $label): BaseForm - { - $this->label = $label; - return $this; - } - - /** - * @return string - */ - public function getPlaceholder(): string - { - return $this->placeholder; - } - - /** - * @param string $placeholder - * - * @return BaseForm - */ - public function setPlaceholder(string $placeholder): BaseForm - { - $this->placeholder = $placeholder; - return $this; - } - - /** - * @return WidthType - */ - public function getWidth(): WidthType - { - return $this->width; - } - - /** - * @param WidthType $width - * - * @return BaseForm - */ - public function setWidth(WidthType $width): BaseForm - { - $this->width = $width; - return $this; - } - - /** - * @return Rules[] - */ - public function getRules(): array - { - return $this->rules; - } - - /** - * @param Rules[] $rules - * - * @return BaseForm - */ - public function setRules(array $rules): BaseForm - { - $this->rules = $rules; - return $this; - } - - /** - * @return bool - */ - public function getDisabled(): bool - { - return $this->disabled; - } - - /** - * @param bool $disabled - * - * @return BaseForm - */ - public function setDisabled(bool $disabled): BaseForm - { - $this->disabled = $disabled; - return $this; - } - - /** - * @return string - */ - public function getInputType(): string - { - return $this->inputType; - } - - /** - * @param string $inputType - * - * @return BaseForm - */ - public function setInputType(string $inputType): BaseForm - { - $this->inputType = $inputType; - return $this; - } -} diff --git a/app/Component/AntDesign/Form/Form.php b/app/Component/AntDesign/Form/Form.php deleted file mode 100644 index b789f62..0000000 --- a/app/Component/AntDesign/Form/Form.php +++ /dev/null @@ -1,63 +0,0 @@ -title; - } - - /** - * @param string $title - * - * @return Form - */ - public function setTitle(string $title): Form - { - $this->title = $title; - return $this; - } - - /** - * @return array - */ - public function getItem(): array - { - return $this->item; - } - - /** - * @param array $item - * - * @return Form - */ - public function setItem(array $item): Form - { - $data = []; - foreach ($item as $form) { - $type = $form['inputType']; - $class = __NAMESPACE__ . '\\' . InputType::byName(strtoupper($type))->getValue(); - $data[] = new $class($form); - } - $this->item = $data; - return $this; - } -} diff --git a/app/Component/AntDesign/Form/FormCheckbox.php b/app/Component/AntDesign/Form/FormCheckbox.php deleted file mode 100644 index 4bec90c..0000000 --- a/app/Component/AntDesign/Form/FormCheckbox.php +++ /dev/null @@ -1,60 +0,0 @@ -defaultChecked; - } - - /** - * @param bool $defaultChecked - * - * @return FormCheckbox - */ - public function setDefaultChecked(bool $defaultChecked): FormCheckbox - { - $this->defaultChecked = $defaultChecked; - return $this; - } - - /** - * @return array - */ - public function getValueEnum(): array - { - return $this->valueEnum; - } - - /** - * @param ValueEnum[] $valueEnum - * - * @return FormCheckbox - */ - public function setValueEnum(array $valueEnum): FormCheckbox - { - $this->valueEnum = $valueEnum; - return $this; - } -} diff --git a/app/Component/AntDesign/Form/FormDatePicker.php b/app/Component/AntDesign/Form/FormDatePicker.php deleted file mode 100644 index ff657aa..0000000 --- a/app/Component/AntDesign/Form/FormDatePicker.php +++ /dev/null @@ -1,84 +0,0 @@ -type; - } - - /** - * @param FormDateType $type - * - * @return FormDatePicker - */ - public function setType(FormDateType $type): FormDatePicker - { - $this->type = $type; - return $this; - } - - /** - * @return bool - */ - public function getRange(): bool - { - return $this->range; - } - - /** - * @param bool $range - * - * @return FormDatePicker - */ - public function setRange(bool $range): FormDatePicker - { - $this->range = $range; - return $this; - } - - /** - * @return string - */ - public function getDefaultValue(): string - { - return $this->defaultValue; - } - - /** - * @param string $defaultValue - * - * @return FormDatePicker - */ - public function setDefaultValue(string $defaultValue): FormDatePicker - { - $this->defaultValue = $defaultValue; - return $this; - } - -} diff --git a/app/Component/AntDesign/Form/FormRate.php b/app/Component/AntDesign/Form/FormRate.php deleted file mode 100644 index f6f04ff..0000000 --- a/app/Component/AntDesign/Form/FormRate.php +++ /dev/null @@ -1,130 +0,0 @@ -character; - } - - /** - * @param string $character - * - * @return FormRate - */ - public function setCharacter(string $character): FormRate - { - $this->character = $character; - return $this; - } - - /** - * @return bool - */ - public function getAllowClear(): bool - { - return $this->allowClear; - } - - /** - * @param bool $allowClear - * - * @return FormRate - */ - public function setAllowClear(bool $allowClear): FormRate - { - $this->allowClear = $allowClear; - return $this; - } - - /** - * @return bool - */ - public function getAllowHalf(): bool - { - return $this->allowHalf; - } - - /** - * @param bool $allowHalf - * - * @return FormRate - */ - public function setAllowHalf(bool $allowHalf): FormRate - { - $this->allowHalf = $allowHalf; - return $this; - } - - /** - * @return int - */ - public function getCount(): int - { - return $this->count; - } - - /** - * @param int $count - * - * @return FormRate - */ - public function setCount(int $count): FormRate - { - $this->count = $count; - return $this; - } - - /** - * @return float|int - */ - public function getDefaultValue() - { - return $this->defaultValue; - } - - /** - * @param float|int $defaultValue - * - * @return FormRate - */ - public function setDefaultValue($defaultValue): FormRate - { - $this->defaultValue = $defaultValue; - return $this; - } -} diff --git a/app/Component/AntDesign/Form/FormSelect.php b/app/Component/AntDesign/Form/FormSelect.php deleted file mode 100644 index ddadc5a..0000000 --- a/app/Component/AntDesign/Form/FormSelect.php +++ /dev/null @@ -1,267 +0,0 @@ -valueEnum; - } - - /** - * @param ValueEnum[] $valueEnum - * - * @return FormSelect - */ - public function setValueEnum(array $valueEnum): FormSelect - { - $this->valueEnum = $valueEnum; - return $this; - } - - /** - * @return FormSelectModeType - */ - public function getMode(): FormSelectModeType - { - return $this->mode; - } - - /** - * @param FormSelectModeType $mode - * - * @return FormSelect - */ - public function setMode(FormSelectModeType $mode): FormSelect - { - $this->mode = $mode; - return $this; - } - - /** - * @return int - */ - public function getListHeight(): int - { - return $this->listHeight; - } - - /** - * @param int $listHeight - * - * @return FormSelect - */ - public function setListHeight(int $listHeight): FormSelect - { - $this->listHeight = $listHeight; - return $this; - } - - /** - * @return SizeType - */ - public function getSize(): SizeType - { - return $this->size; - } - - /** - * @param SizeType $size - * - * @return FormSelect - */ - public function setSize(SizeType $size): FormSelect - { - $this->size = $size; - return $this; - } - - /** - * @return bool - */ - public function getShowSearch(): bool - { - return $this->showSearch; - } - - /** - * @param bool $showSearch - * - * @return FormSelect - */ - public function setShowSearch(bool $showSearch): FormSelect - { - $this->showSearch = $showSearch; - return $this; - } - - /** - * @return bool - */ - public function getAllowClear(): bool - { - return $this->allowClear; - } - - /** - * @param bool $allowClear - * - * @return FormSelect - */ - public function setAllowClear(bool $allowClear): FormSelect - { - $this->allowClear = $allowClear; - return $this; - } - - /** - * @return bool - */ - public function getAutoClearSearchValue(): bool - { - return $this->autoClearSearchValue; - } - - /** - * @param bool $autoClearSearchValue - * - * @return FormSelect - */ - public function setAutoClearSearchValue(bool $autoClearSearchValue): FormSelect - { - $this->autoClearSearchValue = $autoClearSearchValue; - return $this; - } - - /** - * @return bool - */ - public function getBordered(): bool - { - return $this->bordered; - } - - /** - * @param bool $bordered - * - * @return FormSelect - */ - public function setBordered(bool $bordered): FormSelect - { - $this->bordered = $bordered; - return $this; - } - - /** - * @return bool - */ - public function getDefaultActiveFirstOption(): bool - { - return $this->defaultActiveFirstOption; - } - - /** - * @param bool $defaultActiveFirstOption - * - * @return FormSelect - */ - public function setDefaultActiveFirstOption(bool $defaultActiveFirstOption): FormSelect - { - $this->defaultActiveFirstOption = $defaultActiveFirstOption; - return $this; - } - - /** - * @return bool - */ - public function getDefaultOpen(): bool - { - return $this->defaultOpen; - } - - /** - * @param bool $defaultOpen - * - * @return FormSelect - */ - public function setDefaultOpen(bool $defaultOpen): FormSelect - { - $this->defaultOpen = $defaultOpen; - return $this; - } - -} diff --git a/app/Component/AntDesign/Form/FormSlider.php b/app/Component/AntDesign/Form/FormSlider.php deleted file mode 100644 index 919c548..0000000 --- a/app/Component/AntDesign/Form/FormSlider.php +++ /dev/null @@ -1,132 +0,0 @@ -range; - } - - /** - * @param bool $range - * - * @return FormSlider - */ - public function setRange(bool $range): FormSlider - { - $this->range = $range; - return $this; - } - - /** - * @return float|float[] - */ - public function getDefaultValue() - { - return $this->defaultValue; - } - - /** - * @param float|float[] $defaultValue - * - * @return FormSlider - */ - public function setDefaultValue($defaultValue): FormSlider - { - $this->defaultValue = $defaultValue; - return $this; - } - - /** - * @return float|int - */ - public function getMax() - { - return $this->max; - } - - /** - * @param float|int $max - * - * @return FormSlider - */ - public function setMax($max): FormSlider - { - $this->max = $max; - return $this; - } - - /** - * @return float|int - */ - public function getMin() - { - return $this->min; - } - - /** - * @param float|int $min - * - * @return FormSlider - */ - public function setMin($min): FormSlider - { - $this->min = $min; - return $this; - } - - /** - * @return bool - */ - public function getTooltipVisible(): bool - { - return $this->tooltipVisible; - } - - /** - * @param bool $tooltipVisible - * - * @return FormSlider - */ - public function setTooltipVisible(bool $tooltipVisible): FormSlider - { - $this->tooltipVisible = $tooltipVisible; - return $this; - } - -} diff --git a/app/Component/AntDesign/Form/FormSwitch.php b/app/Component/AntDesign/Form/FormSwitch.php deleted file mode 100644 index c0b525c..0000000 --- a/app/Component/AntDesign/Form/FormSwitch.php +++ /dev/null @@ -1,109 +0,0 @@ -defaultChecked; - } - - /** - * @param bool $defaultChecked - * - * @return FormSwitch - */ - public function setDefaultChecked(bool $defaultChecked): FormSwitch - { - $this->defaultChecked = $defaultChecked; - return $this; - } - - /** - * @return SizeType - */ - public function getSize(): SizeType - { - return $this->size; - } - - /** - * @param SizeType $size - * - * @return FormSwitch - */ - public function setSize(SizeType $size): FormSwitch - { - $this->size = $size; - return $this; - } - - /** - * @return string - */ - public function getCheckedChildren(): string - { - return $this->checkedChildren; - } - - /** - * @param string $checkedChildren - * - * @return FormSwitch - */ - public function setCheckedChildren(string $checkedChildren): FormSwitch - { - $this->checkedChildren = $checkedChildren; - return $this; - } - - /** - * @return string - */ - public function getUnCheckedChildren(): string - { - return $this->unCheckedChildren; - } - - /** - * @param string $unCheckedChildren - * - * @return FormSwitch - */ - public function setUnCheckedChildren(string $unCheckedChildren): FormSwitch - { - $this->unCheckedChildren = $unCheckedChildren; - return $this; - } - -} diff --git a/app/Component/AntDesign/Form/FormText.php b/app/Component/AntDesign/Form/FormText.php deleted file mode 100644 index d393321..0000000 --- a/app/Component/AntDesign/Form/FormText.php +++ /dev/null @@ -1,81 +0,0 @@ -bordered; - } - - /** - * @param bool $bordered - * - * @return FormText - */ - public function setBordered(bool $bordered): FormText - { - $this->bordered = $bordered; - return $this; - } - - /** - * @return bool - */ - public function getAllowClear(): bool - { - return $this->allowClear; - } - - /** - * @param bool $allowClear - * - * @return FormText - */ - public function setAllowClear(bool $allowClear): FormText - { - $this->allowClear = $allowClear; - return $this; - } - - /** - * @return bool - */ - public function getShowCount(): bool - { - return $this->showCount; - } - - /** - * @param bool $showCount - * - * @return FormText - */ - public function setShowCount(bool $showCount): FormText - { - $this->showCount = $showCount; - return $this; - } -} diff --git a/app/Component/AntDesign/Form/FormTextPassword.php b/app/Component/AntDesign/Form/FormTextPassword.php deleted file mode 100644 index 8695c62..0000000 --- a/app/Component/AntDesign/Form/FormTextPassword.php +++ /dev/null @@ -1,32 +0,0 @@ -visibilityToggle; - } - - /** - * @param bool $visibilityToggle - * - * @return FormTextPassword - */ - public function setVisibilityToggle(bool $visibilityToggle): FormTextPassword - { - $this->visibilityToggle = $visibilityToggle; - return $this; - } - -} diff --git a/app/Component/AntDesign/Form/FormTextarea.php b/app/Component/AntDesign/Form/FormTextarea.php deleted file mode 100644 index 2c0c36f..0000000 --- a/app/Component/AntDesign/Form/FormTextarea.php +++ /dev/null @@ -1,85 +0,0 @@ -autoSize; - } - - /** - * @param AutoSize|bool $autoSize - * - * @return FormTextarea - */ - public function setAutoSize($autoSize) - { - $this->autoSize = $autoSize; - return $this; - } - - /** - * @return string - */ - public function getDefaultValue(): string - { - return $this->defaultValue; - } - - /** - * @param string $defaultValue - * - * @return FormTextarea - */ - public function setDefaultValue(string $defaultValue): FormTextarea - { - $this->defaultValue = $defaultValue; - return $this; - } - - /** - * @return int - */ - public function getMaxLength(): int - { - return $this->maxLength; - } - - /** - * @param int $maxLength - * - * @return FormTextarea - */ - public function setMaxLength(int $maxLength): FormTextarea - { - $this->maxLength = $maxLength; - return $this; - } -} diff --git a/app/Component/AntDesign/Form/Rules.php b/app/Component/AntDesign/Form/Rules.php deleted file mode 100644 index 3a50c71..0000000 --- a/app/Component/AntDesign/Form/Rules.php +++ /dev/null @@ -1,62 +0,0 @@ -required; - } - - /** - * @param bool $required - * - * @return Rules - */ - public function setRequired(bool $required): Rules - { - $this->required = $required; - return $this; - } - - /** - * @return string - */ - public function getMessage(): string - { - return $this->message; - } - - /** - * @param string $message - * - * @return Rules - */ - public function setMessage(string $message): Rules - { - $this->message = $message; - return $this; - } -} diff --git a/app/Component/AntDesign/Link/Link.php b/app/Component/AntDesign/Link/Link.php deleted file mode 100644 index f2875aa..0000000 --- a/app/Component/AntDesign/Link/Link.php +++ /dev/null @@ -1,288 +0,0 @@ -name; - } - - /** - * @param string $name - * - * @return Link - */ - public function setName(string $name): Link - { - $this->name = $name; - if (empty($this->label)) { - $this->setLabel($name); - } - return $this; - } - - /** - * @return string - */ - public function getPath(): string - { - return $this->path; - } - - /** - * @param string $path - * - * @return Link - */ - public function setPath(string $path): Link - { - $this->path = $path; - return $this; - } - - /** - * @return LinkTarget - */ - public function getTarget(): LinkTarget - { - return $this->target; - } - - /** - * @param LinkTarget $target - * - * @return Link - */ - public function setTarget(LinkTarget $target): Link - { - $this->target = $target; - return $this; - } - - /** - * @return LinkType - */ - public function getType(): LinkType - { - return $this->type; - } - - /** - * @param LinkType $type - * - * @return Link - */ - public function setType(LinkType $type): Link - { - $this->type = $type; - return $this; - } - - /** - * @return ValueEnumTypeStatus - */ - public function getStatus(): ValueEnumTypeStatus - { - return $this->status; - } - - /** - * @param ValueEnumTypeStatus $status - * - * @return Link - */ - public function setStatus(ValueEnumTypeStatus $status): Link - { - $this->status = $status; - return $this; - } - - /** - * @return string - */ - public function getIcon(): string - { - return $this->icon; - } - - /** - * @param string $icon - * - * @return Link - */ - public function setIcon(string $icon): Link - { - $this->icon = $icon; - return $this; - } - - /** - * @return string - */ - public function getLabel(): string - { - return $this->label; - } - - /** - * @param string $label - * - * @return Link - */ - public function setLabel(string $label): Link - { - $this->label = $label; - return $this; - } - - /** - * @return array - */ - public function getData(): array - { - return $this->data; - } - - /** - * @param array $data - * - * @return Link - */ - public function setData(array $data): Link - { - $this->data = $data; - return $this; - } - - /** - * @return string - */ - public function getTip(): string - { - return $this->tip; - } - - /** - * @param string $tip - * - * @return Link - */ - public function setTip(string $tip): Link - { - $this->tip = $tip; - return $this; - } - - /** - * @return Form - */ - public function getForm(): Form - { - return $this->form; - } - - /** - * @param Form $form - * - * @return Link - */ - public function setForm(Form $form): Link - { - $this->form = $form; - return $this; - } - - /** - * @return LinkCondition[] - */ - public function getCondition(): array - { - return $this->condition; - } - - /** - * @param LinkCondition[] $condition - * - * @return Link - */ - public function setCondition(array $condition): Link - { - $this->condition = $condition; - return $this; - } -} diff --git a/app/Component/AntDesign/Link/LinkCondition.php b/app/Component/AntDesign/Link/LinkCondition.php deleted file mode 100644 index 6f5535e..0000000 --- a/app/Component/AntDesign/Link/LinkCondition.php +++ /dev/null @@ -1,84 +0,0 @@ -label; - } - - /** - * @param string $label - * - * @return LinkCondition - */ - public function setLabel(string $label): LinkCondition - { - $this->label = $label; - return $this; - } - - /** - * @return LinkConditionType - */ - public function getType(): LinkConditionType - { - return $this->type; - } - - /** - * @param LinkConditionType $type - * - * @return LinkCondition - */ - public function setType(LinkConditionType $type): LinkCondition - { - $this->type = $type; - return $this; - } - - /** - * @return LinkJudge[] - */ - public function getJudge(): array - { - return $this->judge; - } - - /** - * @param LinkJudge[] $judge - * - * @return LinkCondition - */ - public function setJudge(array $judge): LinkCondition - { - $this->judge = $judge; - return $this; - } -} diff --git a/app/Component/AntDesign/Link/LinkJudge.php b/app/Component/AntDesign/Link/LinkJudge.php deleted file mode 100644 index 07e1a05..0000000 --- a/app/Component/AntDesign/Link/LinkJudge.php +++ /dev/null @@ -1,84 +0,0 @@ -attribute; - } - - /** - * @param string $attribute - * - * @return LinkJudge - */ - public function setAttribute(string $attribute): LinkJudge - { - $this->attribute = $attribute; - return $this; - } - - /** - * @return LinkJudgeType - */ - public function getType(): LinkJudgeType - { - return $this->type; - } - - /** - * @param LinkJudgeType $type - * - * @return LinkJudge - */ - public function setType(LinkJudgeType $type): LinkJudge - { - $this->type = $type; - return $this; - } - - /** - * @return mixed - */ - public function getValue() - { - return $this->value; - } - - /** - * @param mixed $value - * - * @return LinkJudge - */ - public function setValue($value) - { - $this->value = $value; - return $this; - } -} diff --git a/app/Component/AntDesign/Search/SearchCondition.php b/app/Component/AntDesign/Search/SearchCondition.php deleted file mode 100644 index 3bc636d..0000000 --- a/app/Component/AntDesign/Search/SearchCondition.php +++ /dev/null @@ -1,60 +0,0 @@ -type; - } - - /** - * @param LinkConditionType $type - * - * @return SearchCondition - */ - public function setType(LinkConditionType $type): SearchCondition - { - $this->type = $type; - return $this; - } - - /** - * @return SearchJudge[] - */ - public function getJudge(): array - { - return $this->judge; - } - - /** - * @param SearchJudge[] $judge - * - * @return SearchCondition - */ - public function setJudge(array $judge): SearchCondition - { - $this->judge = $judge; - return $this; - } -} diff --git a/app/Component/AntDesign/Search/SearchJudge.php b/app/Component/AntDesign/Search/SearchJudge.php deleted file mode 100644 index 5cb8606..0000000 --- a/app/Component/AntDesign/Search/SearchJudge.php +++ /dev/null @@ -1,59 +0,0 @@ -attribute; - } - - /** - * @param string $attribute - * - * @return SearchJudge - */ - public function setAttribute(string $attribute): SearchJudge - { - $this->attribute = $attribute; - return $this; - } - - /** - * @return SearchJudgeType - */ - public function getType(): SearchJudgeType - { - return $this->type; - } - - /** - * @param SearchJudgeType $type - * - * @return SearchJudge - */ - public function setType(SearchJudgeType $type): SearchJudge - { - $this->type = $type; - return $this; - } -} diff --git a/app/Component/AntDesign/Table.php b/app/Component/AntDesign/Table.php deleted file mode 100644 index 7df8144..0000000 --- a/app/Component/AntDesign/Table.php +++ /dev/null @@ -1,48 +0,0 @@ -columnConfig === null) { - $this->columnConfig = new ColumnConfig(); - } - } -} diff --git a/app/Component/Generate/AbstractConfig.php b/app/Component/Generate/AbstractConfig.php deleted file mode 100644 index 7a61f26..0000000 --- a/app/Component/Generate/AbstractConfig.php +++ /dev/null @@ -1,30 +0,0 @@ -getSpaces(2) . implode("\n" . $this->getSpaces(2), $this->getContent()); - return [ - "name" => $this->getName(), - 'params' => $this->getParams(), - 'return' => $this->getReturn(), - 'content' => $content, - 'comments' => $this->getComment(), - ]; - } - - /** - * @param int $level - * - * @return string - */ - public function getSpaces(int $level = 1): string - { - return str_repeat(' ', $level * 4); - } - - /** - * @param string $name - * @param int $level - * - * @return string - */ - public function throwExceptionForError(string $name, int $level = 1): string - { - return $this->getSpaces($level) . "throw new {$this->getExceptionName()}({$this->getError()->getClassname()}::{$this->getError()->getConstant($name)});"; - } - - /** - * @var string - */ - protected $name; - - /** - * @var string - */ - protected $exceptionName; - - /** - * @var ErrorCodeBuildCollection - */ - protected $error; - - /** - * @return ErrorCodeBuildCollection - */ - public function getError(): ErrorCodeBuildCollection - { - return $this->error; - } - - /** - * @param ErrorCodeBuildCollection $error - * - * @return BaseActionBuild - */ - public function setError(ErrorCodeBuildCollection $error): BaseActionBuild - { - $this->error = $error; - return $this; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @param string $name - * - * @return BaseActionBuild - */ - public function setName(string $name): BaseActionBuild - { - $this->name = $name; - return $this; - } - - /** - * @return string - */ - public function getExceptionName(): string - { - return $this->exceptionName; - } - - /** - * @param string $exceptionName - * - * @return BaseActionBuild - */ - public function setExceptionName(string $exceptionName): BaseActionBuild - { - $this->exceptionName = $exceptionName; - return $this; - } -} diff --git a/app/Component/Generate/Build/Action/Controller/BaseActionControllerBuild.php b/app/Component/Generate/Build/Action/Controller/BaseActionControllerBuild.php deleted file mode 100644 index d667e42..0000000 --- a/app/Component/Generate/Build/Action/Controller/BaseActionControllerBuild.php +++ /dev/null @@ -1,79 +0,0 @@ -getValidateParse()->parse(); - } - - /** - * @var string - */ - private $serviceName; - - /** - * @var BaseValidateParse - */ - private $validateParse; - - - /** - * @return string - */ - public function getServiceName(): string - { - return $this->serviceName; - } - - /** - * @param string $serviceName - * - * @return BaseActionControllerBuild - */ - public function setServiceName(string $serviceName): BaseActionControllerBuild - { - $this->serviceName = $serviceName; - return $this; - } - - /** - * @return BaseValidateParse - */ - public function getValidateParse(): BaseValidateParse - { - return $this->validateParse; - } - - /** - * @param BaseValidateParse $validateParse - * - * @return BaseActionControllerBuild - */ - public function setValidateParse(BaseValidateParse $validateParse): BaseActionControllerBuild - { - $this->validateParse = $validateParse; - return $this; - } -} diff --git a/app/Component/Generate/Build/Action/Controller/Hyperf/DefaultActionControllerBuild.php b/app/Component/Generate/Build/Action/Controller/Hyperf/DefaultActionControllerBuild.php deleted file mode 100644 index b3eaff2..0000000 --- a/app/Component/Generate/Build/Action/Controller/Hyperf/DefaultActionControllerBuild.php +++ /dev/null @@ -1,24 +0,0 @@ -'.$this->getServiceName().'->'.$this->getName().'($params);', - 'return $this->success([]);' - ]; - } -} diff --git a/app/Component/Generate/Build/Action/Controller/Hyperf/DetailActionControllerBuild.php b/app/Component/Generate/Build/Action/Controller/Hyperf/DetailActionControllerBuild.php deleted file mode 100644 index 0129505..0000000 --- a/app/Component/Generate/Build/Action/Controller/Hyperf/DetailActionControllerBuild.php +++ /dev/null @@ -1,26 +0,0 @@ -getValidateParse()->getParams(); - return [ - '$params = Context::get("validator.data", []);', - '$data = $this->'.$this->getServiceName().'->'.$this->getName().'($params);', - 'return $this->success($data);' - ]; - } -} diff --git a/app/Component/Generate/Build/Action/Controller/Hyperf/ListActionControllerBuild.php b/app/Component/Generate/Build/Action/Controller/Hyperf/ListActionControllerBuild.php deleted file mode 100644 index fd6d68f..0000000 --- a/app/Component/Generate/Build/Action/Controller/Hyperf/ListActionControllerBuild.php +++ /dev/null @@ -1,35 +0,0 @@ -getValidateParse()->getParams(); - return [ - '$params = Context::get("validator.data", []);', - '$page = new PageEntity($params);', - '$data = $this->' . $this->getServiceName() . '->' . $this->getName() . '($params, ["*"], $page);', - 'return $this->success($data);', - ]; - } -} diff --git a/app/Component/Generate/Build/Action/Controller/ValidateParse/ApidogValidateParse.php b/app/Component/Generate/Build/Action/Controller/ValidateParse/ApidogValidateParse.php deleted file mode 100644 index f67c43d..0000000 --- a/app/Component/Generate/Build/Action/Controller/ValidateParse/ApidogValidateParse.php +++ /dev/null @@ -1,19 +0,0 @@ -getPath() . '", summary="' . $this->getDescription() . '")', - '@Body(rules={', - $rule, - '})', - ]; - } -} diff --git a/app/Component/Generate/Build/Action/Controller/ValidateParse/BaseValidateParse.php b/app/Component/Generate/Build/Action/Controller/ValidateParse/BaseValidateParse.php deleted file mode 100644 index ff5705d..0000000 --- a/app/Component/Generate/Build/Action/Controller/ValidateParse/BaseValidateParse.php +++ /dev/null @@ -1,85 +0,0 @@ -params; - } - - /** - * @param array $params - * - * @return BaseValidateParse - */ - public function setParams(array $params): BaseValidateParse - { - $this->params = $params; - return $this; - } - - /** - * @return string - */ - public function getDescription(): string - { - return $this->description; - } - - /** - * @param string $description - * - * @return BaseValidateParse - */ - public function setDescription(string $description): BaseValidateParse - { - $this->description = $description; - return $this; - } - - /** - * @return string - */ - public function getPath(): string - { - return $this->path; - } - - /** - * @param string $path - * - * @return BaseValidateParse - */ - public function setPath(string $path): BaseValidateParse - { - $this->path = $path; - return $this; - } - - /** - * @return array - */ - abstract public function parse(): array; -} diff --git a/app/Component/Generate/Build/Action/Controller/ValidateParse/EasyswoolApidogValidateParse.php b/app/Component/Generate/Build/Action/Controller/ValidateParse/EasyswoolApidogValidateParse.php deleted file mode 100644 index bd84fdf..0000000 --- a/app/Component/Generate/Build/Action/Controller/ValidateParse/EasyswoolApidogValidateParse.php +++ /dev/null @@ -1,11 +0,0 @@ - 'params', 'type' => 'array', 'comment' => '参数'], - ]; - } - - public function getComment(): array - { - return [ - $this->getDescription(), - ]; - } - - /** - * @var ModelBuildCollection - */ - protected $model; - - /** - * @var string - */ - protected $description; - - /** - * @return ModelBuildCollection - */ - public function getModel(): ModelBuildCollection - { - return $this->model; - } - - /** - * @param ModelBuildCollection $model - * - * @return BaseActionServiceBuild - */ - public function setModel(ModelBuildCollection $model): BaseActionServiceBuild - { - $this->model = $model; - return $this; - } - - /** - * @return string - */ - public function getDescription(): string - { - return $this->description; - } - - /** - * @param string $description - * - * @return BaseActionServiceBuild - */ - public function setDescription(string $description): BaseActionServiceBuild - { - $this->description = $description; - return $this; - } -} diff --git a/app/Component/Generate/Build/Action/Service/Hyperf/ChangeActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/ChangeActionServiceBuild.php deleted file mode 100644 index 16ca518..0000000 --- a/app/Component/Generate/Build/Action/Service/Hyperf/ChangeActionServiceBuild.php +++ /dev/null @@ -1,31 +0,0 @@ -getModel()->getPrimaryKey(); - return [ - "\$where = ['{$primaryKey}' => \$params['{$primaryKey}']];", - "unset(\$params['{$primaryKey}']);", - "\$models = {$this->getModel()->getClassname()}::findAllCondition(\$where);", - "if (count(\$models) !== count(\$params['{$primaryKey}'])) {", - $this->throwExceptionForError('notFound'), - '}', - "\$status = {$this->getModel()->getClassname()}::updateCondition(\$where, \$params);", - 'if (!$status) {', - $this->throwExceptionForError('update'), - '}', - 'return $status;', - ]; - } - - public function getReturn(): string - { - return 'int'; - } -} diff --git a/app/Component/Generate/Build/Action/Service/Hyperf/CreateActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/CreateActionServiceBuild.php deleted file mode 100644 index 503657c..0000000 --- a/app/Component/Generate/Build/Action/Service/Hyperf/CreateActionServiceBuild.php +++ /dev/null @@ -1,26 +0,0 @@ -getModel()->getClassname()}();", - '$status = $model->insert($params);', - 'if (!$status) {', - $this->throwExceptionForError($this->getName()), - '}', - 'return $model->toArray();', - ]; - } - - public function getReturn(): string - { - return 'array'; - } -} diff --git a/app/Component/Generate/Build/Action/Service/Hyperf/DefaultActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/DefaultActionServiceBuild.php deleted file mode 100644 index 07ee795..0000000 --- a/app/Component/Generate/Build/Action/Service/Hyperf/DefaultActionServiceBuild.php +++ /dev/null @@ -1,23 +0,0 @@ -getError()->getConstant($this->getName()))) { - return []; - } - return [ - $this->throwExceptionForError($this->getName()), - ]; - } - - public function getReturn(): string - { - return 'array'; - } -} diff --git a/app/Component/Generate/Build/Action/Service/Hyperf/DetailActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/DetailActionServiceBuild.php deleted file mode 100644 index d406fbb..0000000 --- a/app/Component/Generate/Build/Action/Service/Hyperf/DetailActionServiceBuild.php +++ /dev/null @@ -1,30 +0,0 @@ -findOne($params, $field);', - 'return $this->formatModel($result->toArray());', - ]; - } - - public function getParams(): array - { - return [ - ['name' => 'params', 'type' => 'array', 'comment' => '条件'], - ['name' => 'field', 'type' => 'array', 'default' => ['*'], 'comment' => '字段'], - ]; - } - - public function getReturn(): string - { - return 'array'; - } -} diff --git a/app/Component/Generate/Build/Action/Service/Hyperf/FindOneActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/FindOneActionServiceBuild.php deleted file mode 100644 index baca2bd..0000000 --- a/app/Component/Generate/Build/Action/Service/Hyperf/FindOneActionServiceBuild.php +++ /dev/null @@ -1,32 +0,0 @@ -getModel()->getClassname()}::findOneCondition(\$params, \$field);", - 'if (!$model) {', - $this->throwExceptionForError('notFound'), - '}', - 'return $model;', - ]; - } - - public function getParams(): array - { - return [ - ['name' => 'params', 'type' => 'array', 'comment' => '条件'], - ['name' => 'field', 'type' => 'array', 'default' => ['*'], 'comment' => '字段'], - ]; - } - - public function getReturn(): string - { - return $this->getModel()->getClassname(); - } -} diff --git a/app/Component/Generate/Build/Action/Service/Hyperf/FormatModelActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/FormatModelActionServiceBuild.php deleted file mode 100644 index 2184098..0000000 --- a/app/Component/Generate/Build/Action/Service/Hyperf/FormatModelActionServiceBuild.php +++ /dev/null @@ -1,35 +0,0 @@ -getName()} method.", - 'return $result;', - ]; - } - - public function getMethod(): array - { - $method = parent::getMethod(); - $method['protected'] = true; - return $method; - } - - public function getParams(): array - { - return [ - ['name' => 'result', 'type' => 'array', 'comment' => '数据'], - ]; - } - - public function getReturn(): string - { - return 'array'; - } -} diff --git a/app/Component/Generate/Build/Action/Service/Hyperf/ListActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/ListActionServiceBuild.php deleted file mode 100644 index 4ad81d9..0000000 --- a/app/Component/Generate/Build/Action/Service/Hyperf/ListActionServiceBuild.php +++ /dev/null @@ -1,46 +0,0 @@ -getModel()->getClassname()}::query();", - '$query->select($field);', - "\$query->where(['enable' => SoftDeleted::ENABLE]);", - ]; - // 判断 条件 search - $data[] = '$results = $pageEntity ? $this->page($query, $pageEntity) : $query->get()->all();'; - $data[] = 'return $this->toArray($results, [$this, "formatModel"]);'; - return $data; - } - - public function getParams(): array - { - return [ - ['name' => 'params', 'type' => 'array', 'default' => [], 'comment' => '条件'], - ['name' => 'field', 'type' => 'array', 'default' => ['*'], 'comment' => '字段' ], - ['name' => 'pageEntity', 'type' => '?PageEntity', 'default' => null, 'comment' => '分页'], - ]; - } - - public function getReturn(): string - { - return 'array'; - } -} diff --git a/app/Component/Generate/Build/Action/Service/Hyperf/RemoveActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/RemoveActionServiceBuild.php deleted file mode 100644 index e568a66..0000000 --- a/app/Component/Generate/Build/Action/Service/Hyperf/RemoveActionServiceBuild.php +++ /dev/null @@ -1,25 +0,0 @@ -getModel()->getClassname()}::softDeleteCondition(\$params);", - 'if (!$status) {', - $this->throwExceptionForError($this->getName()), - '}', - 'return $status;', - ]; - } - - public function getReturn(): string - { - return 'int'; - } -} diff --git a/app/Component/Generate/Build/Action/Service/Hyperf/UpdateActionServiceBuild.php b/app/Component/Generate/Build/Action/Service/Hyperf/UpdateActionServiceBuild.php deleted file mode 100644 index a76a3c3..0000000 --- a/app/Component/Generate/Build/Action/Service/Hyperf/UpdateActionServiceBuild.php +++ /dev/null @@ -1,27 +0,0 @@ -getModel()->getPrimaryKey(); - return [ - "\$model = \$this->findOne(['{$primaryKey}' => \$params['{$primaryKey}']]);", - '$status = $model->update($params);', - 'if (!$status) {', - $this->throwExceptionForError($this->getName()), - '}', - 'return $model->toArray();', - ]; - } - - public function getReturn(): string - { - return 'array'; - } -} diff --git a/app/Component/Generate/Build/BaseBuild.php b/app/Component/Generate/Build/BaseBuild.php deleted file mode 100644 index e55d458..0000000 --- a/app/Component/Generate/Build/BaseBuild.php +++ /dev/null @@ -1,115 +0,0 @@ -config; - } - - /** - * @param BuildConfig $config - * - * @return BaseBuild - */ - public function setConfig(BuildConfig $config): BaseBuild - { - $this->config = $config; - return $this; - } - - /** - * @return GenerateCodeEntity - */ - public function getGenerateCodeEntity(): GenerateCodeEntity - { - return $this->generateCodeEntity; - } - - /** - * @param GenerateCodeEntity $generateCodeEntity - * - * @return BaseBuild - */ - public function setGenerateCodeEntity(GenerateCodeEntity $generateCodeEntity): BaseBuild - { - $this->generateCodeEntity = $generateCodeEntity; - return $this; - } - - /** - * @param ClassConfig $config - * @param string $path - * - * @return string - * @throws Exception - */ - protected function output(ClassConfig $config, string $path): string - { - $generate = new Generate(); - $generate->setPath($this->getRoot() . '/' . $path); - $generate->setConfig($config); - return $generate->output('php'); - } - - /** - * @param string $name - * - * @return string - */ - protected function getNamespace(string $name): string - { - return implode('\\', array_map(function ($str) { - return StringHelper::ucfirst($str); - }, StringHelper::explode($name, '/'))); - } - - /** - * @return string - */ - public function getRoot(): string - { - return $this->root; - } - - /** - * @param string $root - * - * @return BaseBuild - */ - public function setRoot(string $root): BaseBuild - { - $this->root = $root; - return $this; - } - - abstract public function build(); -} diff --git a/app/Component/Generate/Build/Collection/BaseBuildCollection.php b/app/Component/Generate/Build/Collection/BaseBuildCollection.php deleted file mode 100644 index 05cd819..0000000 --- a/app/Component/Generate/Build/Collection/BaseBuildCollection.php +++ /dev/null @@ -1,80 +0,0 @@ -class; - } - - /** - * @param string $class - * - * @return BaseBuildCollection - */ - public function setClass(string $class): BaseBuildCollection - { - $this->class = $class; - return $this; - } - - /** - * @return string - */ - public function getClassname(): string - { - return $this->classname; - } - - /** - * @param string $classname - * - * @return BaseBuildCollection - */ - public function setClassname(string $classname): BaseBuildCollection - { - $this->classname = $classname; - return $this; - } - - /** - * @return string - */ - public function getFile(): string - { - return $this->file; - } - - /** - * @param string $file - * - * @return BaseBuildCollection - */ - public function setFile(string $file): BaseBuildCollection - { - $this->file = $file; - return $this; - } -} diff --git a/app/Component/Generate/Build/Collection/ControllerBuildCollection.php b/app/Component/Generate/Build/Collection/ControllerBuildCollection.php deleted file mode 100644 index 39fac6a..0000000 --- a/app/Component/Generate/Build/Collection/ControllerBuildCollection.php +++ /dev/null @@ -1,30 +0,0 @@ -rout; - } - - /** - * @param array $rout - * - * @return ControllerBuildCollection - */ - public function setRout(array $rout): ControllerBuildCollection - { - $this->rout = $rout; - return $this; - } -} diff --git a/app/Component/Generate/Build/Collection/ErrorCodeBuildCollection.php b/app/Component/Generate/Build/Collection/ErrorCodeBuildCollection.php deleted file mode 100644 index 0a9fc69..0000000 --- a/app/Component/Generate/Build/Collection/ErrorCodeBuildCollection.php +++ /dev/null @@ -1,42 +0,0 @@ -constants; - } - - /** - * @param array $constants - * - * @return ErrorCodeBuildCollection - */ - public function setConstants(array $constants): ErrorCodeBuildCollection - { - $this->constants = $constants; - return $this; - } - - /** - * @param string $path - * - * @return string - */ - public function getConstant(string $path): string - { - return ArrayHelper::get($this->getConstants(), $path); - } -} diff --git a/app/Component/Generate/Build/Collection/ModelBuildCollection.php b/app/Component/Generate/Build/Collection/ModelBuildCollection.php deleted file mode 100644 index 17c784b..0000000 --- a/app/Component/Generate/Build/Collection/ModelBuildCollection.php +++ /dev/null @@ -1,30 +0,0 @@ -primaryKey; - } - - /** - * @param string $primaryKey - * - * @return ModelBuildCollection - */ - public function setPrimaryKey(string $primaryKey): ModelBuildCollection - { - $this->primaryKey = $primaryKey; - return $this; - } -} diff --git a/app/Component/Generate/Build/Config/BuildActionClassConfig.php b/app/Component/Generate/Build/Config/BuildActionClassConfig.php deleted file mode 100644 index b7808cb..0000000 --- a/app/Component/Generate/Build/Config/BuildActionClassConfig.php +++ /dev/null @@ -1,82 +0,0 @@ -namespace; - } - - /** - * @param string $namespace - * - * @return BuildActionClassConfig - */ - public function setNamespace(string $namespace): BuildActionClassConfig - { - $this->namespace = $namespace; - return $this; - } - - /** - * @return string - */ - public function getSuffix(): string - { - return $this->suffix; - } - - /** - * @param string $suffix - * - * @return BuildActionClassConfig - */ - public function setSuffix(string $suffix): BuildActionClassConfig - { - $this->suffix = $suffix; - return $this; - } - - /** - * @return string|null - */ - public function getFirstNamespace(): ?string - { - return $this->firstNamespace; - } - - /** - * @param string|null $firstNamespace - * - * @return BuildActionClassConfig - */ - public function setFirstNamespace(?string $firstNamespace): BuildActionClassConfig - { - $this->firstNamespace = $firstNamespace; - return $this; - } -} diff --git a/app/Component/Generate/Build/Config/BuildActionConfig.php b/app/Component/Generate/Build/Config/BuildActionConfig.php deleted file mode 100644 index be8bb8f..0000000 --- a/app/Component/Generate/Build/Config/BuildActionConfig.php +++ /dev/null @@ -1,58 +0,0 @@ -service; - } - - /** - * @param BuildActionClassConfig $service - * - * @return BuildActionConfig - */ - public function setService(BuildActionClassConfig $service): BuildActionConfig - { - $this->service = $service; - return $this; - } - - /** - * @return BuildActionClassConfig - */ - public function getController(): BuildActionClassConfig - { - return $this->controller; - } - - /** - * @param BuildActionClassConfig $controller - * - * @return BuildActionConfig - */ - public function setController(BuildActionClassConfig $controller): BuildActionConfig - { - $this->controller = $controller; - return $this; - } -} diff --git a/app/Component/Generate/Build/Config/BuildConfig.php b/app/Component/Generate/Build/Config/BuildConfig.php deleted file mode 100644 index c10ecc8..0000000 --- a/app/Component/Generate/Build/Config/BuildConfig.php +++ /dev/null @@ -1,157 +0,0 @@ -default; - } - - /** - * @param BuildDefaultConfig $default - * - * @return BuildConfig - */ - public function setDefault(BuildDefaultConfig $default): BuildConfig - { - $this->default = $default; - return $this; - } - - /** - * @return BuildControllerConfig - */ - public function getController(): BuildControllerConfig - { - return $this->controller; - } - - /** - * @param BuildControllerConfig $controller - * - * @return BuildConfig - */ - public function setController(BuildControllerConfig $controller): BuildConfig - { - $this->controller = $controller; - return $this; - } - - /** - * @return BuildActionConfig - */ - public function getAction(): BuildActionConfig - { - return $this->action; - } - - /** - * @param BuildActionConfig $action - * - * @return BuildConfig - */ - public function setAction(BuildActionConfig $action): BuildConfig - { - $this->action = $action; - return $this; - } - - /** - * @return BuildErrorCodeConfig - */ - public function getErrorCode(): BuildErrorCodeConfig - { - return $this->errorCode; - } - - /** - * @param BuildErrorCodeConfig $errorCode - * - * @return BuildConfig - */ - public function setErrorCode(BuildErrorCodeConfig $errorCode): BuildConfig - { - $this->errorCode = $errorCode; - return $this; - } - - /** - * @return BuildServiceConfig - */ - public function getService(): BuildServiceConfig - { - return $this->service; - } - - /** - * @param BuildServiceConfig $service - * - * @return BuildConfig - */ - public function setService(BuildServiceConfig $service): BuildConfig - { - $this->service = $service; - return $this; - } - - /** - * @return BuildExceptionConfig - */ - public function getException(): BuildExceptionConfig - { - return $this->exception; - } - - /** - * @param BuildExceptionConfig $exception - * - * @return BuildConfig - */ - public function setException(BuildExceptionConfig $exception): BuildConfig - { - $this->exception = $exception; - return $this; - } -} diff --git a/app/Component/Generate/Build/Config/BuildControllerConfig.php b/app/Component/Generate/Build/Config/BuildControllerConfig.php deleted file mode 100644 index aa32cb8..0000000 --- a/app/Component/Generate/Build/Config/BuildControllerConfig.php +++ /dev/null @@ -1,157 +0,0 @@ -inheritance; - } - - /** - * @param string $inheritance - * - * @return BuildControllerConfig - */ - public function setInheritance(string $inheritance): BuildControllerConfig - { - $this->inheritance = $inheritance; - return $this; - } - - /** - * @return callable - */ - public function getProperties(): callable - { - return $this->properties; - } - - /** - * @param callable|null $properties - * - * @return BuildControllerConfig - */ - public function setProperties(?callable $properties): BuildControllerConfig - { - $this->properties = $properties; - return $this; - } - - /** - * @return string - */ - public function getAnnotationValidateParse(): string - { - return $this->annotationValidateParse; - } - - /** - * @param string $annotationValidateParse - * - * @return BuildControllerConfig - */ - public function setAnnotationValidateParse(string $annotationValidateParse): BuildControllerConfig - { - $this->annotationValidateParse = $annotationValidateParse; - return $this; - } - - /** - * @return array - */ - public function getUses(): array - { - return $this->uses; - } - - /** - * @param array $uses - * - * @return BuildControllerConfig - */ - public function setUses(array $uses): BuildControllerConfig - { - $this->uses = $uses; - return $this; - } - - /** - * @return callable - */ - public function getComment(): callable - { - return $this->comment; - } - - /** - * @param callable $comment - * - * @return BuildControllerConfig - */ - public function setComment(callable $comment): BuildControllerConfig - { - $this->comment = $comment; - return $this; - } - - /** - * @return string - */ - public function getPrefix(): string - { - return $this->prefix; - } - - /** - * @param string $prefix - * - * @return BuildControllerConfig - */ - public function setPrefix(string $prefix): BuildControllerConfig - { - $this->prefix = $prefix; - return $this; - } -} diff --git a/app/Component/Generate/Build/Config/BuildDefaultBaseConfig.php b/app/Component/Generate/Build/Config/BuildDefaultBaseConfig.php deleted file mode 100644 index 03b37a8..0000000 --- a/app/Component/Generate/Build/Config/BuildDefaultBaseConfig.php +++ /dev/null @@ -1,33 +0,0 @@ -path; - } - - /** - * @param string $path - * - * @return BuildDefaultBaseConfig - */ - public function setPath(string $path): BuildDefaultBaseConfig - { - $this->path = $path; - return $this; - } -} diff --git a/app/Component/Generate/Build/Config/BuildDefaultConfig.php b/app/Component/Generate/Build/Config/BuildDefaultConfig.php deleted file mode 100644 index ab24986..0000000 --- a/app/Component/Generate/Build/Config/BuildDefaultConfig.php +++ /dev/null @@ -1,109 +0,0 @@ -controller; - } - - /** - * @param BuildDefaultBaseConfig $controller - * - * @return BuildDefaultConfig - */ - public function setController(BuildDefaultBaseConfig $controller): BuildDefaultConfig - { - $this->controller = $controller; - return $this; - } - - /** - * @return BuildDefaultBaseConfig - */ - public function getService(): BuildDefaultBaseConfig - { - return $this->service; - } - - /** - * @param BuildDefaultBaseConfig $service - * - * @return BuildDefaultConfig - */ - public function setService(BuildDefaultBaseConfig $service): BuildDefaultConfig - { - $this->service = $service; - return $this; - } - - /** - * @return BuildDefaultBaseConfig - */ - public function getErrorCode(): BuildDefaultBaseConfig - { - return $this->errorCode; - } - - /** - * @param BuildDefaultBaseConfig $errorCode - * - * @return BuildDefaultConfig - */ - public function setErrorCode(BuildDefaultBaseConfig $errorCode): BuildDefaultConfig - { - $this->errorCode = $errorCode; - return $this; - } - - /** - * @return Link[] - */ - public function getAction(): array - { - return $this->action; - } - - /** - * @param Link[] $action - * - * @return BuildDefaultConfig - */ - public function setAction(array $action): BuildDefaultConfig - { - $this->action = $action; - return $this; - } -} diff --git a/app/Component/Generate/Build/Config/BuildErrorCodeConfig.php b/app/Component/Generate/Build/Config/BuildErrorCodeConfig.php deleted file mode 100644 index 371a63e..0000000 --- a/app/Component/Generate/Build/Config/BuildErrorCodeConfig.php +++ /dev/null @@ -1,82 +0,0 @@ -prefix; - } - - /** - * @param array $prefix - * - * @return BuildErrorCodeConfig - */ - public function setPrefix(array $prefix): BuildErrorCodeConfig - { - $this->prefix = $prefix; - return $this; - } - - /** - * @return string - */ - public function getInheritance(): string - { - return $this->inheritance; - } - - /** - * @param string $inheritance - * - * @return BuildErrorCodeConfig - */ - public function setInheritance(string $inheritance): BuildErrorCodeConfig - { - $this->inheritance = $inheritance; - return $this; - } - - /** - * @return string - */ - public function getUse(): string - { - return $this->use; - } - - /** - * @param string $use - * - * @return BuildErrorCodeConfig - */ - public function setUse(string $use): BuildErrorCodeConfig - { - $this->use = $use; - return $this; - } -} diff --git a/app/Component/Generate/Build/Config/BuildExceptionConfig.php b/app/Component/Generate/Build/Config/BuildExceptionConfig.php deleted file mode 100644 index a6d4a10..0000000 --- a/app/Component/Generate/Build/Config/BuildExceptionConfig.php +++ /dev/null @@ -1,58 +0,0 @@ -inheritance; - } - - /** - * @param string $inheritance - * - * @return BuildExceptionConfig - */ - public function setInheritance(string $inheritance): BuildExceptionConfig - { - $this->inheritance = $inheritance; - return $this; - } - - /** - * @return string - */ - public function getUse(): string - { - return $this->use; - } - - /** - * @param string $use - * - * @return BuildExceptionConfig - */ - public function setUse(string $use): BuildExceptionConfig - { - $this->use = $use; - return $this; - } -} diff --git a/app/Component/Generate/Build/Config/BuildServiceConfig.php b/app/Component/Generate/Build/Config/BuildServiceConfig.php deleted file mode 100644 index 181130a..0000000 --- a/app/Component/Generate/Build/Config/BuildServiceConfig.php +++ /dev/null @@ -1,58 +0,0 @@ -inheritance; - } - - /** - * @param string $inheritance - * - * @return BuildServiceConfig - */ - public function setInheritance(string $inheritance): BuildServiceConfig - { - $this->inheritance = $inheritance; - return $this; - } - - /** - * @return string - */ - public function getUse(): string - { - return $this->use; - } - - /** - * @param string $use - * - * @return BuildServiceConfig - */ - public function setUse(string $use): BuildServiceConfig - { - $this->use = $use; - return $this; - } -} diff --git a/app/Component/Generate/Build/ControllerBuild.php b/app/Component/Generate/Build/ControllerBuild.php deleted file mode 100644 index ea64af2..0000000 --- a/app/Component/Generate/Build/ControllerBuild.php +++ /dev/null @@ -1,171 +0,0 @@ -service; - } - - /** - * @return ErrorCodeBuildCollection - */ - public function getErrorCode(): ErrorCodeBuildCollection - { - return $this->errorCode; - } - - /** - * @param ErrorCodeBuildCollection $errorCode - * - * @return ControllerBuild - */ - public function setErrorCode(ErrorCodeBuildCollection $errorCode): ControllerBuild - { - $this->errorCode = $errorCode; - return $this; - } - - /** - * @param BaseBuildCollection $service - * - * @return ControllerBuild - */ - public function setService(BaseBuildCollection $service): ControllerBuild - { - $this->service = $service; - return $this; - } - - protected function getActionService(string $name, array $form, string $description = ''): array - { - $config = $this->getConfig()->getAction()->getController(); - $classname = null; - if (!empty($config->getFirstNamespace())) { - $classname = $config->getFirstNamespace() . '\\' . StringHelper::ucfirst($name) . $config->getSuffix(); - if (!class_exists($classname)) { - $classname = null; - } - } - if ($classname === null) { - $classname = $config->getNamespace() . '\\' . StringHelper::ucfirst($name) . $config->getSuffix(); - } - if (!class_exists($classname)) { - $classname = $config->getNamespace() . '\\Default' . $config->getSuffix(); - } - - // path - $directory = str_replace($this->getConfig()->getDefault()->getController()->getPath(), '', $this->getGenerateCodeEntity()->getController()); - $controllerPath = StringHelper::dirname($directory); - $paths = StringHelper::explode($controllerPath, '/', true, true); - $prefix = $this->getConfig()->getController()->getPrefix(); - if (!StringHelper::isEmpty($prefix)) { - array_unshift($paths, $prefix); - } - $paths[] = StringHelper::basename($directory, 'Controller'); - $paths[] = $name; - - $validateParse = $this->getConfig()->getController()->getAnnotationValidateParse(); - /** - * @var BaseValidateParse $parse - */ - $parse = new $validateParse; - $parse->setParams($form)->setPath(implode('/', array_map(function ($path) { - return StringHelper::strtolower($path); - }, $paths)))->setDescription($this->getGenerateCodeEntity()->getName() . $description); - - /** - * @var BaseActionControllerBuild $model - */ - $model = new $classname; - $model->setName($name) - ->setValidateParse($parse) - ->setError($this->getErrorCode()) - ->setExceptionName($this->getConfig()->getException()->getInheritance()) - ->setServiceName(lcfirst($this->getService()->getClassname())); - return [$model->getMethod(), $model->getUses(), $parse->getPath()]; - } - - /** - * @return ControllerBuildCollection - * @throws Exception - */ - public function build(): ControllerBuildCollection - { - $properties = call_user_func($this->getConfig()->getController()->getProperties(), $this); - $uses = $this->getConfig()->getController()->getUses(); - $uses[] = $this->getService()->getClass(); - $routs = $methods = $actions = []; - - // todo 如果有 查询 则有 list - if (1 || !empty($this->getGenerateCodeEntity()->getSearch())) { -// [$method, $use] = $this->getActionService('list', $this->getGenerateCodeEntity()->getSearch(), '列表'); - [$method, $use, $rout] = $this->getActionService('list', [], '列表'); - $methods[] = $method; - $uses = ArrayHelper::merge($uses, $use); - $routs[] = $rout; - } - - foreach ($this->getGenerateCodeEntity()->getActions() as $action) { - if (in_array($action->getPath(), $actions)) { - continue; - } -// [$method, $use] = $this->getActionService($action->getPath(), $action->getForm()->getItem(), $action->getName()); - [$method, $use, $rout] = $this->getActionService($action->getPath(), [], $action->getName()); - $methods[] = $method; - $uses = ArrayHelper::merge($uses, $use); - $actions[] = $action->getPath(); - $routs[] = $rout; - } - - $class = $this->getNamespace($this->getGenerateCodeEntity()->getController()); - $classname = StringHelper::basename($class); - $namespace = StringHelper::dirname($class); - $comment = [ - "class {$classname}", - "@package {$namespace}", - ]; - $comment = ArrayHelper::merge($comment, call_user_func($this->getConfig()->getController()->getComment(), $this)); - $config = [ - 'namespace' => $namespace, - 'classname' => $classname, - 'uses' => $uses, - 'comments' => $comment, - 'inheritance' => $this->getConfig()->getController()->getInheritance(), - 'properties' => $properties, - 'methods' => $methods, - ]; - $file = $this->output(new ClassConfig($config), StringHelper::dirname($this->getGenerateCodeEntity()->getController())); - return new ControllerBuildCollection([ - 'classname' => $classname, - 'class' => $class, - 'rout' => $routs, - 'file' => $file, - ]); - } -} diff --git a/app/Component/Generate/Build/ErrorCodeBuild.php b/app/Component/Generate/Build/ErrorCodeBuild.php deleted file mode 100644 index a7d838d..0000000 --- a/app/Component/Generate/Build/ErrorCodeBuild.php +++ /dev/null @@ -1,187 +0,0 @@ -model; - } - - /** - * @param ModelBuildCollection $model - * - * @return ErrorCodeBuild - */ - public function setModel(ModelBuildCollection $model): ErrorCodeBuild - { - $this->model = $model; - return $this; - } - - /** - * 文件名称 - * @return string - */ - protected function getName(): string - { - return $this->getModel()->getClassname() . 'Error'; - } - - /** - * 获得 错误字段 值的 前缀 - * - * @param string $path - * - * @return array - */ - protected function getPrefix(string $path): array - { - $defaultPath = $this->getConfig()->getDefault()->getErrorCode()->getPath(); - $directory = str_replace($defaultPath, '', $path); - $errorPrefix = StringHelper::explode($directory, '/', true, true); - // default prefix - $prefix = ArrayHelper::get($this->getConfig()->getErrorCode()->getPrefix(), 'default', 'B-001'); - if (!empty($errorPrefix[0])) { - $appErrorPrefix = ArrayHelper::get($this->getConfig()->getErrorCode()->getPrefix(), StringHelper::strtolower($errorPrefix[0])); - if (!empty($appErrorPrefix)) { - $prefix = $appErrorPrefix; - $defaultPath .= "/{$errorPrefix[0]}"; - } - } - $scan = FileHelper::scan($this->getRoot() . '/' . $defaultPath); - $number = iterator_count($scan) + 1; - $prefix .= '-' . str_pad($number, 3, "0", STR_PAD_LEFT); - $errorPrefix[] = $this->getModel()->getClassname(); - array_unshift($errorPrefix, 'errors'); - return [ - 'value' => $prefix, - 'name' => implode("_", $errorPrefix), - ]; - } - - /*** - * 获得 常量 - * - * @param string $path - * - * @return array - */ - protected function getConstant(string $path): array - { - // prefix - $prefix = $this->getPrefix($path); - $constants = []; - $num = 1; - $isChange = false; - foreach ($this->getGenerateCodeEntity()->getActions() as $action) { - if (StringHelper::matchWildcard('change*', $action->getPath())) { - $isChange = true; - } - if (!in_array($action->getPath(), $this->allow) || !empty($constants[$action->getPath()])) { - continue; - } - $constantName = $action->getPath() . '_fail'; - $constantMessage = $action->getName() . '失败'; - $constants[$action->getPath()] = [ - 'name' => StringHelper::strtoupper($prefix['name'] . "_" . $constantName), - 'default' => $prefix['value'] . '-' . str_pad($num, 3, "0", STR_PAD_LEFT), - 'comments' => [ - '@Message("' . $this->getGenerateCodeEntity()->getName() . $constantMessage . '")', - ], - ]; - $num++; - } - - $constants['notFound'] = [ - 'name' => StringHelper::strtoupper($prefix['name'] . "_not_found"), - 'default' => $prefix['value'] . '-' . str_pad($num, 3, "0", STR_PAD_LEFT), - 'comments' => [ - '@Message("' . $this->getGenerateCodeEntity()->getName() . '不存在")', - ], - ]; - - // 修改的 归于 更新 - if ($isChange && empty($constants['update'])) { - $num++; - $constants['update'] = [ - 'name' => StringHelper::strtoupper($prefix['name'] . "_update_fail"), - 'default' => $prefix['value'] . '-' . str_pad($num, 3, "0", STR_PAD_LEFT), - 'comments' => [ - '@Message("' . $this->getGenerateCodeEntity()->getName() . '更新失败")', - ], - ]; - } - - return $constants; - } - - /** - * @return ErrorCodeBuildCollection - * @throws Exception - */ - public function build(): ErrorCodeBuildCollection - { - $defaultConfig = $this->getConfig()->getDefault(); - // 错误码 目录结构 基于 服务目录结构 - $errorCodePath = str_replace($defaultConfig->getService()->getPath(), $defaultConfig->getErrorCode()->getPath(), - $this->getGenerateCodeEntity()->getService()); - $path = StringHelper::dirname($errorCodePath); - $constants = $this->getConstant($path); - - $class = $this->getNamespace($path . '/' . $this->getName()); - $namespace = StringHelper::dirname($class); - - $config = [ - 'namespace' => $namespace, - 'classname' => $this->getName(), - 'uses' => [ - $this->getConfig()->getErrorCode()->getUse(), - ], - 'comments' => [ - "class {$this->getName()}", - "@package {$namespace}", - ], - 'inheritance' => $this->getConfig()->getErrorCode()->getInheritance(), - 'constants' => $constants, - ]; - $file = $this->output(new ClassConfig($config), $path); - return new ErrorCodeBuildCollection([ - 'classname' => $this->getName(), - 'class' => $class, - 'file' => $file, - 'constants' => ArrayHelper::getColumn($constants, 'name'), - ]); - } -} diff --git a/app/Component/Generate/Build/Model/Hyperf/ModelBuild.php b/app/Component/Generate/Build/Model/Hyperf/ModelBuild.php deleted file mode 100644 index f41a702..0000000 --- a/app/Component/Generate/Build/Model/Hyperf/ModelBuild.php +++ /dev/null @@ -1,21 +0,0 @@ -getNamespace($this->getGenerateCodeEntity()->getModel()); - $table = StringHelper::basename($class); - $model = new GenerateModel(); - $data = $model->create($table, $this->getGenerateCodeEntity()->getPool(), StringHelper::dirname($this->getGenerateCodeEntity()->getModel())); - return new ModelBuildCollection($data[$table]); - } -} diff --git a/app/Component/Generate/Build/ServiceBuild.php b/app/Component/Generate/Build/ServiceBuild.php deleted file mode 100644 index 1a9efe2..0000000 --- a/app/Component/Generate/Build/ServiceBuild.php +++ /dev/null @@ -1,165 +0,0 @@ -errorCode; - } - - /** - * @param ErrorCodeBuildCollection $errorCode - * - * @return ServiceBuild - */ - public function setErrorCode(ErrorCodeBuildCollection $errorCode): ServiceBuild - { - $this->errorCode = $errorCode; - return $this; - } - - /** - * @return ModelBuildCollection - */ - public function getModel(): ModelBuildCollection - { - return $this->model; - } - - /** - * @param ModelBuildCollection $model - * - * @return ServiceBuild - */ - public function setModel(ModelBuildCollection $model): ServiceBuild - { - $this->model = $model; - return $this; - } - - protected function getActionService(string $name, string $description = ''): array - { - $config = $this->getConfig()->getAction()->getService(); - $actionName = $name; - if (StringHelper::matchWildcard('change*', $name)) { - $name = 'change'; - } - - $classname = ''; - if (!empty($config->getFirstNamespace())) { - $classname = $config->getFirstNamespace() . '\\' . StringHelper::ucfirst($name) . $config->getSuffix(); - if (!class_exists($classname)) { - $classname = ''; - } - } - - if ($classname === '') { - $classname = $config->getNamespace() . '\\' . StringHelper::ucfirst($name) . $config->getSuffix(); - } - - if (!class_exists($classname)) { - $classname = $config->getNamespace() . '\\Default' . $config->getSuffix(); - } - /** - * @var BaseActionServiceBuild $model - */ - $model = new $classname; - $model->setModel($this->getModel()) - ->setError($this->getErrorCode()) - ->setName($actionName) - ->setExceptionName($this->getConfig()->getException()->getInheritance()) - ->setDescription($description); - return [$model->getMethod(), $model->getUses()]; - } - - /** - * @return BaseBuildCollection - * @throws \Exception - */ - public function build(): BaseBuildCollection - { - $uses = [ - $this->getModel()->getClass(), - $this->getErrorCode()->getClass(), - $this->getConfig()->getException()->getUse(), - $this->getConfig()->getService()->getUse(), - ]; - - $methods = $actions = []; - // todo 如果有 查询 则有 list - if (1 || !empty($this->getGenerateCodeEntity()->getSearch())) { - [$method, $use] = $this->getActionService('list', '列表'); - $methods[] = $method; - $uses = ArrayHelper::merge($uses, $use); - $actions[] = 'list'; - } - - foreach ($this->getGenerateCodeEntity()->getActions() as $action) { - if (in_array($action->getPath(), $actions)) { - continue; - } - [$method, $use] = $this->getActionService($action->getPath(), $action->getName()); - $methods[] = $method; - $uses = ArrayHelper::merge($uses, $use); - $actions[] = $action->getPath(); - } - - // findOne - if (in_array('update', $actions) || in_array('detail', $actions)) { - [$method, $use] = $this->getActionService('findOne', 'find one model'); - $methods[] = $method; - $uses = ArrayHelper::merge($uses, $use); - } - - // formatModel - if (in_array('list', $actions) || in_array('detail', $actions)) { - [$method, $use] = $this->getActionService('formatModel', '格式化'); - $methods[] = $method; - $uses = ArrayHelper::merge($uses, $use); - } - - $class = $this->getNamespace($this->getGenerateCodeEntity()->getService()); - $classname = StringHelper::basename($class); - $namespace = StringHelper::dirname($class); - $config = [ - 'namespace' => $namespace, - 'classname' => $classname, - 'uses' => $uses, - 'comments' => [ - "class {$classname}", - "@package {$namespace}", - ], - 'inheritance' => $this->getConfig()->getService()->getInheritance(), - 'methods' => $methods, - ]; - $file = $this->output(new ClassConfig($config), StringHelper::dirname($this->getGenerateCodeEntity()->getService())); - return new BaseBuildCollection([ - 'classname' => $classname, - 'class' => $class, - 'file' => $file, - ]); - } -} diff --git a/app/Component/Generate/ClassFile/ClassBase.php b/app/Component/Generate/ClassFile/ClassBase.php deleted file mode 100644 index e8fd51a..0000000 --- a/app/Component/Generate/ClassFile/ClassBase.php +++ /dev/null @@ -1,235 +0,0 @@ -static; - } - - /** - * @param bool $static - * - * @return ClassBase - */ - public function setStatic(bool $static = true): ClassBase - { - $this->static = $static; - return $this; - } - - /** - * @return bool - */ - public function getPrivate(): bool - { - return $this->private; - } - - /** - * @param bool $private - * - * @return ClassBase - */ - public function setPrivate(bool $private): ClassBase - { - $this->private = $private; - if ($private === true) { - $this->setPublic(false); - $this->setProtected(false); - } - return $this; - } - - /** - * @return bool - */ - public function getProtected(): bool - { - return $this->protected; - } - - /** - * @param bool $protected - * - * @return ClassBase - */ - public function setProtected(bool $protected): ClassBase - { - $this->protected = $protected; - if ($protected === true) { - $this->setPublic(false); - $this->setPrivate(false); - } - return $this; - } - - /** - * @return bool - */ - public function getPublic(): bool - { - return $this->public; - } - - /** - * @param bool $public - * - * @return ClassBase - */ - public function setPublic(bool $public): ClassBase - { - $this->public = $public; - if ($public === true) { - $this->setProtected(false); - $this->setPrivate(false); - } - return $this; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @param string $name - * - * @return ClassBase - */ - public function setName(string $name): ClassBase - { - $this->name = $name; - return $this; - } - - /** - * @return array - */ - public function getComments(): array - { - return $this->comments; - } - - /** - * @param array $comments - * - * @return ClassBase - */ - public function setComments(array $comments): ClassBase - { - $this->comments = $comments; - return $this; - } - - /** - * @param string $comment - * - * @return ClassBase - */ - public function addComment(string $comment): ClassBase - { - $this->comments[] = $comment; - return $this; - } - - public function valueType($value): string - { - switch (gettype($value)) { - case 'boolean': - $value = 'bool'; - break; - case 'integer': - $value = 'int'; - break; - case 'double': - $value = 'float'; - break; - case 'NULL': - $value = 'null'; - break; - default: - break; - } - return $value; - } - - /** - * @param $value - * - * @return string - */ - public function getValueType($value): string - { - switch (gettype($value)) { - case 'boolean': - $value = $value ? 'true' : 'false'; - break; - case 'integer': - case 'double': - $value = (string)$value; - break; - case 'string': - $value = "'" . $value . "'"; - break; - case 'resource': - $value = '{resource}'; - break; - case 'NULL': - $value = 'null'; - break; - case 'unknown type': - $value = '{unknown}'; - break; - case 'array': - $value = json_encode($value); - break; - default: - break; - } - return $value; - } -} diff --git a/app/Component/Generate/ClassFile/ClassConfig.php b/app/Component/Generate/ClassFile/ClassConfig.php deleted file mode 100644 index af95146..0000000 --- a/app/Component/Generate/ClassFile/ClassConfig.php +++ /dev/null @@ -1,610 +0,0 @@ -namespace; - } - - /** - * @param string $namespace - * - * @return ClassConfig - */ - public function setNamespace(string $namespace): ClassConfig - { - $this->namespace = $namespace; - return $this; - } - - /** - * @return array - */ - public function getUses(): array - { - return $this->uses; - } - - /** - * @param array $uses - * - * @return ClassConfig - */ - public function setUses(array $uses): ClassConfig - { - $this->uses = $uses; - return $this; - } - - /** - * @return string - */ - public function getClassname(): string - { - return $this->classname; - } - - /** - * @param string $classname - * - * @return ClassConfig - */ - public function setClassname(string $classname): ClassConfig - { - $this->classname = $classname; - return $this; - } - - /** - * @return ?string - */ - public function getInheritance(): ?string - { - return $this->inheritance; - } - - /** - * @param string $inheritance - * - * @return ClassConfig - */ - public function setInheritance(string $inheritance): ClassConfig - { - $this->inheritance = $inheritance; - return $this; - } - - /** - * @return array - */ - public function getImplements(): array - { - return $this->implements; - } - - /** - * @param array $implements - * - * @return ClassConfig - */ - public function setImplements(array $implements): ClassConfig - { - $this->implements = $implements; - return $this; - } - - /** - * @return ClassMethod[] - */ - public function getMethods(): array - { - return $this->methods; - } - - /** - * @param ClassMethod[] $methods - * - * @return ClassConfig - */ - public function setMethods(array $methods): ClassConfig - { - $this->methods = $methods; - return $this; - } - - /** - * @return ClassProperty[] - */ - public function getProperties(): ?array - { - return $this->properties; - } - - /** - * @param ClassProperty[] $properties - * - * @return ClassConfig - */ - public function setProperties(array $properties): ClassConfig - { - $this->properties = $properties; - return $this; - } - - /** - * @return array - */ - public function getComments(): array - { - return $this->comments; - } - - /** - * @param array $comments - * - * @return ClassConfig - */ - public function setComments(array $comments): ClassConfig - { - $this->comments = $comments; - return $this; - } - - /** - * @return string - */ - public function getFileName(): string - { - return $this->getClassname(); - } - - /** - * @param string $use - * - * @return ClassConfig - */ - public function addUse(string $use): ClassConfig - { - $this->uses[] = $use; - return $this; - } - - /** - * @param string $comment - * - * @return ClassConfig - */ - public function addComment(string $comment): ClassConfig - { - $this->comments[] = $comment; - return $this; - } - - /** - * @param string $implement - * - * @return ClassConfig - */ - public function addImplement(string $implement): ClassConfig - { - $this->implements[] = $implement; - return $this; - } - - /** - * @param ClassMethod $classMethod - * - * @return ClassConfig - */ - public function addMethod(ClassMethod $classMethod): ClassConfig - { - $this->methods[] = $classMethod; - return $this; - } - - /** - * @param ClassProperty $classProperty - * - * @return ClassConfig - */ - public function addProperty(ClassProperty $classProperty): ClassConfig - { - $this->properties[] = $classProperty; - return $this; - } - - /** - * @param ClassConstant $constant - * - * @return ClassConfig - */ - public function addCont(ClassConstant $constant): ClassConfig - { - $this->constants[] = $constant; - return $this; - } - - /** - * @return bool - */ - public function getFinal(): bool - { - return $this->final; - } - - /** - * @param bool $final - * - * @return ClassConfig - */ - public function setFinal(bool $final): ClassConfig - { - $this->final = $final; - if ($final === true) { - $this->setAbstract(false); - } - return $this; - } - - /** - * @return bool - */ - public function getAbstract(): bool - { - return $this->abstract; - } - - /** - * @param bool $abstract - * - * @return ClassConfig - */ - public function setAbstract(bool $abstract): ClassConfig - { - $this->abstract = $abstract; - if ($abstract === true) { - $this->setFinal(false); - } - return $this; - } - - /** - * @return ClassConstant[] - */ - public function getConstants(): array - { - return $this->constants; - } - - /** - * @param ClassConstant[] $constants - * - * @return ClassConfig - */ - public function setConstants(array $constants): ClassConfig - { - $this->constants = $constants; - return $this; - } - - /** - * @return bool - */ - public function getInterface(): bool - { - $this->setImplements([]); - return $this->interface; - } - - /** - * @param bool $interface - * - * @return ClassConfig - */ - public function setInterface(bool $interface): ClassConfig - { - $this->interface = $interface; - return $this; - } - - /** - * @return string - */ - protected function renderUses(): string - { - $data = []; - if (!empty($this->getUses())) { - foreach ($this->getUses() as $use) { - $data[] = "use {$use};"; - } - } - return implode("\n", $data); - } - - /** - * @param array $comments - * @param int $level - * - * @return string - */ - protected function renderComment(array $comments = [], int $level = 0): string - { - $data = []; - if (!empty($comments)) { - $data[] = "{$this->getSpaces($level)}/**"; - foreach ($comments as $comment) { - $data[] = "{$this->getSpaces($level)} * {$comment}"; - } - $data[] = "{$this->getSpaces($level)} */"; - } - return implode("\n", $data); - } - - /** - * @return string - */ - protected function renderClassname(): string - { - $str = ''; - if ($this->getFinal()) { - $str .= "final"; - } - if ($this->getAbstract()) { - $str .= "abstract"; - } - - $str .= ($this->getInterface() ? 'interface' : 'class') . " {$this->getClassname()}"; - - if (!empty($this->getInheritance())) { - $str .= " extends {$this->getInheritance()}"; - } - if (!empty($this->getImplements())) { - $implement = implode(', ', $this->getImplements()); - $str .= " implements {$implement}"; - } - return $str; - } - - /** - * @return string - */ - protected function renderConst(): string - { - $data = []; - if (!empty($this->getConstants())) { - foreach ($this->getConstants() as $constant) { - // if not comment, add name - if (empty($constant->getComments()) && !is_null($constant->getDefault())) { - $constant->addComment($constant->getName()); - } - if (!empty($constant->getComments())) { - $data[] = $this->renderComment($constant->getComments(), 1); - } - $data[] = ("{$this->getSpaces()}{$this->getScope($constant)} const " . strtoupper($constant->getName()) . " = " . $constant->getValueType($constant->getDefault()) . ";\n"); - } - } - return implode("\n", $data); - } - - /** - * 获取 作用域 - * - * @param ClassBase $classBase - * - * @return string - */ - protected function getScope(ClassBase $classBase): string - { - $str = ''; - if ($classBase->getPublic()) { - $str = 'public'; - } - - if ($classBase->getProtected()) { - $str = 'protected'; - } - - if ($classBase->getPrivate()) { - $str = 'private'; - } - - if ($classBase->getStatic()) { - $str .= ' static'; - } - return $str; - } - - /** - * @return string - */ - protected function renderProperty(): string - { - $data = []; - if (!empty($this->getProperties())) { - foreach ($this->getProperties() as $classProperty) { - // if not comment, add default value type - if (empty($classProperty->getComments()) && !is_null($classProperty->getDefault())) { - $classProperty->addComment("@var " . gettype($classProperty->getDefault())); - } - if (!empty($classProperty->getComments())) { - $data[] = $this->renderComment($classProperty->getComments(), 1); - } - $property = "{$this->getSpaces()}{$this->getScope($classProperty)} $" . $classProperty->getName(); - if (is_null($classProperty->getDefault())) { - $property .= ";"; - } else { - $property .= (" = " . $classProperty->getValueType($classProperty->getDefault()) . ";"); - } - $data[] = $property . "\n"; - } - } - return implode("\n", $data); - } - - /** - * @return string - */ - protected function renderMethod(): string - { - $data = []; - if (!empty($this->getMethods())) { - foreach ($this->getMethods() as $classMethod) { - $params = []; - if (!empty($classMethod->getParams())) { - foreach ($classMethod->getParams() as $classParams) { - $classParamName = "$" . $classParams->getName(); - if (empty($classParams->getType()) && !empty($classParams->getDefault())) { - $classParams->setType($classMethod->valueType($classParams->getDefault())); - } - $classParam = ''; - if (!empty($classParams->getType())) { - $classParam .= "{$classParams->getType()} "; - } else { - $classParams->setType("mixed"); - } - $classParam .= $classParamName; - if ($classParams->getAssign()) { - $classParam .= (" = " . $classMethod->getValueType($classParams->getDefault())); - } - $params[] = $classParam; - $type = str_replace('?', 'null|', $classParams->getType()); - $classMethod->addComment("@param {$type} {$classParamName} {$classParams->getComment()}"); - } - } - $param = implode(", ", $params); - - $method = $this->getSpaces(); - if ($classMethod->getFinal()) { - $method .= "final"; - } - $method .= "{$this->getScope($classMethod)} function {$classMethod->getName()}({$param})"; - if (!empty($classMethod->getReturn())) { - $method .= ": {$classMethod->getReturn()}"; - } else { - $classMethod->setReturn('mixed'); - } - $classMethod->addComment("@return {$classMethod->getReturn()}"); - - $data[] = $this->renderComment($classMethod->getComments(), 1); - $data[] = $method; - $data[] = "{$this->getSpaces()}{"; - if (empty($classMethod->getContent())) { - $classMethod->setContent("{$this->getSpaces(2)}// TODO: Implement {$classMethod->getName()}() method."); - } - $data[] = $classMethod->getContent(); - $data[] = "{$this->getSpaces()}}\n"; - } - } - return implode("\n", $data); - } - - /** - * @return string - */ - protected function renderClass(): string - { - return implode("\n", array_filter([ - // class comment - !empty($this->getComments()) ? $this->renderComment($this->getComments()) : "", - // classname - $this->renderClassname(), - // start - '{', - // const - $this->renderConst(), - // properties - $this->renderProperty(), - // methods - $this->renderMethod(), - // end - '}', - ])); - - } - - /** - * @return string - */ - public function getContent(): string - { - return implode("\n\n", array_filter([ - // getNamespace()) ? "namespace {$this->getNamespace()};" : "", - // uses - $this->renderUses(), - // class - $this->renderClass(), - ])); - } -} diff --git a/app/Component/Generate/ClassFile/ClassConstant.php b/app/Component/Generate/ClassFile/ClassConstant.php deleted file mode 100644 index 777d0fa..0000000 --- a/app/Component/Generate/ClassFile/ClassConstant.php +++ /dev/null @@ -1,30 +0,0 @@ -default; - } - - /** - * @param mixed $default - * - * @return ClassConstant - */ - public function setDefault($default): ClassConstant - { - $this->default = $default; - return $this; - } -} diff --git a/app/Component/Generate/ClassFile/ClassMethod.php b/app/Component/Generate/ClassFile/ClassMethod.php deleted file mode 100644 index 0ad22d4..0000000 --- a/app/Component/Generate/ClassFile/ClassMethod.php +++ /dev/null @@ -1,114 +0,0 @@ -final; - } - - /** - * @param bool $final - * - * @return ClassMethod - */ - public function setFinal(bool $final = true): ClassMethod - { - $this->final = $final; - return $this; - } - - /** - * @return ClassParams[] - */ - public function getParams(): array - { - return $this->params; - } - - /** - * @param ClassParams[] $params - * - * @return ClassMethod - */ - public function setParams(array $params): ClassMethod - { - $this->params = $params; - return $this; - } - - /** - * @return mixed - */ - public function getReturn() - { - return $this->return; - } - - /** - * @param mixed $return - * - * @return ClassMethod - */ - public function setReturn($return): ClassMethod - { - $this->return = $return; - return $this; - } - - /** - * @param ClassParams $params - * - * @return $this - */ - public function addParams(ClassParams $params): ClassMethod - { - $this->params[] = $params; - return $this; - } - - /** - * @return string - */ - public function getContent(): string - { - return $this->content; - } - - /** - * @param ?string $content - * - * @return ClassMethod - */ - public function setContent(?string $content): ClassMethod - { - $this->content = $content; - return $this; - } - -} diff --git a/app/Component/Generate/ClassFile/ClassParams.php b/app/Component/Generate/ClassFile/ClassParams.php deleted file mode 100644 index 185d269..0000000 --- a/app/Component/Generate/ClassFile/ClassParams.php +++ /dev/null @@ -1,130 +0,0 @@ -default; - } - - /** - * @param mixed $default - * - * @return ClassParams - */ - public function setDefault($default): ClassParams - { - $this->setAssign(true); - $this->default = $default; - return $this; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @param string $name - * - * @return ClassParams - */ - public function setName(string $name): ClassParams - { - $this->name = $name; - return $this; - } - - /** - * @return mixed - */ - public function getType() - { - return $this->type; - } - - /** - * @param mixed $type - * - * @return ClassParams - */ - public function setType($type): ClassParams - { - $this->type = $type; - return $this; - } - - /** - * @return string - */ - public function getComment(): string - { - return $this->comment; - } - - /** - * @param string $comment - * - * @return ClassParams - */ - public function setComment(string $comment): ClassParams - { - $this->comment = $comment; - return $this; - } - - /** - * @return bool - */ - public function getAssign(): bool - { - return $this->assign; - } - - /** - * @param bool $assign - * - * @return ClassParams - */ - public function setAssign(bool $assign): ClassParams - { - $this->assign = $assign; - return $this; - } -} diff --git a/app/Component/Generate/ClassFile/ClassProperty.php b/app/Component/Generate/ClassFile/ClassProperty.php deleted file mode 100644 index 706d4bd..0000000 --- a/app/Component/Generate/ClassFile/ClassProperty.php +++ /dev/null @@ -1,30 +0,0 @@ -default; - } - - /** - * @param mixed $default - * - * @return ClassProperty - */ - public function setDefault($default): ClassProperty - { - $this->default = $default; - return $this; - } -} diff --git a/app/Component/Generate/Generate.php b/app/Component/Generate/Generate.php deleted file mode 100644 index c69e911..0000000 --- a/app/Component/Generate/Generate.php +++ /dev/null @@ -1,77 +0,0 @@ -path; - } - - /** - * @param string $path - * - * @return Generate - */ - public function setPath(string $path): Generate - { - $this->path = $path; - return $this; - } - - /** - * @return AbstractConfig - */ - public function getConfig(): AbstractConfig - { - return $this->config; - } - - /** - * @param AbstractConfig $config - * - * @return Generate - */ - public function setConfig(AbstractConfig $config): Generate - { - $this->config = $config; - return $this; - } - - /** - * @param string $suffix - * - * @return string - * @throws Exception - */ - public function output(string $suffix): string - { - $file = implode(DIRECTORY_SEPARATOR, [ - $this->getPath(), - $this->getConfig()->getFileName(), - ]) . '.' . FileHelper::getExtension($suffix); - $status = FileHelper::putFile($file, $this->getConfig()->getContent()); - if (!$status) { - throw new Exception("{$file} generate fail"); - } - return $file; - } -} diff --git a/app/Component/User.php b/app/Component/User.php deleted file mode 100644 index 185ccfd..0000000 --- a/app/Component/User.php +++ /dev/null @@ -1,60 +0,0 @@ -jwt->verifyToken($token); - $channel = ArrayHelper::get($data, 'channel', null); - // 多服务器 渠道 判断 - if ($channel === 'admin' && ArrayHelper::isValidValue($data, 'admin_id')) { - $user = $this->adminLoginService->findIdentity(['admin_id' => $data['admin_id']]); - } - return $user; - } -} diff --git a/app/Constant/Error.php b/app/Constant/Error.php deleted file mode 100644 index c511198..0000000 --- a/app/Constant/Error.php +++ /dev/null @@ -1,181 +0,0 @@ -getValidateData(); - $page = new PageEntity($params); - $data = $this->adminService->getList($params, [ - 'admin_id', - 'account', - 'role', - 'nickname', - 'number', - 'status', - ], $page); - return $this->success($data); - } - - /** - * @PostApi(path="/admin/v1/admin/create", summary="管理员创建", description="管理员创建") - * @Body(rules={ - * "account|账号":"required|string|max:32", - * "password|密码":"required|string|max:64", - * "role|角色":"required|string|max:255", - * "nickname|昵称":"required|string|max:32", - * }) - * @ApiResponse(code="0", template="success") - */ - public function create() - { - $params = $this->getValidateData(); - $this->adminService->create($params); - return $this->success([]); - } - - /** - * @PostApi(path="/admin/v1/admin/update", summary="管理员更新", description="管理员更新") - * @Body(rules={ - * "admin_id|id":"required|int", - * "password|密码":"string|max:64", - * "role|角色":"string|max:255", - * "nickname|昵称":"string|max:32", - * }) - * @ApiResponse(code="0", template="success") - */ - public function update() - { - $params = $this->getValidateData(); - $this->adminService->update($params); - return $this->success([]); - } - - /** - * @PostApi(path="/admin/v1/admin/detail", summary="管理员详情", description="管理员详情") - * @Body(rules={ - * "admin_id|id":"required|int", - * }) - * @ApiResponse(code="0", template="success") - */ - public function detail() - { - $params = $this->getValidateData(); - $data = $this->adminService->detail($params, [ - 'admin_id', - 'account', - 'role', - 'nickname', - 'number', - 'status', - ]); - return $this->success($data); - } - - /** - * @PostApi(path="/admin/v1/admin/remove", summary="管理员删除", description="管理员删除") - * @Body(rules={ - * "admin_id。*x|id":"required|int", - * }) - * @ApiResponse(code="0", template="success") - */ - public function remove() - { - $params = $this->getValidateData(); - $this->adminService->remove($params); - return $this->success(); - } - - /** - * @PostApi(path="/admin/v1/admin/changeStatus", summary="管理员修改状态", description="管理员修改状态") - * @Body(rules={ - * "admin_id.*|id":"required|int", - * "status|状态":"required|int", - * }) - * @ApiResponse(code="0", template="success") - */ - public function changeStatus() - { - $params = $this->getValidateData(); - $this->adminService->changeStatus($params); - return $this->success(); - } -} diff --git a/app/Controller/Admin/V1/LoginController.php b/app/Controller/Admin/V1/LoginController.php deleted file mode 100644 index 513cf40..0000000 --- a/app/Controller/Admin/V1/LoginController.php +++ /dev/null @@ -1,81 +0,0 @@ -getValidateData(); - $data = $this->loginService->login($params, $this->request->getClientIp()); - return $this->success($data); - } - - /** - * @PostApi(path="/admin/v1/login/refreshToken", summary="刷新token", description="刷新token") - * @Body(rules={ - * "refresh_token|刷新token" : "required|string" - * }) - * @ApiResponse(code="0", template="success", schema={ - * "token" : "123456", - * "refresh_token": "123456" - * }) - */ - public function refreshToken() - { - $refreshToken = ArrayHelper::get($this->getValidateData(), 'refresh_token'); - $data = $this->loginService->refreshToken($refreshToken, $this->request->getClientIp()); - return $this->success($data); - } - - /** - * @PostApi(path="/admin/v1/login/logout", summary="注销", description="退出登录") - * @Header(key="Token|token", rule="required|string") - * - * @ApiResponse(code="0", template="success") - */ - public function logout() - { - $token = ArrayHelper::get($this->getValidateData(), 'Token'); - $this->loginService->logout($token, $this->request->getClientIp()); - return $this->success([]); - } - -} diff --git a/app/Controller/Admin/V1/System/GenerateCodeController.php b/app/Controller/Admin/V1/System/GenerateCodeController.php deleted file mode 100644 index f443ce5..0000000 --- a/app/Controller/Admin/V1/System/GenerateCodeController.php +++ /dev/null @@ -1,10 +0,0 @@ -getValidateData(); - $page = new PageEntity($params); - $data = $this->menuService->getList($params, [], $page); - return $this->success($data); - } - - /** - * @PostApi(path="/admin/v1/menu/create", summary="菜单创建", description="菜单创建") - * @Body(rules={ - * "name|菜单名称":"required|string|max:64", - * "pid|上一级":"string|max:64", - * "icon|菜单图标":"required|string|max:64", - * "path|菜单路由":"string|max:255", - * "template|模版":"string|max:64", - * "role|角色":"required|string|max:64", - * "sort|排序":"required|int", - * }) - * @ApiResponse(code="0", template="success") - */ - public function create() - { - $params = $this->getValidateData(); - $this->menuService->create($params); - return $this->success([]); - } - - /** - * @PostApi(path="/admin/v1/menu/update", summary="菜单更新", description="菜单更新") - * @Body(rules={ - * "name|菜单名称":"required|string|max:64", - * "pid|上一级":"string|max:64", - * "icon|菜单图标":"required|string|max:64", - * "path|菜单路由":"string|max:255", - * "template|模版":"string|max:64", - * "role|角色":"required|string|max:64", - * "sort|排序":"required|int", - * }) - * @ApiResponse(code="0", template="success") - */ - public function update() - { - $params = $this->getValidateData(); - $this->menuService->update($params); - return $this->success([]); - } - - /** - * @PostApi(path="/admin/v1/menu/detail", summary="菜单详情", description="菜单详情") - * @Body(rules={ - * "name|菜单名称":"required|string|max:64" - * }) - * @ApiResponse(code="0", template="success") - */ - public function detail() - { - $params = $this->getValidateData(); - $data = $this->menuService->detail($params); - return $this->success($data); - } - - /** - * @PostApi(path="/admin/v1/menu/remove", summary="菜单移除", description="菜单移除") - * @Body(rules={ - * "name|菜单名称":"required|string|max:64" - * }) - * @ApiResponse(code="0", template="success") - */ - public function remove() - { - $params = $this->getValidateData(); - $this->menuService->remove($params); - return $this->success([]); - } -} diff --git a/app/Controller/Admin/V1/System/PermissionController.php b/app/Controller/Admin/V1/System/PermissionController.php deleted file mode 100644 index 1537e1c..0000000 --- a/app/Controller/Admin/V1/System/PermissionController.php +++ /dev/null @@ -1,112 +0,0 @@ -permissionService->getPermissions(); - return $this->success($data); - } - - /** - * @PostApi(path="/admin/v1/permission/create", summary="权限创建", description="权限创建") - * @Body(rules={ - * "name|path":"required|string|max:64", - * "description|名称":"required|string", - * "node.*|节点":"required|string|max:64", - * }) - * @ApiResponse(code="0", template="success") - */ - public function create() - { - $params = $this->getValidateData(); - $this->permissionService->create($params); - return $this->success([]); - } - - /** - * @PostApi(path="/admin/v1/permission/update", summary="权限更新", description="权限更新") - * @Body(rules={ - * "name|path":"required|string|max:64", - * "description|名称":"required|string", - * "node.*|节点":"required|string|max:64", - * }) - * @ApiResponse(code="0", template="success") - */ - public function update() - { - $params = $this->getValidateData(); - $this->permissionService->update($params); - return $this->success([]); - } - - /** - * @PostApi(path="/admin/v1/permission/detail", summary="权限详情", description="权限详情") - * @Body(rules={ - * "name|权限名称":"required|string|max:64" - * }) - * @ApiResponse(code="0", template="success") - */ - public function detail() - { - $params = $this->getValidateData(); - $data = $this->permissionService->detail($params); - return $this->success($data); - } - - /** - * @PostApi(path="/admin/v1/permission/remove", summary="权限移除", description="权限移除") - * @Body(rules={ - * "name|权限名称":"required|string|max:64" - * }) - * @ApiResponse(code="0", template="success") - */ - public function remove() - { - $params = $this->getValidateData(); - $this->permissionService->remove($params); - return $this->success([]); - } - - /** - * @PostApi(path="/admin/v1/permission/search", summary="权限节点筛选", description="权限节点筛选") - * @Body(rules={ - * "name|权限名称":"required|string|max:64" - * }) - * @ApiResponse(code="0", template="success") - */ - public function search() - { - $params = $this->getValidateData(); - $data = $this->permissionService->search($params['name']); - return $this->success($data); - } -} diff --git a/app/Controller/Admin/V1/System/RoleController.php b/app/Controller/Admin/V1/System/RoleController.php deleted file mode 100644 index 673d748..0000000 --- a/app/Controller/Admin/V1/System/RoleController.php +++ /dev/null @@ -1,106 +0,0 @@ -getValidateData(); - $page = empty($params['isAll']) ? new PageEntity($params) : null; - $data = $this->roleService->getList($params, [], $page); - return $this->success($data); - } - - /** - * @PostApi(path="/admin/v1/role/create", summary="角色创建", description="角色创建") - * @Body(rules={ - * "name|角色名称":"required|string|max:64", - * "description|描述":"string", - * "permission.*|权限":"required|string|max:64", - * }) - * @ApiResponse(code="0", template="success") - */ - public function create() - { - $params = $this->getValidateData(); - $this->roleService->create($params); - return $this->success([]); - } - - /** - * @PostApi(path="/admin/v1/role/update", summary="角色更新", description="角色更新") - * @Body(rules={ - * "name|角色名称":"required|string|max:64", - * "description|描述":"string", - * "permission.*|权限":"required|string|max:64", - * }) - * @ApiResponse(code="0", template="success") - */ - public function update() - { - $params = $this->getValidateData(); - $this->roleService->update($params); - return $this->success([]); - } - - /** - * @PostApi(path="/admin/v1/role/detail", summary="角色详情", description="角色详情") - * @Body(rules={ - * "name|角色名称":"required|string|max:64" - * }) - * @ApiResponse(code="0", template="success") - */ - public function detail() - { - $params = $this->getValidateData(); - $data = $this->roleService->detail($params); - return $this->success($data); - } - - /** - * @PostApi(path="/admin/v1/role/remove", summary="角色移除", description="角色移除") - * @Body(rules={ - * "name|角色名称":"required|string|max:64" - * }) - * @ApiResponse(code="0", template="success") - */ - public function remove() - { - $params = $this->getValidateData(); - $this->roleService->remove($params); - return $this->success([]); - } -} diff --git a/app/Controller/Controller.php b/app/Controller/Controller.php deleted file mode 100644 index 813dfab..0000000 --- a/app/Controller/Controller.php +++ /dev/null @@ -1,30 +0,0 @@ -container->get(ConfigInterface::class); - $requestName = $config->get('auth.api.requestName', 'api'); - return $this->request->getAttribute($requestName); - } - - /** - * api dog validate data - */ - public function getValidateData(): array - { - return Context::get('validator.data', []); - } -} diff --git a/app/Controller/IndexController.php b/app/Controller/IndexController.php new file mode 100644 index 0000000..60a442e --- /dev/null +++ b/app/Controller/IndexController.php @@ -0,0 +1,26 @@ +request->input('user', 'Hyperf'); + $method = $this->request->getMethod(); + + return [ + 'method' => $method, + 'message' => "Hello {$user}.", + ]; + } +} diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php deleted file mode 100644 index f0ad6f4..0000000 --- a/app/Controller/TestController.php +++ /dev/null @@ -1,288 +0,0 @@ - [ - [ - 'dataIndex' => '', - 'title' => '序号', - 'valueType' => ValueType::INDEX, - ], - [ - 'dataIndex' => 'nickname', - 'title' => '昵称', - 'valueType' => ValueType::TEXT, - ], - [ - 'dataIndex' => 'password', - 'title' => '密码', - 'valueType' => ValueType::PASSWORD, - ], - [ - 'dataIndex' => 'number', - 'title' => '工号', - 'valueType' => ValueType::MONEY, - ], - [ - 'dataIndex' => 'status', - 'title' => '状态', - 'valueType' => ValueType::SELECT, - 'valueEnum' => AdminStatus::getMapJson(), - ], - [ - 'dataIndex' => 'enable', - 'title' => '是否停用', - 'valueType' => ValueType::RADIO, - 'valueEnum' => SoftDeleted::getMapJson(), - ], - [ - 'dataIndex' => 'create_at', - 'title' => '创建时间', - 'valueType' => ValueType::DATE_TIME, - ], - [ - 'dataIndex' => '', - 'title' => '操作', - 'valueType' => ValueType::OPTION, - ], - ], - 'columnConfig' => [ - 'rowKey' => 'admin_id', - 'pagination' => ['pageSize' => 2], - ], - 'pageConfig' => [ - 'submitText' => '提交', - ], - 'form' => [ - [ - 'title' => '基础信息', - 'item' => [ - [ - 'inputType' => 'text', - 'name' => 'nickname', - 'label' => '昵称', - ], - [ - 'inputType' => 'password', - 'name' => 'password', - 'label' => '密码', - ], - [ - 'inputType' => 'checkbox', - 'name' => 'number', - 'label' => '工号', - 'valueEnum' => AdminStatus::getMapJson(), - ], - [ - 'inputType' => 'select', - 'name' => 'status', - 'label' => '状态', - 'valueEnum' => AdminStatus::getMapJson(), - ], - [ - 'inputType' => 'switch', - 'name' => 'enable', - 'label' => '是否停用', - 'checkedChildren' => '左', - 'unCheckedChildren' => '右', - 'valueEnum' => SoftDeleted::getMapJson(), - ], - [ - 'inputType' => 'date', - 'name' => 'create_at', - 'label' => '创建时间', - 'type' => FormDateType::DATE_TIME, - ], - ], - ], - [ - 'title' => '额外', - 'item' => [ - [ - 'inputType' => 'slider', - 'name' => 'slider', - 'label' => '百分比', - 'min' => 0, - 'max' => 100, - ], - [ - 'inputType' => 'rate', - 'name' => 'rate', - 'label' => '分', - 'allowHalf' => true, - 'count' => 6, - ], - ], - ], - ], - ]); - return $this->success($table->toArray()); - } - - /** - * @GetMapping(path="/") - * - * @return mixed - */ - public function list() - { - $params = $this->request->inputs(['page', 'pageSize']); - $page = new PageEntity([ - 'page' => !empty($params['page']) ? (int)$params['page'] : 1, - 'pageSize' => !empty($params['pageSize']) ? (int)$params['pageSize'] : 2, - ]); - $list = $this->adminService->getList([], ['admin_id', 'nickname'], $page); - $data = array_merge($list, $params); - return $this->success($data); - } - - /** - * @PostMapping(path="/create") - */ - public function create() - { - return $this->success($this->request->post()); - } - - /** - * @PostMapping(path="/update") - */ - public function update() - { - return $this->success($this->request->post()); - } - - /** - * @PostMapping(path="/remove") - */ - public function remove() - { - return $this->success($this->request->post()); - } - - /** - * @GetMapping(path="/generate") - */ - public function generate() - { -// $data = [ -// 'namespace' => 'App\Controller', -// 'classname' => 'AdminController', -// 'uses' => [ -// 'Hyperf\HttpServer\Annotation\Controller', -// 'Lengbin\Hyperf\Auth\RouterAuthAnnotation', -// 'Lengbin\Hyperf\Common\Framework\BaseController', -// ], -// 'comments' => [ -// 'Class AdminController', -// '@package App\Controller', -// '@Controller()', -// '@RouterAuthAnnotation(isPublic=true)', -// ], -// 'inheritance' => 'BaseController', -// 'constants' => [ -// [ -// 'name' => 'success', -// 'default' => 1, -// ], -// [ -// 'name' => 'fail', -// 'default' => "2", -// -// ], -// ], -// 'properties' => [ -// ["name" => 'abc', 'default' => 1.3], -// ["name" => 'abc2', 'default' => "hello world"], -// ["name" => 'abc3', 'default' => true], -// ["name" => 'abc4'], -// ], -// 'methods' => [ -// [ -// "name" => 'abc', -// 'params' => [ -// ['name' => 'a', 'type' => 'int', 'default' => 1, 'comment' => '左边'], -// ['name' => 'b', 'default' => 2, 'comment' => '中间'], -// ['name' => 'c', 'type' => 'int'], -// ['name' => 'd', 'comment' => '右边'], -// ], -// 'return' => 'int', -// 'content' => '', -// ], -// ], -// ]; -// $generate = new Generate(); -// $generate->setPath(BASE_PATH . '/app/Controller'); -// $config = new ClassConfig($data); -// $generate->setConfig($config); -// return $this->success(['a' => $generate->output('php'), 'b' => $config->__toObjectString(), 'c' => $config->__getClassname()]); -// - $config = $this->container->get(ConfigInterface::class)->get('genCode.default'); - $params = [ - 'name' => '管理员', - 'model' => 'app/Model/Admin', - 'pool' => 'default', - 'controller' => 'app/Controller/Test/AdminController', - 'service' => 'app/Service/Test/AdminService', - 'actions' => $config['actions'], - 'list' => [// todo 白名单 - - ], - 'search' => [ - - ], - 'tag' => [ - - ], - ]; - $generateCodeEntity = new GenerateCodeEntity($params); - $data = $this->generateService->crud($generateCodeEntity); - return $this->success($data); - } -} diff --git a/app/Entity/GenerateCodeEntity.php b/app/Entity/GenerateCodeEntity.php deleted file mode 100644 index 1a5dae1..0000000 --- a/app/Entity/GenerateCodeEntity.php +++ /dev/null @@ -1,236 +0,0 @@ -controller; - } - - /** - * @param string $controller - * - * @return GenerateCodeEntity - */ - public function setController(string $controller): GenerateCodeEntity - { - $this->controller = $controller; - return $this; - } - - /** - * @return string - */ - public function getModel(): string - { - return $this->model; - } - - /** - * @param string $model - * - * @return GenerateCodeEntity - */ - public function setModel(string $model): GenerateCodeEntity - { - $this->model = $model; - return $this; - } - - /** - * @return string - */ - public function getService(): string - { - return $this->service; - } - - /** - * @param string $service - * - * @return GenerateCodeEntity - */ - public function setService(string $service): GenerateCodeEntity - { - $this->service = $service; - return $this; - } - - /** - * @return Link[] - */ - public function getActions(): array - { - return $this->actions; - } - - /** - * @param Link[] $actions - * - * @return GenerateCodeEntity - */ - public function setActions(array $actions): GenerateCodeEntity - { - $this->actions = $actions; - return $this; - } - - /** - * @return Table - */ - public function getList(): Table - { - return $this->list; - } - - /** - * @param Table $table - * - * @return GenerateCodeEntity - */ - public function setList(Table $table): GenerateCodeEntity - { - $this->list = $table; - return $this; - } - - /** - * @return array - */ - public function getSearch(): array - { - return $this->search; - } - - /** - * @param array $search - * - * @return GenerateCodeEntity - */ - public function setSearch(array $search): GenerateCodeEntity - { - $this->search = $search; - return $this; - } - - /** - * @return string - */ - public function getPool(): string - { - return $this->pool; - } - - /** - * @param string $pool - * - * @return GenerateCodeEntity - */ - public function setPool(string $pool): GenerateCodeEntity - { - $this->pool = $pool; - return $this; - } - - /** - * @return array - */ - public function getTag(): array - { - return $this->tag; - } - - /** - * @param array $tag - * - * @return GenerateCodeEntity - */ - public function setTag(array $tag): GenerateCodeEntity - { - $this->tag = $tag; - return $this; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @param string $name - * - * @return GenerateCodeEntity - */ - public function setName(string $name): GenerateCodeEntity - { - $this->name = $name; - return $this; - } -} diff --git a/app/Exception/BusinessException.php b/app/Exception/BusinessException.php new file mode 100644 index 0000000..eaae4aa --- /dev/null +++ b/app/Exception/BusinessException.php @@ -0,0 +1,28 @@ +stopPropagation(); - $this->formatLog($throwable); - return $this->response->fail(CommentErrorCode::INVALID_PARAMS, $throwable->getMessage()); - } - - public function isValid(Throwable $throwable): bool - { - return $throwable instanceof ApiDogException; - } -} diff --git a/app/Exception/Handler/AppExceptionHandler.php b/app/Exception/Handler/AppExceptionHandler.php new file mode 100644 index 0000000..188d298 --- /dev/null +++ b/app/Exception/Handler/AppExceptionHandler.php @@ -0,0 +1,43 @@ +logger = $logger; + } + + public function handle(Throwable $throwable, ResponseInterface $response) + { + $this->logger->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile())); + $this->logger->error($throwable->getTraceAsString()); + return $response->withHeader('Server', 'Hyperf')->withStatus(500)->withBody(new SwooleStream('Internal Server Error.')); + } + + public function isValid(Throwable $throwable): bool + { + return true; + } +} diff --git a/app/Listener/DbQueryExecutedListener.php b/app/Listener/DbQueryExecutedListener.php index 8999902..abe5a52 100644 --- a/app/Listener/DbQueryExecutedListener.php +++ b/app/Listener/DbQueryExecutedListener.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/app/Model/Admin.php b/app/Model/Admin.php deleted file mode 100644 index 159070e..0000000 --- a/app/Model/Admin.php +++ /dev/null @@ -1,45 +0,0 @@ - 'string', 'number' => 'integer', 'status' => 'integer', 'enable' => 'integer', 'create_at' => 'datetime', 'update_at' => 'datetime']; -} \ No newline at end of file diff --git a/app/Model/AuthAssignment.php b/app/Model/AuthAssignment.php deleted file mode 100644 index 952fb09..0000000 --- a/app/Model/AuthAssignment.php +++ /dev/null @@ -1,32 +0,0 @@ - 'integer']; -} \ No newline at end of file diff --git a/app/Model/AuthItem.php b/app/Model/AuthItem.php deleted file mode 100644 index 6784e0b..0000000 --- a/app/Model/AuthItem.php +++ /dev/null @@ -1,35 +0,0 @@ - 'integer', 'updated_at' => 'integer']; -} \ No newline at end of file diff --git a/app/Model/AuthItemChild.php b/app/Model/AuthItemChild.php deleted file mode 100644 index 370a35e..0000000 --- a/app/Model/AuthItemChild.php +++ /dev/null @@ -1,31 +0,0 @@ - 'integer', 'updated_at' => 'integer', 'sort' => 'integer']; -} \ No newline at end of file diff --git a/app/Model/AuthRule.php b/app/Model/AuthRule.php deleted file mode 100644 index 2965683..0000000 --- a/app/Model/AuthRule.php +++ /dev/null @@ -1,33 +0,0 @@ - 'integer', 'updated_at' => 'integer']; -} \ No newline at end of file diff --git a/config/autoload/translation.php b/app/Model/Model.php similarity index 67% rename from config/autoload/translation.php rename to app/Model/Model.php index 35b9f06..fe03061 100644 --- a/config/autoload/translation.php +++ b/app/Model/Model.php @@ -9,8 +9,10 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ -return [ - 'locale' => 'zh_CN', - 'fallback_locale' => 'en', - 'path' => BASE_PATH . '/storage/languages', -]; +namespace App\Model; + +use Hyperf\DbConnection\Model\Model as BaseModel; + +abstract class Model extends BaseModel +{ +} diff --git a/app/Service/Admin/AdminLoginService.php b/app/Service/Admin/AdminLoginService.php deleted file mode 100644 index bdd2fee..0000000 --- a/app/Service/Admin/AdminLoginService.php +++ /dev/null @@ -1,115 +0,0 @@ -status === AdminStatus::FROZEN) { - throw new BusinessException(AdminError::ERROR_ADMIN_FREEZE); - } - } - - /** - * @param array $params - * - * @return Admin|null - */ - public function findIdentity(array $params): ?IdentityInterface - { - $admin = Admin::findOneCondition($params); - $this->checkAdminStatus($admin); - return $admin; - } - - /** - * 登录 - * - * @param array $params [account, password] - * @param string $ip - * - * @return array - */ - public function login(array $params, string $ip): array - { - $admin = Admin::findOneCondition([ - 'account' => $params['account'], - ], ['admin_id', 'password', 'status']); - - if (StringHelper::isEmpty($admin)) { - throw new BusinessException(AdminError::ERROR_ADMIN_ACCOUNT_OR_PASSWORD_FAIL); - } - - if (!PasswordHelper::verifyPassword($params['password'], $admin->password)) { - throw new BusinessException(AdminError::ERROR_ADMIN_ACCOUNT_OR_PASSWORD_FAIL); - } - - $this->checkAdminStatus($admin); - - $token = $this->jwt->generate([ - 'admin_id' => $admin->admin_id, - 'channel' => 'admin', - ]); - // todo 登录日志 - return [ - 'token' => $token, - 'refresh_token' => $this->jwt->generateRefreshToken($token), - ]; - } - - /** - * 刷新token - * - * @param string $refreshToken - * @param string $ip - * - * @return array - */ - public function refreshToken(string $refreshToken, string $ip): array - { - // todo 登录日志 - $token = $this->jwt->refreshToken($refreshToken); - return [ - 'token' => $token, - 'refresh_token' => $refreshToken, - ]; - } - - /** - * 退出 - * - * @param string $token - * @param string $ip - * - * @return bool - */ - public function logout(string $token, string $ip): bool - { - // todo 登录日志 - return $this->jwt->logout($token); - } -} diff --git a/app/Service/Admin/AdminService.php b/app/Service/Admin/AdminService.php deleted file mode 100644 index 6c12bb9..0000000 --- a/app/Service/Admin/AdminService.php +++ /dev/null @@ -1,211 +0,0 @@ -select($field); - $query->where(['enable' => SoftDeleted::ENABLE]); - - if (!empty($params['search'])) { - $query->where([ - ["account", 'like', "%{$params['search']}%"], - ["nickname", 'like', "%{$params['search']}%", 'or'], - ]); - } - - if (!empty($params['status'])) { - $query->where(['status' => $params['status']]); - } - - $results = $pageEntity ? $this->page($query, $pageEntity) : $query->get()->all(); - return $this->toArray($results, [$this, 'formatAdmin']); - } - - /** - * 格式化数据 - * - * @param array $admin - * - * @return array - */ - protected function formatAdmin(array $admin): array - { - if (!empty($admin['status'])) { - $admin['status_message'] = AdminStatus::byValue($admin['status'])->getMessage(); - } - - return $admin; - } - - public function detail(array $params, array $field = ['*']): array - { - $result = $this->findOne($params, $field); - return $this->formatAdmin($result->toArray()); - } - - /** - * @param array $conditions - * @param string[] $field - * - * @return Admin - */ - public function findOne(array $conditions, $field = ['*']): Admin - { - $model = Admin::findOneCondition($conditions, $field); - if (!$model) { - throw new BusinessException(AdminError::ERROR_ADMIN_NOT_FOUND); - } - return $model; - } - - /** - * @return int - */ - protected function getNumber(): int - { - $count = Admin::query()->count(); - return ++$count; - } - - /** - * @param array $params - * - * @return array - */ - public function create(array $params): array - { - $check = Admin::existCondition([ - 'account' => $params['account'], - ]); - if ($check) { - throw new BusinessException(AdminError::ERROR_ADMIN_EXIST); - } - $this->roleService->findOne($params['role']); - try { - Db::beginTransaction(); - $model = new Admin(); - $params['admin_id'] = SnowFlake::make(1, 1); - $params['status'] = AdminStatus::NORMAL; - $params['number'] = $this->getNumber(); - $params['enable'] = SoftDeleted::ENABLE; - $params['password'] = PasswordHelper::generatePassword($params['password']); - $status = $model->insert($params); - if (!$status) { - throw new BusinessException(AdminError::ERROR_ADMIN_CREATE_FAIL); - } - $this->roleService->assign($model->role, $model->admin_id); - Db::commit(); - return $model->toArray(); - } catch (Throwable $exception) { - Db::rollBack(); - throw new BusinessException(AdminError::ERROR_ADMIN_CREATE_FAIL); - } - } - - /** - * @param array $params - * - * @return array - */ - public function update(array $params): array - { - $model = $this->findOne([ - 'admin_id' => $params['admin_id'], - ]); - - if (!empty($params['password'])) { - $params['password'] = PasswordHelper::generatePassword($params['password']); - } - - $role = ''; - if (!empty($params['role']) && $model->role !== $params['role']) { - $role = $this->roleService->findOne($params['role']); - } - - try { - Db::beginTransaction(); - $status = $model->update($params); - if (!$status) { - throw new BusinessException(AdminError::ERROR_ADMIN_UPDATE_FAIL); - } - if (!empty($role)) { - $this->roleService->revoke($model->admin_id); - $this->roleService->assign($model->role, $model->admin_id); - } - Db::commit(); - return $model->toArray(); - } catch (Throwable $exception) { - Db::rollBack(); - throw new BusinessException(AdminError::ERROR_ADMIN_UPDATE_FAIL); - } - } - - /** - * @param array $params - * - * @return int - */ - public function remove(array $params): int - { - $status = Admin::softDeleteCondition($params); - if (!$status) { - throw new BusinessException(AdminError::ERROR_ADMIN_DELETE_FAIL); - } - return $status; - } - - /** - * @param array $params - * - * @return int - */ - public function changeStatus(array $params): int - { - $admin = Admin::findAllCondition(['admin_id' => $params['admin_id']]); - if (count($admin) !== count($params['admin_id'])) { - throw new BusinessException(AdminError::ERROR_ADMIN_NOT_FOUND); - } - $status = Admin::updateCondition(['admin_id' => $params['admin_id']], ['status' => $params['status']]); - if (!$status) { - throw new BusinessException(AdminError::ERROR_ADMIN_UPDATE_FAIL); - } - return $status; - } - -} diff --git a/app/Service/System/GenerateService.php b/app/Service/System/GenerateService.php deleted file mode 100644 index bf2fb5b..0000000 --- a/app/Service/System/GenerateService.php +++ /dev/null @@ -1,48 +0,0 @@ - new BuildConfig($this->config->get('genCode', [])), - 'root' => BASE_PATH, - 'generateCodeEntity' => $generateCodeEntity, - ]; - $model = (new ModelBuild($params))->build(); - $errorCode = (new ErrorCodeBuild($params))->setModel($model)->build(); - $service = (new ServiceBuild($params))->setModel($model)->setErrorCode($errorCode)->build(); - $controller = (new ControllerBuild($params))->setErrorCode($errorCode)->setService($service)->build(); - return [ - 'file' => [ - 'model' => $model->getFile(), - 'service' => $service->getFile(), - 'controller' => $controller->getFile(), - 'errorCode' => $errorCode->getFile(), - ], - 'rout' => $controller->getRout(), - ]; - } - - public function html(GenerateCodeEntity $generateCodeEntity): array - { - // todo 未实现 前端代码 自动生成 - } -} diff --git a/app/Service/System/Manager/MenuService.php b/app/Service/System/Manager/MenuService.php deleted file mode 100644 index 5386583..0000000 --- a/app/Service/System/Manager/MenuService.php +++ /dev/null @@ -1,167 +0,0 @@ -manager->getMenus($role); - if (empty($params['pid'])) { - $params['pid'] = ''; - } - return array_values(array_filter($menus, function ($menu) use ($params) { - return $menu->getPid() === $params['pid']; - })); - } - - /** - * @param array $params - * @param array|string[] $field - * @param PageEntity|null $pageEntity - * - * @return array - */ - public function getList(array $params = [], array $field = ['*'], ?PageEntity $pageEntity = null): array - { - $menus = $this->getMenus($params); - $results = $this->pageByArray($menus, $pageEntity); - return $this->toArray($results, function ($result) { - $result = $result->getAttributes(); - if (!is_array($result['role'])) { - $result['role'] = explode(',', $result['role']); - } - $result['create_at'] = date('Y-m-d H:i:s', $result['created_at']); - $result['update_at'] = date('Y-m-d H:i:s', $result['updated_at']); - return $result; - }); - } - - /** - * @param array $params - * - * @return Menu - */ - protected function populateMenu(array $params): Menu - { - $role = $params['role']; - if (!is_array($role)) { - $role = [$role]; - } - foreach ($role as $item) { - $this->roleService->findOne($item); - } - return (new Menu($params['name']))->withPid($params['pid']) - ->withIcon($params['icon']) - ->withPath($params['path']) - ->withSort($params['sort']) - ->withTemplate($params['template']) - ->withRole(implode(',', $role)); - } - - /** - * @param array $params - * - * @return array - */ - public function create(array $params): array - { - try { - $menu = $this->populateMenu($params); - $this->manager->add($menu); - return $params; - } catch (Throwable $exception) { - throw new BusinessException(MenuError::ERROR_MENU_CREATE_FAIL); - } - } - - /** - * @param array $params - * - * @return array - */ - public function update(array $params): array - { - try { - $menu = $this->populateMenu($params); - $this->manager->update($params['name'], $menu); - return $params; - } catch (Throwable $exception) { - throw new BusinessException(MenuError::ERROR_MENU_UPDATE_FAIL); - } - } - - /** - * @param string $name - * - * @return Menu - */ - public function findOne(string $name): Menu - { - $menu = $this->manager->getMenu($name); - if (!$menu) { - throw new BusinessException(MenuError::ERROR_MENU_NOT_FOUND); - } - return $menu; - } - - /** - * @param array $params - * @param array|string[] $field - * - * @return array - */ - public function detail(array $params, array $field = ['*']): array - { - $menu = $this->findOne($params['name']); - $result = $menu->getAttributes(); - $result['role'] = explode(',', $result['role']); - $result['create_at'] = date('Y-m-d H:i:s', $result['created_at']); - $result['update_at'] = date('Y-m-d H:i:s', $result['updated_at']); - return $result; - } - - /** - * @param array $params - * - * @return int - */ - public function remove(array $params): int - { - try { - $menu = $this->findOne($params['name']); - $this->manager->remove($menu); - return 1; - } catch (Throwable $exception) { - throw new BusinessException(MenuError::ERROR_MENU_REMOVE_FAIL); - } - } -} diff --git a/app/Service/System/Manager/PermissionService.php b/app/Service/System/Manager/PermissionService.php deleted file mode 100644 index 2d40e92..0000000 --- a/app/Service/System/Manager/PermissionService.php +++ /dev/null @@ -1,194 +0,0 @@ -withDescription($row['description'] ?? '')->withRuleName($row['rule_name'] ?? null); - } - - /** - * @param array $params - * - * @return array - */ - public function create(array $params): array - { - try { - Db::beginTransaction(); - $permission = $this->populateItem($params); - $this->manager->add($permission); - if (!empty($params['node'])) { - foreach ($params['node'] as $name) { - $node = $this->findOne($name); - if ($this->manager->hasChild($permission, $node) || $this->manager->canAddChild($permission, $node)) { - continue; - } - $this->manager->addChild($permission, $node); - } - } - Db::commit(); - return $params; - } catch (Throwable $exception) { - Db::rollBack(); - throw new BusinessException(PermissionError::ERROR_PERMISSION_CREATE_FAIL); - } - } - - /** - * @param string $name - * - * @return Permission - */ - public function findOne(string $name): Permission - { - $permission = $this->manager->getPermission($name); - if (!$permission) { - throw new BusinessException(PermissionError::ERROR_PERMISSION_NOT_FOUND); - } - return $permission; - } - - /** - * @param array $params - * - * @return array - */ - public function update(array $params): array - { - try { - Db::beginTransaction(); - $this->findOne($params['name']); - $permission = $this->populateItem($params); - $this->manager->update($params['name'], $permission); - $this->manager->removeChildren($permission); - if (!empty($params['node'])) { - foreach ($params['node'] as $name) { - $node = $this->findOne($name); - if ($this->manager->hasChild($permission, $node) || $this->manager->canAddChild($permission, $node)) { - continue; - } - $this->manager->addChild($permission, $node); - } - } - Db::commit(); - return $params; - } catch (Throwable $exception) { - Db::rollBack(); - throw new BusinessException(PermissionError::ERROR_PERMISSION_UPDATE_FAIL); - } - } - - /** - * @param array $params - * @param array|string[] $field - * - * @return array - */ - public function detail(array $params, array $field = ['*']): array - { - $permission = $this->findOne($params['name']); - $nodes = $this->manager->getPermissionsByRole($permission->getName()); - $data = []; - foreach ($nodes as $node) { - $data[] = $node->getName(); - } - $description = explode("-", $permission->getDescription()); - $group = array_shift($description); - return [ - 'name' => $permission->getName(), - 'full_description' => $permission->getDescription(), - 'group' => $group, - 'description' => implode('', $description), - 'rule_name' => $permission->getRuleName(), - 'node' => $data, - 'create_at' => date('Y-m-d H:i:s', $permission->getCreatedAt()), - 'update_at' => date('Y-m-d H:i:s', $permission->getUpdatedAt()), - ]; - } - - /** - * @param array $params - * - * @return int - */ - public function remove(array $params): int - { - try { - $menu = $this->findOne($params['name']); - $this->manager->remove($menu); - Db::commit(); - return 1; - } catch (Throwable $exception) { - Db::rollBack(); - throw new BusinessException(PermissionError::ERROR_PERMISSION_REMOVE_FAIL); - } - } - - /** - * @return array - */ - public function getPermissions(): array - { - $result = []; - $permissions = $this->manager->getPermissions(); - foreach ($permissions as $permission) { - $names = explode("-", $permission->getDescription()); - if (count($names) === 1) { - continue; - } - $title = array_shift($names); - if (empty($result[$title])) { - $result[$title] = []; - } - $result[$title][] = [ - 'name' => $permission->getName(), - 'full_description' => $permission->getDescription(), - 'description' => implode('', $names), - 'rule_name' => $permission->getRuleName(), - 'create_at' => date('Y-m-d H:i:s', $permission->getCreatedAt()), - 'update_at' => date('Y-m-d H:i:s', $permission->getUpdatedAt()), - ]; - } - $data = []; - foreach ($result as $name => $item) { - $data[] = [ - 'group' => $name, - 'item' => $item, - ]; - } - return $data; - } - - /** - * @param string $name - * - * @return array - */ - public function search(string $name): array - { - $permissions = array_keys($this->manager->getPermissions()); - return array_values(array_filter($permissions, function ($permission) use ($name) { - return $permission === $name ? true : StringHelper::matchWildcard($name . '*', $permission); - })); - } -} diff --git a/app/Service/System/Manager/RoleService.php b/app/Service/System/Manager/RoleService.php deleted file mode 100644 index a87d344..0000000 --- a/app/Service/System/Manager/RoleService.php +++ /dev/null @@ -1,196 +0,0 @@ -manager->getRoles(); - $roles = array_values($roles); - $results = $pageEntity ? $this->pageByArray($roles, $pageEntity) : $roles; - return $this->toArray($results, function ($result) { - $result = [ - 'name' => $result->getName(), - 'description' => $result->getDescription(), - 'create_at' => date('Y-m-d H:i:s', $result->getCreatedAt()), - 'update_at' => date('Y-m-d H:i:s', $result->getUpdatedAt()), - ]; - return $result; - }); - } - - /** - * @param array $row - * - * @return Item - */ - public function populateItem(array $row): Item - { - return (new Role($row['name']))->withDescription($row['description'] ?? '')->withRuleName($row['rule_name'] ?? null); - } - - /** - * @param array $params - * - * @return array - */ - public function create(array $params): array - { - try { - Db::beginTransaction(); - $role = $this->populateItem($params); - $this->manager->add($role); - foreach ($params['permission'] as $name) { - $permission = $this->permissionService->findOne($name); - if ($this->manager->hasChild($role, $permission)) { - continue; - } - $this->manager->addChild($role, $permission); - } - Db::commit(); - return $params; - } catch (Throwable $exception) { - Db::rollBack(); - throw new BusinessException(RoleError::ERROR_ROLE_CREATE_FAIL); - } - } - - /** - * @param string $name - * - * @return Role - */ - public function findOne(string $name): Role - { - $role = $this->manager->getRole($name); - if (!$role) { - throw new BusinessException(RoleError::ERROR_ROLE_NOT_FOUND); - } - return $role; - } - - /** - * @param array $params - * - * @return array - */ - public function update(array $params): array - { - try { - Db::beginTransaction(); - $this->findOne($params['name']); - $role = $this->populateItem($params); - $this->manager->update($params['name'], $role); - $this->manager->removeChildren($role); - foreach ($params['permission'] as $name) { - $permission = $this->permissionService->findOne($name); - if ($this->manager->hasChild($role, $permission)) { - continue; - } - $this->manager->addChild($role, $permission); - } - Db::commit(); - return $params; - } catch (Throwable $exception) { - Db::rollBack(); - throw new BusinessException(RoleError::ERROR_ROLE_UPDATE_FAIL); - } - } - - /** - * @param array $params - * @param array|string[] $field - * - * @return array - */ - public function detail(array $params, array $field = ['*']): array - { - $role = $this->findOne($params['name']); - $permissions = $this->manager->getPermissionsByRole($role->getName()); - $data = []; - foreach ($permissions as $permission) { - $data[] = $permission->getName(); - } - return [ - 'name' => $role->getName(), - 'description' => $role->getDescription(), - 'permission' => $data, - 'create_at' => date('Y-m-d H:i:s', $role->getCreatedAt()), - 'update_at' => date('Y-m-d H:i:s', $role->getUpdatedAt()), - ]; - } - - /** - * @param array $params - * - * @return int - */ - public function remove(array $params): int - { - try { - $role = $this->findOne($params['name']); - $this->manager->remove($role); - Db::commit(); - return 1; - } catch (Throwable $exception) { - Db::rollBack(); - throw new BusinessException(RoleError::ERROR_ROLE_REMOVE_FAIL); - } - } - - /** - * 为用户分配角色或权限。 - * - * @param string $name - * @param string $adminId - * - * @throws Exception - */ - public function assign(string $name, string $adminId) - { - $this->manager->assign($this->findOne($name), $adminId); - } - - /** - * 取消用户的角色或权限。 - * - * @param string $adminId - * - */ - public function revoke(string $adminId) - { - $this->manager->revokeAll($adminId); - } -} diff --git a/bin/hyperf.php b/bin/hyperf.php index dedd1dc..0e5439a 100644 --- a/bin/hyperf.php +++ b/bin/hyperf.php @@ -3,8 +3,10 @@ ini_set('display_errors', 'on'); ini_set('display_startup_errors', 'on'); +ini_set('memory_limit', '1G'); error_reporting(E_ALL); +date_default_timezone_set('Asia/Shanghai'); ! defined('BASE_PATH') && define('BASE_PATH', dirname(__DIR__, 1)); ! defined('SWOOLE_HOOK_FLAGS') && define('SWOOLE_HOOK_FLAGS', SWOOLE_HOOK_ALL); @@ -14,9 +16,9 @@ // Self-called anonymous function that creates its own scope and keep the global namespace clean. (function () { Hyperf\Di\ClassLoader::init(); - /** @var \Psr\Container\ContainerInterface $container */ + /** @var Psr\Container\ContainerInterface $container */ $container = require BASE_PATH . '/config/container.php'; - $application = $container->get(\Hyperf\Contract\ApplicationInterface::class); + $application = $container->get(Hyperf\Contract\ApplicationInterface::class); $application->run(); })(); diff --git a/composer.json b/composer.json index 92f3dd2..995c2d3 100644 --- a/composer.json +++ b/composer.json @@ -12,37 +12,29 @@ "description": "A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlewares.", "license": "Apache-2.0", "require": { - "php": ">=7.2", - "ext-swoole": ">=4.5", - "hyperf/cache": "~2.0.0", - "hyperf/command": "~2.0.0", - "hyperf/config": "~2.0.0", - "hyperf/db-connection": "~2.0.0", - "hyperf/framework": "~2.0.0", - "hyperf/guzzle": "~2.0.0", - "hyperf/http-server": "~2.0.0", - "hyperf/logger": "~2.0.0", - "hyperf/memory": "~2.0.0", - "hyperf/process": "~2.0.0", - "hyperf/redis": "~2.0.0", - "hyperf/elasticsearch": "~2.0.0", - "hyperf/snowflake": "^1.1", - "lengbin/hyperf-jwt": "dev-master", - "lengbin/hyperf-auth": "dev-master", - "lengbin/hyperf-common": "dev-master", - "lengbin/hyperf-error-code": "dev-main", - "daodao97/apidog": "^1.5", - "lengbin/hyperf-yii-rbac": "9999999-dev", - "ext-json": "*" + "php": ">=7.3", + "hyperf/cache": "~2.2.0", + "hyperf/command": "~2.2.0", + "hyperf/config": "~2.2.0", + "hyperf/db-connection": "~2.2.0", + "hyperf/framework": "~2.2.0", + "hyperf/guzzle": "~2.2.0", + "hyperf/http-server": "~2.2.0", + "hyperf/logger": "~2.2.0", + "hyperf/memory": "~2.2.0", + "hyperf/process": "~2.2.0", + "hyperf/database": "~2.2.0", + "hyperf/redis": "~2.2.0", + "hyperf/constants": "~2.2.0" }, "require-dev": { - "swoole/ide-helper": "^4.4", - "phpmd/phpmd": "^2.6", - "friendsofphp/php-cs-fixer": "^2.14", + "friendsofphp/php-cs-fixer": "^3.0", + "hyperf/devtool": "~2.2.0", + "hyperf/ide-helper": "~2.2.0", + "hyperf/testing": "~2.2.0", "mockery/mockery": "^1.0", "phpstan/phpstan": "^0.12", - "hyperf/devtool": "~2.0.0", - "hyperf/testing": "~2.0.0" + "swoole/ide-helper": "^4.5" }, "suggest": { "ext-openssl": "Required to use HTTPS.", @@ -64,6 +56,10 @@ }, "minimum-stability": "dev", "prefer-stable": true, + "config": { + "optimize-autoloader": true, + "sort-packages": true + }, "extra": [], "scripts": { "post-root-package-install": [ @@ -72,10 +68,12 @@ "post-autoload-dump": [ "rm -rf runtime/container" ], - "test": "co-phpunit -c phpunit.xml --colors=always", + "test": "co-phpunit --prepend test/bootstrap.php -c phpunit.xml --colors=always", "cs-fix": "php-cs-fixer fix $1", "analyse": "phpstan analyse --memory-limit 300M -l 0 -c phpstan.neon ./app ./config", - "start": "php ./bin/hyperf.php start", - "init-proxy": "init-proxy.sh" + "start": [ + "Composer\\Config::disableProcessTimeout", + "php ./bin/hyperf.php start" + ] } } diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..5d2757f --- /dev/null +++ b/composer.lock @@ -0,0 +1,7466 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "b9c38c27754cada82ad67b6d2f84fa5a", + "packages": [ + { + "name": "doctrine/annotations", + "version": "1.13.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "5b668aef16090008790395c02c893b1ba13f7e08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/5b668aef16090008790395c02c893b1ba13f7e08", + "reference": "5b668aef16090008790395c02c893b1ba13f7e08", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "ext-tokenizer": "*", + "php": "^7.1 || ^8.0", + "psr/cache": "^1 || ^2 || ^3" + }, + "require-dev": { + "doctrine/cache": "^1.11 || ^2.0", + "doctrine/coding-standard": "^6.0 || ^8.1", + "phpstan/phpstan": "^0.12.20", + "phpunit/phpunit": "^7.5 || ^8.0 || ^9.1.5", + "symfony/cache": "^4.4 || ^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "https://www.doctrine-project.org/projects/annotations.html", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "support": { + "issues": "https://github.com/doctrine/annotations/issues", + "source": "https://github.com/doctrine/annotations/tree/1.13.2" + }, + "time": "2021-08-05T19:00:23+00:00" + }, + { + "name": "doctrine/inflector", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "9cf661f4eb38f7c881cac67c75ea9b00bf97b210" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/9cf661f4eb38f7c881cac67c75ea9b00bf97b210", + "reference": "9cf661f4eb38f7c881cac67c75ea9b00bf97b210", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^7.0", + "phpstan/phpstan": "^0.11", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-strict-rules": "^0.11", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Inflector\\": "lib/Doctrine/Inflector" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.", + "homepage": "https://www.doctrine-project.org/projects/inflector.html", + "keywords": [ + "inflection", + "inflector", + "lowercase", + "manipulation", + "php", + "plural", + "singular", + "strings", + "uppercase", + "words" + ], + "support": { + "issues": "https://github.com/doctrine/inflector/issues", + "source": "https://github.com/doctrine/inflector/tree/2.0.x" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector", + "type": "tidelift" + } + ], + "time": "2020-05-29T15:13:26+00:00" + }, + { + "name": "doctrine/instantiator", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^8.0", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.4.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2020-11-10T18:47:58+00:00" + }, + { + "name": "doctrine/lexer", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "e864bbf5904cb8f5bb334f99209b48018522f042" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/e864bbf5904cb8f5bb334f99209b48018522f042", + "reference": "e864bbf5904cb8f5bb334f99209b48018522f042", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "phpstan/phpstan": "^0.11.8", + "phpunit/phpunit": "^8.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "https://www.doctrine-project.org/projects/lexer.html", + "keywords": [ + "annotations", + "docblock", + "lexer", + "parser", + "php" + ], + "support": { + "issues": "https://github.com/doctrine/lexer/issues", + "source": "https://github.com/doctrine/lexer/tree/1.2.1" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer", + "type": "tidelift" + } + ], + "time": "2020-05-25T17:44:05+00:00" + }, + { + "name": "fig/http-message-util", + "version": "1.1.5", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message-util.git", + "reference": "9d94dc0154230ac39e5bf89398b324a86f63f765" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message-util/zipball/9d94dc0154230ac39e5bf89398b324a86f63f765", + "reference": "9d94dc0154230ac39e5bf89398b324a86f63f765", + "shasum": "" + }, + "require": { + "php": "^5.3 || ^7.0 || ^8.0" + }, + "suggest": { + "psr/http-message": "The package containing the PSR-7 interfaces" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Fig\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Utility classes and constants for use with PSR-7 (psr/http-message)", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "issues": "https://github.com/php-fig/http-message-util/issues", + "source": "https://github.com/php-fig/http-message-util/tree/1.1.5" + }, + "time": "2020-11-24T22:02:12+00:00" + }, + { + "name": "graham-campbell/result-type", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/GrahamCampbell/Result-Type.git", + "reference": "84afea85c6841deeea872f36249a206e878a5de0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/84afea85c6841deeea872f36249a206e878a5de0", + "reference": "84afea85c6841deeea872f36249a206e878a5de0", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "phpoption/phpoption": "^1.8" + }, + "require-dev": { + "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.19 || ^9.5.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "GrahamCampbell\\ResultType\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk" + } + ], + "description": "An Implementation Of The Result Type", + "keywords": [ + "Graham Campbell", + "GrahamCampbell", + "Result Type", + "Result-Type", + "result" + ], + "support": { + "issues": "https://github.com/GrahamCampbell/Result-Type/issues", + "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.0.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", + "type": "tidelift" + } + ], + "time": "2021-08-28T21:34:50+00:00" + }, + { + "name": "guzzlehttp/guzzle", + "version": "7.3.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "7008573787b430c1c1f650e3722d9bba59967628" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7008573787b430c1c1f650e3722d9bba59967628", + "reference": "7008573787b430c1c1f650e3722d9bba59967628", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.4", + "guzzlehttp/psr7": "^1.7 || ^2.0", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "ext-curl": "*", + "php-http/client-integration-tests": "^3.0", + "phpunit/phpunit": "^8.5.5 || ^9.3.5", + "psr/log": "^1.1" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.3-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.3.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://github.com/alexeyshockov", + "type": "github" + }, + { + "url": "https://github.com/gmponos", + "type": "github" + } + ], + "time": "2021-03-23T11:33:13+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "1.4.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/8e7d04f1f6450fef59366c399cfad4b9383aa30d", + "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "symfony/phpunit-bridge": "^4.4 || ^5.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/1.4.1" + }, + "time": "2021-03-07T09:25:29+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "1dc8d9cba3897165e16d12bb13d813afb1eb3fe7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/1dc8d9cba3897165e16d12bb13d813afb1eb3fe7", + "reference": "1dc8d9cba3897165e16d12bb13d813afb1eb3fe7", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.8 || ^9.3.10" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.0.0" + }, + "time": "2021-06-30T20:03:07+00:00" + }, + { + "name": "hyperf/cache", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/cache.git", + "reference": "a965eff26fd2acc2557ef557b80e121cdae57b95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/cache/zipball/a965eff26fd2acc2557ef557b80e121cdae57b95", + "reference": "a965eff26fd2acc2557ef557b80e121cdae57b95", + "shasum": "" + }, + "require": { + "hyperf/contract": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2", + "psr/container": "^1.0|^2.0", + "psr/simple-cache": "^1.0" + }, + "suggest": { + "hyperf/di": "Use cache annotations.", + "hyperf/event": "Use listener to delete annotation cache." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Cache\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A cache component for hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "cache", + "hyperf", + "php" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/command", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/command.git", + "reference": "805df76bc390d754e1d37fbaea26a7401f2912c2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/command/zipball/805df76bc390d754e1d37fbaea26a7401f2912c2", + "reference": "805df76bc390d754e1d37fbaea26a7401f2912c2", + "shasum": "" + }, + "require": { + "hyperf/utils": "~2.2.0", + "php": ">=7.2", + "psr/event-dispatcher": "^1.0", + "symfony/console": "^5.0" + }, + "suggest": { + "hyperf/di": "Required to use annotations." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Command\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Command for hyperf", + "keywords": [ + "command", + "php", + "swoole" + ], + "support": { + "issues": "https://github.com/hyperf/command/issues", + "source": "https://github.com/hyperf/command/tree/v2.2.0" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/config", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/config.git", + "reference": "ccdcc79ec244612c04f186e65b222ad778db75e9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/config/zipball/ccdcc79ec244612c04f186e65b222ad778db75e9", + "reference": "ccdcc79ec244612c04f186e65b222ad778db75e9", + "shasum": "" + }, + "require": { + "hyperf/contract": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2", + "psr/container": "^1.0|^2.0", + "symfony/finder": "^5.0" + }, + "suggest": { + "hyperf/di": "Allows using @Value annotation", + "hyperf/event": "Allows using @Value annotation", + "hyperf/framework": "Allows using @Value annotation", + "vlucas/phpdotenv": "Allows using enviroment value to override the config" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Config\\ConfigProvider" + } + }, + "autoload": { + "files": [ + "./src/Functions.php" + ], + "psr-4": { + "Hyperf\\Config\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "An independent component that provides configuration container.", + "homepage": "https://hyperf.io", + "keywords": [ + "config", + "configuration", + "hyperf", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/constants", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/constants.git", + "reference": "7568ff95958644d8c8143f6c534653930c3d23d2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/constants/zipball/7568ff95958644d8c8143f6c534653930c3d23d2", + "reference": "7568ff95958644d8c8143f6c534653930c3d23d2", + "shasum": "" + }, + "require": { + "hyperf/di": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2" + }, + "suggest": { + "hyperf/translation": "Required to use translation." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Constants\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Constants\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A constants component for hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "constants", + "hyperf", + "php" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/contract", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/contract.git", + "reference": "62004fbfc9718068522a88975777385db5e0f2e3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/contract/zipball/62004fbfc9718068522a88975777385db5e0f2e3", + "reference": "62004fbfc9718068522a88975777385db5e0f2e3", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Contract\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "The contracts of Hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "hyperf", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/database", + "version": "v2.2.5", + "source": { + "type": "git", + "url": "https://github.com/hyperf/database.git", + "reference": "da359e624ef0d7c2efa8bbeb586eede3e9efba2e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/database/zipball/da359e624ef0d7c2efa8bbeb586eede3e9efba2e", + "reference": "da359e624ef0d7c2efa8bbeb586eede3e9efba2e", + "shasum": "" + }, + "require": { + "hyperf/utils": "~2.2.0", + "nesbot/carbon": "^2.0", + "php": ">=7.2", + "psr/container": "^1.0|^2.0", + "psr/event-dispatcher": "^1.0" + }, + "suggest": { + "doctrine/dbal": "Required to rename columns (^3.0).", + "nikic/php-parser": "Required to use ModelCommand. (^4.0)", + "php-di/phpdoc-reader": "Required to use ModelCommand. (^2.2)" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Database\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A flexible database library.", + "homepage": "https://hyperf.io", + "keywords": [ + "database", + "hyperf", + "php" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-08-18T08:51:36+00:00" + }, + { + "name": "hyperf/db-connection", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/db-connection.git", + "reference": "ac0e407330a33e823d9eab3798d0735a70c64ff2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/db-connection/zipball/ac0e407330a33e823d9eab3798d0735a70c64ff2", + "reference": "ac0e407330a33e823d9eab3798d0735a70c64ff2", + "shasum": "" + }, + "require": { + "hyperf/database": "~2.2.0", + "hyperf/di": "~2.2.0", + "hyperf/framework": "~2.2.0", + "hyperf/model-listener": "~2.2.0", + "hyperf/pool": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\DbConnection\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\DbConnection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A hyperf db connection handler for hyperf/database.", + "homepage": "https://hyperf.io", + "keywords": [ + "Connection", + "database", + "hyperf", + "php" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/di", + "version": "v2.2.4", + "source": { + "type": "git", + "url": "https://github.com/hyperf/di.git", + "reference": "ac4813b0b5cf677dcce479ebd8dd441ef79b361b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/di/zipball/ac4813b0b5cf677dcce479ebd8dd441ef79b361b", + "reference": "ac4813b0b5cf677dcce479ebd8dd441ef79b361b", + "shasum": "" + }, + "require": { + "doctrine/annotations": "^1.6", + "doctrine/instantiator": "^1.0", + "nikic/php-parser": "^4.1", + "php": ">=7.3", + "php-di/phpdoc-reader": "^2.2", + "psr/container": "^1.0|^2.0", + "symfony/finder": "^5.0", + "vlucas/phpdotenv": "^5.0" + }, + "suggest": { + "ext-pcntl": "Required to scan annotations.", + "hyperf/config": "Require this component for annotation scan progress to retrieve the scan path." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Di\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Di\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A DI for Hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "annotation", + "di", + "hyperf", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-08-14T02:40:30+00:00" + }, + { + "name": "hyperf/dispatcher", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/dispatcher.git", + "reference": "fdd464fe5fac01c60732eddc2da7c3184e93995c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/dispatcher/zipball/fdd464fe5fac01c60732eddc2da7c3184e93995c", + "reference": "fdd464fe5fac01c60732eddc2da7c3184e93995c", + "shasum": "" + }, + "require": { + "hyperf/contract": "~2.2.0", + "php": ">=7.2", + "psr/container": "^1.0|^2.0", + "psr/http-message": "^1.0", + "psr/http-server-middleware": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Dispatcher\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Dispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A HTTP Server for Hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "dispatcher", + "filter", + "hyperf", + "middleware", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/engine", + "version": "v1.1.6", + "source": { + "type": "git", + "url": "https://github.com/hyperf/engine.git", + "reference": "f583f01f458f8c69080e06e6dce715c86edc9f86" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/engine/zipball/f583f01f458f8c69080e06e6dce715c86edc9f86", + "reference": "f583f01f458f8c69080e06e6dce715c86edc9f86", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.0", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^9.4", + "swoole/ide-helper": "dev-master" + }, + "suggest": { + "ext-swoole": ">=4.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Engine\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "keywords": [ + "hyperf", + "php" + ], + "support": { + "issues": "https://github.com/hyperf/engine/issues", + "source": "https://github.com/hyperf/engine/tree/v1.1.6" + }, + "time": "2021-07-11T10:22:13+00:00" + }, + { + "name": "hyperf/event", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/event.git", + "reference": "9c2ab56737d080d799b9b1f905716c7bf0d61ef6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/event/zipball/9c2ab56737d080d799b9b1f905716c7bf0d61ef6", + "reference": "9c2ab56737d080d799b9b1f905716c7bf0d61ef6", + "shasum": "" + }, + "require": { + "hyperf/contract": "~2.2.0", + "php": ">=7.2", + "psr/event-dispatcher": "^1.0" + }, + "suggest": { + "hyperf/di": "Required to use annotatioins." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Event\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Event\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "an event manager that implements PSR-14.", + "homepage": "https://hyperf.io", + "keywords": [ + "event", + "hyperf", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/exception-handler", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/exception-handler.git", + "reference": "4e10fc994e06940a91704b248e389bf96f70ca10" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/exception-handler/zipball/4e10fc994e06940a91704b248e389bf96f70ca10", + "reference": "4e10fc994e06940a91704b248e389bf96f70ca10", + "shasum": "" + }, + "require": { + "hyperf/contract": "~2.2.0", + "hyperf/dispatcher": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2", + "psr/container": "^1.0|^2.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\ExceptionHandler\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\ExceptionHandler\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Exception handler for hyperf", + "homepage": "https://hyperf.io", + "keywords": [ + "exception-handler", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/framework", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/framework.git", + "reference": "0b27f9c6068c74c971e06aa7f44f4c9138844a8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/framework/zipball/0b27f9c6068c74c971e06aa7f44f4c9138844a8c", + "reference": "0b27f9c6068c74c971e06aa7f44f4c9138844a8c", + "shasum": "" + }, + "require": { + "fig/http-message-util": "^1.1.2", + "hyperf/contract": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2", + "psr/container": "^1.0|^2.0", + "psr/event-dispatcher": "^1.0", + "psr/log": "^1.0" + }, + "suggest": { + "ext-swoole": "Required to use swoole engine.", + "hyperf/command": "Required to use Command annotation.", + "hyperf/di": "Required to use Command annotation.", + "hyperf/dispatcher": "Required to use BootApplication event.", + "symfony/event-dispatcher": "Required to use symfony event dispatcher (^5.0)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Framework\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Framework\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlewares.", + "homepage": "https://hyperf.io", + "keywords": [ + "Microservice", + "framework", + "hyperf", + "middleware", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/guzzle", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/guzzle.git", + "reference": "cae5b639bf41db207618c09d9e227de3bf5efed8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/guzzle/zipball/cae5b639bf41db207618c09d9e227de3bf5efed8", + "reference": "cae5b639bf41db207618c09d9e227de3bf5efed8", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^6.3|^7.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.0", + "psr/container": "^1.0|^2.0", + "psr/http-message": "^1.0" + }, + "suggest": { + "hyperf/pool": "Required to use pool handler." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Guzzle\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Guzzle\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Swoole coroutine handler for guzzle", + "keywords": [ + "Guzzle", + "handler", + "php", + "swoole" + ], + "support": { + "issues": "https://github.com/hyperf/guzzle/issues", + "source": "https://github.com/hyperf/guzzle/tree/v2.2.0" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/http-message", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/http-message.git", + "reference": "0f2d7657a6470a6ba0c56fdcc98712e010325651" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/http-message/zipball/0f2d7657a6470a6ba0c56fdcc98712e010325651", + "reference": "0f2d7657a6470a6ba0c56fdcc98712e010325651", + "shasum": "" + }, + "require": { + "hyperf/utils": "~2.2.0", + "laminas/laminas-mime": "^2.7", + "psr/http-message": "^1.0" + }, + "suggest": { + "psr/container": "Required to replace RequestParserInterface." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\HttpMessage\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\HttpMessage\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "microservice framework base on swoole", + "keywords": [ + "http-message", + "hyperf", + "php", + "swoole" + ], + "support": { + "issues": "https://github.com/hyperf/http-message/issues", + "source": "https://github.com/hyperf/http-message/tree/v2.2.0" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/http-server", + "version": "v2.2.4", + "source": { + "type": "git", + "url": "https://github.com/hyperf/http-server.git", + "reference": "4b40dab7d30670c8d77bc44698b4904ee100a8a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/http-server/zipball/4b40dab7d30670c8d77bc44698b4904ee100a8a0", + "reference": "4b40dab7d30670c8d77bc44698b4904ee100a8a0", + "shasum": "" + }, + "require": { + "hyperf/contract": "~2.2.0", + "hyperf/dispatcher": "~2.2.0", + "hyperf/event": "~2.2.0", + "hyperf/exception-handler": "~2.2.0", + "hyperf/http-message": "~2.2.0", + "hyperf/server": "~2.2.0", + "hyperf/utils": "~2.2.0", + "nikic/fast-route": "^1.3", + "php": ">=7.2", + "psr/container": "^1.0|^2.0" + }, + "suggest": { + "hyperf/di": "Required to use annotations." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\HttpServer\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\HttpServer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A HTTP Server for Hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "http", + "http-server", + "hyperf", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-08-10T02:20:43+00:00" + }, + { + "name": "hyperf/logger", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/logger.git", + "reference": "1255b27d6f3a06696913830b0304e9b4b94f3222" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/logger/zipball/1255b27d6f3a06696913830b0304e9b4b94f3222", + "reference": "1255b27d6f3a06696913830b0304e9b4b94f3222", + "shasum": "" + }, + "require": { + "hyperf/contract": "~2.2.0", + "hyperf/utils": "~2.2.0", + "monolog/monolog": "^2.0", + "php": ">=7.2", + "psr/container": "^1.0|^2.0", + "psr/log": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Logger\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Logger\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A logger component for hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "hyperf", + "logger", + "php" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/memory", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/memory.git", + "reference": "e26bfea8c73af4604b217a1b449fbc64a06985d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/memory/zipball/e26bfea8c73af4604b217a1b449fbc64a06985d3", + "reference": "e26bfea8c73af4604b217a1b449fbc64a06985d3", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Memory\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Memory\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "An independent component that use to operate and manage memory.", + "homepage": "https://hyperf.io", + "keywords": [ + "hyperf", + "memory", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/model-listener", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/model-listener.git", + "reference": "fa82b1ac4cf00d3c4f2705e1a0604823b30073e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/model-listener/zipball/fa82b1ac4cf00d3c4f2705e1a0604823b30073e5", + "reference": "fa82b1ac4cf00d3c4f2705e1a0604823b30073e5", + "shasum": "" + }, + "require": { + "hyperf/contract": "~2.2.0", + "hyperf/database": "~2.2.0", + "hyperf/di": "~2.2.0", + "hyperf/event": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2", + "psr/container": "^1.0|^2.0", + "psr/log": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\ModelListener\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\ModelListener\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A model listener for Hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "hyperf", + "model-listener", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/pool", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/pool.git", + "reference": "80c02966b9cb8ac939b8c52f6d4981206d69c57d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/pool/zipball/80c02966b9cb8ac939b8c52f6d4981206d69c57d", + "reference": "80c02966b9cb8ac939b8c52f6d4981206d69c57d", + "shasum": "" + }, + "require": { + "hyperf/contract": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2", + "psr/container": "^1.0|^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Pool\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Pool\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "An independent universal connection pool component.", + "homepage": "https://hyperf.io", + "keywords": [ + "connection-pool", + "hyperf", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/process", + "version": "v2.2.3", + "source": { + "type": "git", + "url": "https://github.com/hyperf/process.git", + "reference": "5a10e322c05f9329ec84ff2255eb5fe9dea304fa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/process/zipball/5a10e322c05f9329ec84ff2255eb5fe9dea304fa", + "reference": "5a10e322c05f9329ec84ff2255eb5fe9dea304fa", + "shasum": "" + }, + "require": { + "hyperf/contract": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2", + "psr/container": "^1.0|^2.0", + "psr/event-dispatcher": "^1.0" + }, + "suggest": { + "hyperf/di": "Required to use annotations.", + "hyperf/event": "Required to dump the message before and after process.", + "hyperf/framework": "Required to use BootProcessListener." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Process\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Process\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A process component for hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "hyperf", + "php", + "process" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-08-05T06:20:33+00:00" + }, + { + "name": "hyperf/redis", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/redis.git", + "reference": "daeb7cd985f02a669a2a7261bd07e5edbe90ccd3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/redis/zipball/daeb7cd985f02a669a2a7261bd07e5edbe90ccd3", + "reference": "daeb7cd985f02a669a2a7261bd07e5edbe90ccd3", + "shasum": "" + }, + "require": { + "ext-redis": "*", + "hyperf/contract": "~2.2.0", + "hyperf/pool": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2", + "psr/container": "^1.0|^2.0" + }, + "suggest": { + "ext-redis": "Required to use sentinel mode (>=5.2).", + "hyperf/di": "Create the RedisPool via dependency injection." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Redis\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Redis\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A redis component for hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "hyperf", + "php", + "pool", + "redis" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/server", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/server.git", + "reference": "491a1da8bda8cf2aacd2fae1e4370eac3e2e18eb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/server/zipball/491a1da8bda8cf2aacd2fae1e4370eac3e2e18eb", + "reference": "491a1da8bda8cf2aacd2fae1e4370eac3e2e18eb", + "shasum": "" + }, + "require": { + "hyperf/contract": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2", + "psr/container": "^1.0|^2.0", + "psr/event-dispatcher": "^1.0", + "psr/log": "^1.0", + "symfony/console": "^5.0" + }, + "suggest": { + "hyperf/event": "Dump the info after server start.", + "hyperf/framework": "Dump the info after server start." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Server\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A base server library for Hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "hyperf", + "php", + "server", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "hyperf/utils", + "version": "v2.2.5", + "source": { + "type": "git", + "url": "https://github.com/hyperf/utils.git", + "reference": "bff47ad92d5d85cd6b941d9766c8a251d1648860" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/utils/zipball/bff47ad92d5d85cd6b941d9766c8a251d1648860", + "reference": "bff47ad92d5d85cd6b941d9766c8a251d1648860", + "shasum": "" + }, + "require": { + "doctrine/inflector": "^2.0", + "hyperf/contract": "~2.2.0", + "hyperf/engine": "^1.1", + "php": ">=7.2" + }, + "suggest": { + "ext-swoole": "Required to use methods related to swoole (>=4.5).", + "hyperf/di": "Required to use ExceptionNormalizer", + "nikic/php-parser": "Required to use PhpParser. (^4.0)", + "symfony/property-access": "Required to use SymfonyNormalizer (^5.0)", + "symfony/serializer": "Required to use SymfonyNormalizer (^5.0)", + "symfony/var-dumper": "Required to use the dd function (^5.0)." + }, + "type": "library", + "extra": { + "hyperf": { + "config": "Hyperf\\Utils\\ConfigProvider" + }, + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "autoload": { + "files": [ + "src/Functions.php" + ], + "psr-4": { + "Hyperf\\Utils\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A tools package that could help developer solved the problem quickly.", + "homepage": "https://hyperf.io", + "keywords": [ + "hyperf", + "php", + "swoole", + "utils" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-08-18T08:28:09+00:00" + }, + { + "name": "laminas/laminas-mime", + "version": "2.8.0", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-mime.git", + "reference": "9a59704f33106427a384d0ae421f96043174093a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-mime/zipball/9a59704f33106427a384d0ae421f96043174093a", + "reference": "9a59704f33106427a384d0ae421f96043174093a", + "shasum": "" + }, + "require": { + "laminas/laminas-stdlib": "^2.7 || ^3.0", + "laminas/laminas-zendframework-bridge": "^1.0", + "php": "^7.3 || ~8.0.0" + }, + "replace": { + "zendframework/zend-mime": "^2.7.2" + }, + "require-dev": { + "laminas/laminas-coding-standard": "~1.0.0", + "laminas/laminas-mail": "^2.6", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "laminas/laminas-mail": "Laminas\\Mail component" + }, + "type": "library", + "autoload": { + "psr-4": { + "Laminas\\Mime\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Create and parse MIME messages and parts", + "homepage": "https://laminas.dev", + "keywords": [ + "laminas", + "mime" + ], + "support": { + "chat": "https://laminas.dev/chat", + "docs": "https://docs.laminas.dev/laminas-mime/", + "forum": "https://discourse.laminas.dev", + "issues": "https://github.com/laminas/laminas-mime/issues", + "rss": "https://github.com/laminas/laminas-mime/releases.atom", + "source": "https://github.com/laminas/laminas-mime" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2021-02-16T17:40:06+00:00" + }, + { + "name": "laminas/laminas-stdlib", + "version": "3.5.0", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-stdlib.git", + "reference": "c8ac6a76a133e682acfabc821d4a2ec646934b12" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/c8ac6a76a133e682acfabc821d4a2ec646934b12", + "reference": "c8ac6a76a133e682acfabc821d4a2ec646934b12", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "conflict": { + "zendframework/zend-stdlib": "*" + }, + "require-dev": { + "laminas/laminas-coding-standard": "~2.3.0", + "phpbench/phpbench": "^0.17.1", + "phpunit/phpunit": "~9.3.7", + "psalm/plugin-phpunit": "^0.16.0", + "vimeo/psalm": "^4.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Laminas\\Stdlib\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "SPL extensions, array utilities, error handlers, and more", + "homepage": "https://laminas.dev", + "keywords": [ + "laminas", + "stdlib" + ], + "support": { + "chat": "https://laminas.dev/chat", + "docs": "https://docs.laminas.dev/laminas-stdlib/", + "forum": "https://discourse.laminas.dev", + "issues": "https://github.com/laminas/laminas-stdlib/issues", + "rss": "https://github.com/laminas/laminas-stdlib/releases.atom", + "source": "https://github.com/laminas/laminas-stdlib" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2021-08-03T13:40:40+00:00" + }, + { + "name": "laminas/laminas-zendframework-bridge", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-zendframework-bridge.git", + "reference": "13af2502d9bb6f7d33be2de4b51fb68c6cdb476e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/13af2502d9bb6f7d33be2de4b51fb68c6cdb476e", + "reference": "13af2502d9bb6f7d33be2de4b51fb68c6cdb476e", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1 || ^9.3", + "psalm/plugin-phpunit": "^0.15.1", + "squizlabs/php_codesniffer": "^3.5", + "vimeo/psalm": "^4.6" + }, + "type": "library", + "extra": { + "laminas": { + "module": "Laminas\\ZendFrameworkBridge" + } + }, + "autoload": { + "files": [ + "src/autoload.php" + ], + "psr-4": { + "Laminas\\ZendFrameworkBridge\\": "src//" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Alias legacy ZF class names to Laminas Project equivalents.", + "keywords": [ + "ZendFramework", + "autoloading", + "laminas", + "zf" + ], + "support": { + "forum": "https://discourse.laminas.dev/", + "issues": "https://github.com/laminas/laminas-zendframework-bridge/issues", + "rss": "https://github.com/laminas/laminas-zendframework-bridge/releases.atom", + "source": "https://github.com/laminas/laminas-zendframework-bridge" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2021-06-24T12:49:22+00:00" + }, + { + "name": "monolog/monolog", + "version": "2.3.2", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "71312564759a7db5b789296369c1a264efc43aad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/71312564759a7db5b789296369c1a264efc43aad", + "reference": "71312564759a7db5b789296369c1a264efc43aad", + "shasum": "" + }, + "require": { + "php": ">=7.2", + "psr/log": "^1.0.1" + }, + "provide": { + "psr/log-implementation": "1.0.0" + }, + "require-dev": { + "aws/aws-sdk-php": "^2.4.9 || ^3.0", + "doctrine/couchdb": "~1.0@dev", + "elasticsearch/elasticsearch": "^7", + "graylog2/gelf-php": "^1.4.2", + "mongodb/mongodb": "^1.8", + "php-amqplib/php-amqplib": "~2.4", + "php-console/php-console": "^3.1.3", + "phpspec/prophecy": "^1.6.1", + "phpstan/phpstan": "^0.12.91", + "phpunit/phpunit": "^8.5", + "predis/predis": "^1.1", + "rollbar/rollbar": "^1.3", + "ruflin/elastica": ">=0.90 <7.0.1", + "swiftmailer/swiftmailer": "^5.3|^6.0" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-mbstring": "Allow to work properly with unicode symbols", + "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)", + "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", + "php-console/php-console": "Allow sending log messages to Google Chrome", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "https://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "support": { + "issues": "https://github.com/Seldaek/monolog/issues", + "source": "https://github.com/Seldaek/monolog/tree/2.3.2" + }, + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", + "type": "tidelift" + } + ], + "time": "2021-07-23T07:42:52+00:00" + }, + { + "name": "nesbot/carbon", + "version": "2.52.0", + "source": { + "type": "git", + "url": "https://github.com/briannesbitt/Carbon.git", + "reference": "369c0e2737c56a0f39c946dd261855255a6fccbe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/369c0e2737c56a0f39c946dd261855255a6fccbe", + "reference": "369c0e2737c56a0f39c946dd261855255a6fccbe", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^7.1.8 || ^8.0", + "symfony/polyfill-mbstring": "^1.0", + "symfony/polyfill-php80": "^1.16", + "symfony/translation": "^3.4 || ^4.0 || ^5.0" + }, + "require-dev": { + "doctrine/orm": "^2.7", + "friendsofphp/php-cs-fixer": "^2.14 || ^3.0", + "kylekatarnls/multi-tester": "^2.0", + "phpmd/phpmd": "^2.9", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12.54", + "phpunit/phpunit": "^7.5.20 || ^8.5.14", + "squizlabs/php_codesniffer": "^3.4" + }, + "bin": [ + "bin/carbon" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-3.x": "3.x-dev", + "dev-master": "2.x-dev" + }, + "laravel": { + "providers": [ + "Carbon\\Laravel\\ServiceProvider" + ] + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "Carbon\\": "src/Carbon/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Nesbitt", + "email": "brian@nesbot.com", + "homepage": "https://markido.com" + }, + { + "name": "kylekatarnls", + "homepage": "https://github.com/kylekatarnls" + } + ], + "description": "An API extension for DateTime that supports 281 different languages.", + "homepage": "https://carbon.nesbot.com", + "keywords": [ + "date", + "datetime", + "time" + ], + "support": { + "issues": "https://github.com/briannesbitt/Carbon/issues", + "source": "https://github.com/briannesbitt/Carbon" + }, + "funding": [ + { + "url": "https://opencollective.com/Carbon", + "type": "open_collective" + }, + { + "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", + "type": "tidelift" + } + ], + "time": "2021-08-14T19:10:52+00:00" + }, + { + "name": "nikic/fast-route", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/FastRoute.git", + "reference": "181d480e08d9476e61381e04a71b34dc0432e812" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/FastRoute/zipball/181d480e08d9476e61381e04a71b34dc0432e812", + "reference": "181d480e08d9476e61381e04a71b34dc0432e812", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35|~5.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "FastRoute\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov", + "email": "nikic@php.net" + } + ], + "description": "Fast request router for PHP", + "keywords": [ + "router", + "routing" + ], + "support": { + "issues": "https://github.com/nikic/FastRoute/issues", + "source": "https://github.com/nikic/FastRoute/tree/master" + }, + "time": "2018-02-13T20:26:39+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v4.12.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "6608f01670c3cc5079e18c1dab1104e002579143" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6608f01670c3cc5079e18c1dab1104e002579143", + "reference": "6608f01670c3cc5079e18c1dab1104e002579143", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=7.0" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.9-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v4.12.0" + }, + "time": "2021-07-21T10:44:31+00:00" + }, + { + "name": "php-di/phpdoc-reader", + "version": "2.2.1", + "source": { + "type": "git", + "url": "https://github.com/PHP-DI/PhpDocReader.git", + "reference": "66daff34cbd2627740ffec9469ffbac9f8c8185c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-DI/PhpDocReader/zipball/66daff34cbd2627740ffec9469ffbac9f8c8185c", + "reference": "66daff34cbd2627740ffec9469ffbac9f8c8185c", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "require-dev": { + "mnapoli/hard-mode": "~0.3.0", + "phpunit/phpunit": "^8.5|^9.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "PhpDocReader\\": "src/PhpDocReader" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PhpDocReader parses @var and @param values in PHP docblocks (supports namespaced class names with the same resolution rules as PHP)", + "keywords": [ + "phpdoc", + "reflection" + ], + "support": { + "issues": "https://github.com/PHP-DI/PhpDocReader/issues", + "source": "https://github.com/PHP-DI/PhpDocReader/tree/2.2.1" + }, + "time": "2020-10-12T12:39:22+00:00" + }, + { + "name": "phpoption/phpoption", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-option.git", + "reference": "5455cb38aed4523f99977c4a12ef19da4bfe2a28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/5455cb38aed4523f99977c4a12ef19da4bfe2a28", + "reference": "5455cb38aed4523f99977c4a12ef19da4bfe2a28", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "phpunit/phpunit": "^6.5.14 || ^7.0.20 || ^8.5.19 || ^9.5.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "PhpOption\\": "src/PhpOption/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk" + } + ], + "description": "Option Type for PHP", + "keywords": [ + "language", + "option", + "php", + "type" + ], + "support": { + "issues": "https://github.com/schmittjoh/php-option/issues", + "source": "https://github.com/schmittjoh/php-option/tree/1.8.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", + "type": "tidelift" + } + ], + "time": "2021-08-28T21:27:29+00:00" + }, + { + "name": "psr/cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "support": { + "source": "https://github.com/php-fig/cache/tree/master" + }, + "time": "2016-08-06T20:24:11+00:00" + }, + { + "name": "psr/container", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "2ae37329ee82f91efadc282cc2d527fd6065a5ef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/2ae37329ee82f91efadc282cc2d527fd6065a5ef", + "reference": "2ae37329ee82f91efadc282cc2d527fd6065a5ef", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.1" + }, + "time": "2021-03-24T13:40:57+00:00" + }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "support": { + "issues": "https://github.com/php-fig/event-dispatcher/issues", + "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" + }, + "time": "2019-01-08T18:20:26+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client/tree/master" + }, + "time": "2020-06-29T06:28:15+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory/tree/master" + }, + "time": "2019-04-30T12:38:16+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/master" + }, + "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "psr/http-server-handler", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-handler.git", + "reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/aff2f80e33b7f026ec96bb42f63242dc50ffcae7", + "reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP server-side request handler", + "keywords": [ + "handler", + "http", + "http-interop", + "psr", + "psr-15", + "psr-7", + "request", + "response", + "server" + ], + "support": { + "issues": "https://github.com/php-fig/http-server-handler/issues", + "source": "https://github.com/php-fig/http-server-handler/tree/master" + }, + "time": "2018-10-30T16:46:14+00:00" + }, + { + "name": "psr/http-server-middleware", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-middleware.git", + "reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/2296f45510945530b9dceb8bcedb5cb84d40c5f5", + "reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "psr/http-message": "^1.0", + "psr/http-server-handler": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP server-side middleware", + "keywords": [ + "http", + "http-interop", + "middleware", + "psr", + "psr-15", + "psr-7", + "request", + "response" + ], + "support": { + "issues": "https://github.com/php-fig/http-server-middleware/issues", + "source": "https://github.com/php-fig/http-server-middleware/tree/master" + }, + "time": "2018-10-30T17:12:04+00:00" + }, + { + "name": "psr/log", + "version": "1.1.4", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.4" + }, + "time": "2021-05-03T11:20:27+00:00" + }, + { + "name": "psr/simple-cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/master" + }, + "time": "2017-10-23T01:57:42+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, + { + "name": "symfony/console", + "version": "v5.3.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "8b1008344647462ae6ec57559da166c2bfa5e16a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/8b1008344647462ae6ec57559da166c2bfa5e16a", + "reference": "8b1008344647462ae6ec57559da166c2bfa5e16a", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.8", + "symfony/polyfill-php80": "^1.16", + "symfony/service-contracts": "^1.1|^2", + "symfony/string": "^5.1" + }, + "conflict": { + "psr/log": ">=3", + "symfony/dependency-injection": "<4.4", + "symfony/dotenv": "<5.1", + "symfony/event-dispatcher": "<4.4", + "symfony/lock": "<4.4", + "symfony/process": "<4.4" + }, + "provide": { + "psr/log-implementation": "1.0|2.0" + }, + "require-dev": { + "psr/log": "^1|^2", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/lock": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/v5.3.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-08-25T20:02:16+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-03-23T23:28:01+00:00" + }, + { + "name": "symfony/finder", + "version": "v5.3.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "a10000ada1e600d109a6c7632e9ac42e8bf2fb93" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/a10000ada1e600d109a6c7632e9ac42e8bf2fb93", + "reference": "a10000ada1e600d109a6c7632e9ac42e8bf2fb93", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Finds files and directories via an intuitive fluent interface", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v5.3.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-08-04T21:20:46+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "16880ba9c5ebe3642d1995ab866db29270b36535" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/16880ba9c5ebe3642d1995ab866db29270b36535", + "reference": "16880ba9c5ebe3642d1995ab866db29270b36535", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-27T12:26:48+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-27T12:26:48+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010", + "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-07-28T13:41:28+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v1.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/191afdcb5804db960d26d8566b7e9a2843cab3a0", + "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "suggest": { + "psr/container": "", + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v1.1.2" + }, + "time": "2019-05-28T07:50:59+00:00" + }, + { + "name": "symfony/string", + "version": "v5.3.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "8d224396e28d30f81969f083a58763b8b9ceb0a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/8d224396e28d30f81969f083a58763b8b9ceb0a5", + "reference": "8d224396e28d30f81969f083a58763b8b9ceb0a5", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "~1.15" + }, + "require-dev": { + "symfony/error-handler": "^4.4|^5.0", + "symfony/http-client": "^4.4|^5.0", + "symfony/translation-contracts": "^1.1|^2", + "symfony/var-exporter": "^4.4|^5.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "files": [ + "Resources/functions.php" + ], + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v5.3.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-08-26T08:00:08+00:00" + }, + { + "name": "symfony/translation", + "version": "v5.3.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/translation.git", + "reference": "4d595a6d15fd3a2c67f6f31d14d15d3b7356d7a6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/translation/zipball/4d595a6d15fd3a2c67f6f31d14d15d3b7356d7a6", + "reference": "4d595a6d15fd3a2c67f6f31d14d15d3b7356d7a6", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "^1.16", + "symfony/translation-contracts": "^2.3" + }, + "conflict": { + "symfony/config": "<4.4", + "symfony/dependency-injection": "<5.0", + "symfony/http-kernel": "<5.0", + "symfony/twig-bundle": "<5.0", + "symfony/yaml": "<4.4" + }, + "provide": { + "symfony/translation-implementation": "2.3" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^4.4|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/dependency-injection": "^5.0", + "symfony/finder": "^4.4|^5.0", + "symfony/http-kernel": "^5.0", + "symfony/intl": "^4.4|^5.0", + "symfony/polyfill-intl-icu": "^1.21", + "symfony/service-contracts": "^1.1.2|^2", + "symfony/yaml": "^4.4|^5.0" + }, + "suggest": { + "psr/log-implementation": "To use logging capability in translator", + "symfony/config": "", + "symfony/yaml": "" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\Translation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools to internationalize your application", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/translation/tree/v5.3.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-08-26T08:22:53+00:00" + }, + { + "name": "symfony/translation-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/translation-contracts.git", + "reference": "95c812666f3e91db75385749fe219c5e494c7f95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/95c812666f3e91db75385749fe219c5e494c7f95", + "reference": "95c812666f3e91db75385749fe219c5e494c7f95", + "shasum": "" + }, + "require": { + "php": ">=7.2.5" + }, + "suggest": { + "symfony/translation-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Translation\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to translation", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/translation-contracts/tree/v2.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-03-23T23:28:01+00:00" + }, + { + "name": "vlucas/phpdotenv", + "version": "v5.3.0", + "source": { + "type": "git", + "url": "https://github.com/vlucas/phpdotenv.git", + "reference": "b3eac5c7ac896e52deab4a99068e3f4ab12d9e56" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/b3eac5c7ac896e52deab4a99068e3f4ab12d9e56", + "reference": "b3eac5c7ac896e52deab4a99068e3f4ab12d9e56", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "graham-campbell/result-type": "^1.0.1", + "php": "^7.1.3 || ^8.0", + "phpoption/phpoption": "^1.7.4", + "symfony/polyfill-ctype": "^1.17", + "symfony/polyfill-mbstring": "^1.17", + "symfony/polyfill-php80": "^1.17" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "ext-filter": "*", + "phpunit/phpunit": "^7.5.20 || ^8.5.14 || ^9.5.1" + }, + "suggest": { + "ext-filter": "Required to use the boolean validator." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.3-dev" + } + }, + "autoload": { + "psr-4": { + "Dotenv\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "graham@alt-three.com", + "homepage": "https://gjcampbell.co.uk/" + }, + { + "name": "Vance Lucas", + "email": "vance@vancelucas.com", + "homepage": "https://vancelucas.com/" + } + ], + "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", + "keywords": [ + "dotenv", + "env", + "environment" + ], + "support": { + "issues": "https://github.com/vlucas/phpdotenv/issues", + "source": "https://github.com/vlucas/phpdotenv/tree/v5.3.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", + "type": "tidelift" + } + ], + "time": "2021-01-20T15:23:13+00:00" + } + ], + "packages-dev": [ + { + "name": "composer/semver", + "version": "3.2.5", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "31f3ea725711245195f62e54ffa402d8ef2fdba9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/31f3ea725711245195f62e54ffa402d8ef2fdba9", + "reference": "31f3ea725711245195f62e54ffa402d8ef2fdba9", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^0.12.54", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.2.5" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2021-05-24T12:41:47+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/84674dd3a7575ba617f5a76d7e9e29a7d3891339", + "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/2.0.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2021-07-31T17:03:58+00:00" + }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v3.1.0", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", + "reference": "cf4cedb9e8991c2daa94a756176d81bf487e4c4b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/cf4cedb9e8991c2daa94a756176d81bf487e4c4b", + "reference": "cf4cedb9e8991c2daa94a756176d81bf487e4c4b", + "shasum": "" + }, + "require": { + "composer/semver": "^3.2", + "composer/xdebug-handler": "^2.0", + "doctrine/annotations": "^1.12", + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^7.1.3 || ^8.0", + "php-cs-fixer/diff": "^2.0", + "symfony/console": "^4.4.20 || ^5.1.3", + "symfony/event-dispatcher": "^4.4.20 || ^5.0", + "symfony/filesystem": "^4.4.20 || ^5.0", + "symfony/finder": "^4.4.20 || ^5.0", + "symfony/options-resolver": "^4.4.20 || ^5.0", + "symfony/polyfill-php72": "^1.23", + "symfony/polyfill-php81": "^1.23", + "symfony/process": "^4.4.20 || ^5.0", + "symfony/stopwatch": "^4.4.20 || ^5.0" + }, + "require-dev": { + "justinrainbow/json-schema": "^5.2", + "keradus/cli-executor": "^1.4", + "mikey179/vfsstream": "^1.6.8", + "php-coveralls/php-coveralls": "^2.4.3", + "php-cs-fixer/accessible-object": "^1.1", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", + "phpspec/prophecy": "^1.10.3", + "phpspec/prophecy-phpunit": "^1.1 || ^2.0", + "phpunit/phpunit": "^7.5.20 || ^8.5.14 || ^9.5", + "phpunitgoodpractices/polyfill": "^1.5", + "phpunitgoodpractices/traits": "^1.9.1", + "symfony/phpunit-bridge": "^5.2.4", + "symfony/yaml": "^4.4.20 || ^5.0" + }, + "suggest": { + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters.", + "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "support": { + "issues": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues", + "source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v3.1.0" + }, + "funding": [ + { + "url": "https://github.com/keradus", + "type": "github" + } + ], + "time": "2021-08-29T20:16:20+00:00" + }, + { + "name": "hamcrest/hamcrest-php", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "shasum": "" + }, + "require": { + "php": "^5.3|^7.0|^8.0" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "^1.4 || ^2.0", + "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "classmap": [ + "hamcrest" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "support": { + "issues": "https://github.com/hamcrest/hamcrest-php/issues", + "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.0.1" + }, + "time": "2020-07-09T08:09:16+00:00" + }, + { + "name": "hyperf/devtool", + "version": "v2.2.5", + "source": { + "type": "git", + "url": "https://github.com/hyperf/devtool.git", + "reference": "20dc78d5d04a2f5fc83f46427f2f0dc4a2c93d30" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/devtool/zipball/20dc78d5d04a2f5fc83f46427f2f0dc4a2c93d30", + "reference": "20dc78d5d04a2f5fc83f46427f2f0dc4a2c93d30", + "shasum": "" + }, + "require": { + "hyperf/command": "~2.2.0", + "hyperf/contract": "~2.2.0", + "hyperf/di": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Devtool\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Devtool\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A Devtool for Hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "devtool", + "hyperf", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-08-19T06:58:40+00:00" + }, + { + "name": "hyperf/ide-helper", + "version": "v2.2.5", + "source": { + "type": "git", + "url": "https://github.com/hyperf/ide-helper.git", + "reference": "f03e9f03e9f3cf392c7bee43d40d978528c5e116" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/ide-helper/zipball/f03e9f03e9f3cf392c7bee43d40d978528c5e116", + "reference": "f03e9f03e9f3cf392c7bee43d40d978528c5e116", + "shasum": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "IDE help files for Hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "hyperf", + "ide-helper", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-08-23T03:09:11+00:00" + }, + { + "name": "hyperf/testing", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/hyperf/testing.git", + "reference": "43679ae8f3d78b6f386c3f28673e55e774402a62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/testing/zipball/43679ae8f3d78b6f386c3f28673e55e774402a62", + "reference": "43679ae8f3d78b6f386c3f28673e55e774402a62", + "shasum": "" + }, + "require": { + "hyperf/contract": "~2.2.0", + "hyperf/http-message": "~2.2.0", + "hyperf/http-server": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2", + "phpunit/phpunit": "^9.5", + "psr/container": "^1.0|^2.0" + }, + "bin": [ + "co-phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Testing\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Testing for hyperf", + "keywords": [ + "php", + "swoole", + "testing" + ], + "support": { + "source": "https://github.com/hyperf/testing/tree/v2.2.0" + }, + "time": "2021-07-18T06:50:14+00:00" + }, + { + "name": "mockery/mockery", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "d1339f64479af1bee0e82a0413813fe5345a54ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/d1339f64479af1bee0e82a0413813fe5345a54ea", + "reference": "d1339f64479af1bee0e82a0413813fe5345a54ea", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "^2.0.1", + "lib-pcre": ">=7.0", + "php": "^7.3 || ^8.0" + }, + "conflict": { + "phpunit/phpunit": "<8.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.5 || ^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-0": { + "Mockery": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "http://blog.astrumfutura.com" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework", + "homepage": "https://github.com/mockery/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "support": { + "issues": "https://github.com/mockery/mockery/issues", + "source": "https://github.com/mockery/mockery/tree/1.4.3" + }, + "time": "2021-02-24T09:51:49+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.10.2", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "replace": { + "myclabs/deep-copy": "self.version" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2020-11-13T09:40:50+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.3" + }, + "time": "2021-07-20T11:28:43+00:00" + }, + { + "name": "phar-io/version", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "bae7c545bef187884426f042434e561ab1ddb182" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182", + "reference": "bae7c545bef187884426f042434e561ab1ddb182", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.1.0" + }, + "time": "2021-02-23T14:00:09+00:00" + }, + { + "name": "php-cs-fixer/diff", + "version": "v2.0.2", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/diff.git", + "reference": "29dc0d507e838c4580d018bd8b5cb412474f7ec3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/29dc0d507e838c4580d018bd8b5cb412474f7ec3", + "reference": "29dc0d507e838c4580d018bd8b5cb412474f7ec3", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.23 || ^6.4.3 || ^7.0", + "symfony/process": "^3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "sebastian/diff v3 backport support for PHP 5.6+", + "homepage": "https://github.com/PHP-CS-Fixer", + "keywords": [ + "diff" + ], + "support": { + "issues": "https://github.com/PHP-CS-Fixer/diff/issues", + "source": "https://github.com/PHP-CS-Fixer/diff/tree/v2.0.2" + }, + "time": "2020-10-14T08:32:19+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, + "time": "2020-06-27T09:03:43+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "5.2.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.3", + "webmozart/assert": "^1.9.1" + }, + "require-dev": { + "mockery/mockery": "~1.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + }, + "time": "2020-09-03T19:13:55+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.0" + }, + "require-dev": { + "ext-tokenizer": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0" + }, + "time": "2020-09-17T18:55:26+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "1.13.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea", + "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.2", + "php": "^7.2 || ~8.0, <8.1", + "phpdocumentor/reflection-docblock": "^5.2", + "sebastian/comparator": "^3.0 || ^4.0", + "sebastian/recursion-context": "^3.0 || ^4.0" + }, + "require-dev": { + "phpspec/phpspec": "^6.0", + "phpunit/phpunit": "^8.0 || ^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11.x-dev" + } + }, + "autoload": { + "psr-4": { + "Prophecy\\": "src/Prophecy" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/1.13.0" + }, + "time": "2021-03-17T13:42:18+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "0.12.96", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "a98bdc51318f20fcae8c953d266f81a70254917f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/a98bdc51318f20fcae8c953d266f81a70254917f", + "reference": "a98bdc51318f20fcae8c953d266f81a70254917f", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.12-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/0.12.96" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2021-08-21T11:55:13+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "9.2.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "f6293e1b30a2354e8428e004689671b83871edde" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde", + "reference": "f6293e1b30a2354e8428e004689671b83871edde", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.10.2", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-text-template": "^2.0.2", + "sebastian/code-unit-reverse-lookup": "^2.0.2", + "sebastian/complexity": "^2.0", + "sebastian/environment": "^5.1.2", + "sebastian/lines-of-code": "^1.0.3", + "sebastian/version": "^3.0.1", + "theseer/tokenizer": "^1.2.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcov": "*", + "ext-xdebug": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-03-28T07:26:59+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "3.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8", + "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:57:25+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:16:10+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "9.5.9", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "ea8c2dfb1065eb35a79b3681eee6e6fb0a6f273b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ea8c2dfb1065eb35a79b3681eee6e6fb0a6f273b", + "reference": "ea8c2dfb1065eb35a79b3681eee6e6fb0a6f273b", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.3.1", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.10.1", + "phar-io/manifest": "^2.0.3", + "phar-io/version": "^3.0.2", + "php": ">=7.3", + "phpspec/prophecy": "^1.12.1", + "phpunit/php-code-coverage": "^9.2.3", + "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.3", + "phpunit/php-timer": "^5.0.2", + "sebastian/cli-parser": "^1.0.1", + "sebastian/code-unit": "^1.0.6", + "sebastian/comparator": "^4.0.5", + "sebastian/diff": "^4.0.3", + "sebastian/environment": "^5.1.3", + "sebastian/exporter": "^4.0.3", + "sebastian/global-state": "^5.0.1", + "sebastian/object-enumerator": "^4.0.3", + "sebastian/resource-operations": "^3.0.3", + "sebastian/type": "^2.3.4", + "sebastian/version": "^3.0.2" + }, + "require-dev": { + "ext-pdo": "*", + "phpspec/prophecy-phpunit": "^2.0.1" + }, + "suggest": { + "ext-soap": "*", + "ext-xdebug": "*" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.5-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ], + "files": [ + "src/Framework/Assert/Functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.9" + }, + "funding": [ + { + "url": "https://phpunit.de/donate.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-08-31T06:47:40+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:08:49+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:08:54+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:30:19+00:00" + }, + { + "name": "sebastian/comparator", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "55f4261989e546dc112258c7a75935a81a7ce382" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", + "reference": "55f4261989e546dc112258c7a75935a81a7ce382", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T15:49:45+00:00" + }, + { + "name": "sebastian/complexity", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.7", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T15:52:27+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:10:38+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "388b6ced16caa751030f6a69e588299fa09200ac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac", + "reference": "388b6ced16caa751030f6a69e588299fa09200ac", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:52:38+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d89cc98761b8cb5a1a235a6b703ae50d34080e65", + "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:24:23+00:00" + }, + { + "name": "sebastian/global-state", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-06-11T13:31:12+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.6", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-28T06:42:11+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:12:34+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:14:26+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:17:30+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:45:17+00:00" + }, + { + "name": "sebastian/type", + "version": "2.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8cd8a1c753c90bc1a0f5372170e3e489136f914", + "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/2.3.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-06-15T12:49:02+00:00" + }, + { + "name": "sebastian/version", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c6c1022351a901512170118436c764e473f6de8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:39:44+00:00" + }, + { + "name": "swoole/ide-helper", + "version": "4.7.1", + "source": { + "type": "git", + "url": "https://github.com/swoole/ide-helper.git", + "reference": "918a98b5b264425fdb59461d9bbd7f9b504ead71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swoole/ide-helper/zipball/918a98b5b264425fdb59461d9bbd7f9b504ead71", + "reference": "918a98b5b264425fdb59461d9bbd7f9b504ead71", + "shasum": "" + }, + "require-dev": { + "guzzlehttp/guzzle": "~6.5.0", + "laminas/laminas-code": "~3.4.0", + "squizlabs/php_codesniffer": "~3.5.0", + "symfony/filesystem": "~4.0" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Team Swoole", + "email": "team@swoole.com" + } + ], + "description": "IDE help files for Swoole.", + "support": { + "issues": "https://github.com/swoole/ide-helper/issues", + "source": "https://github.com/swoole/ide-helper/tree/4.7.1" + }, + "funding": [ + { + "url": "https://gitee.com/swoole/swoole?donate=true", + "type": "custom" + }, + { + "url": "https://github.com/swoole", + "type": "github" + } + ], + "time": "2021-08-19T17:25:57+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v5.3.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "ce7b20d69c66a20939d8952b617506a44d102130" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ce7b20d69c66a20939d8952b617506a44d102130", + "reference": "ce7b20d69c66a20939d8952b617506a44d102130", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/event-dispatcher-contracts": "^2", + "symfony/polyfill-php80": "^1.16" + }, + "conflict": { + "symfony/dependency-injection": "<4.4" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "2.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/error-handler": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/service-contracts": "^1.1|^2", + "symfony/stopwatch": "^4.4|^5.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/event-dispatcher/tree/v5.3.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-08-04T21:20:46+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "69fee1ad2332a7cbab3aca13591953da9cdb7a11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/69fee1ad2332a7cbab3aca13591953da9cdb7a11", + "reference": "69fee1ad2332a7cbab3aca13591953da9cdb7a11", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/event-dispatcher": "^1" + }, + "suggest": { + "symfony/event-dispatcher-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-03-23T23:28:01+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v5.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "343f4fe324383ca46792cae728a3b6e2f708fb32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/343f4fe324383ca46792cae728a3b6e2f708fb32", + "reference": "343f4fe324383ca46792cae728a3b6e2f708fb32", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v5.3.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-07-21T12:40:44+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v5.3.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "4b78e55b179003a42523a362cc0e8327f7a69b5e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/4b78e55b179003a42523a362cc0e8327f7a69b5e", + "reference": "4b78e55b179003a42523a362cc0e8327f7a69b5e", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-php73": "~1.0", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an improved replacement for the array_replace PHP function", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "support": { + "source": "https://github.com/symfony/options-resolver/tree/v5.3.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-08-04T21:20:46+00:00" + }, + { + "name": "symfony/polyfill-php72", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "9a142215a36a3888e30d0a9eeea9766764e96976" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9a142215a36a3888e30d0a9eeea9766764e96976", + "reference": "9a142215a36a3888e30d0a9eeea9766764e96976", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php72/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-27T09:17:38+00:00" + }, + { + "name": "symfony/polyfill-php81", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "e66119f3de95efc359483f810c4c3e6436279436" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/e66119f3de95efc359483f810c4c3e6436279436", + "reference": "e66119f3de95efc359483f810c4c3e6436279436", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-21T13:25:03+00:00" + }, + { + "name": "symfony/process", + "version": "v5.3.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "38f26c7d6ed535217ea393e05634cb0b244a1967" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/38f26c7d6ed535217ea393e05634cb0b244a1967", + "reference": "38f26c7d6ed535217ea393e05634cb0b244a1967", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Executes commands in sub-processes", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/v5.3.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-08-04T21:20:46+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v5.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "b24c6a92c6db316fee69e38c80591e080e41536c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/b24c6a92c6db316fee69e38c80591e080e41536c", + "reference": "b24c6a92c6db316fee69e38c80591e080e41536c", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/service-contracts": "^1.0|^2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a way to profile code", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/stopwatch/tree/v5.3.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-07-10T08:58:57+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2021-07-28T10:34:58+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.10.0", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", + "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<4.6.1 || 4.6.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.13" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.10.0" + }, + "time": "2021-03-09T10:59:23+00:00" + } + ], + "aliases": [], + "minimum-stability": "dev", + "stability-flags": [], + "prefer-stable": true, + "prefer-lowest": false, + "platform": { + "php": ">=7.3" + }, + "platform-dev": [], + "plugin-api-version": "2.0.0" +} diff --git a/config/autoload/annotations.php b/config/autoload/annotations.php index 1e2f0b4..1423a25 100644 --- a/config/autoload/annotations.php +++ b/config/autoload/annotations.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/config/autoload/aspects.php b/config/autoload/aspects.php index 55b80d5..f46bd96 100644 --- a/config/autoload/aspects.php +++ b/config/autoload/aspects.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/config/autoload/auth.php b/config/autoload/auth.php deleted file mode 100644 index e6c1fc1..0000000 --- a/config/autoload/auth.php +++ /dev/null @@ -1,59 +0,0 @@ - [ - // 全局变量 名称 - 'requestName' => 'api', - // 实现类,请实现接口 \Lengbin\Auth\IdentityRepositoryInterface::class - 'identityClass' => \App\Model\User::class, - // 验证器方法,支持 - // header: \Lengbin\Auth\Method\HttpHeaderAuth::class //默认接收参数名称:X-Api-Token - // query : \Lengbin\Auth\Method\QueryParamAuth::class //默认接收参数名称:access-token - // sign : \Lengbin\Auth\Method\SignAuth::class - // 单个 - // 'method' => \Lengbin\Auth\Method\QueryParamAuth::class, - // 如果为 数组 则为 混合验证 - // key => val 接收参数名称 => 验证类 - 'method' => [ - \Lengbin\Auth\Method\HttpHeaderAuth::class, - 'token' => \Lengbin\Auth\Method\QueryParamAuth::class, - ], - //路由白名单。列如 /test/{id}, 可以使用*来通配, /test/* - 'whitelist' => [], - //公共访问,不走验证。列如 /test/{id}, 可以使用*来通赔, /test/* - 'public' => [], - ], - * ]; - */ - -use App\Component\User; -use Lengbin\Auth\Method\HttpHeaderAuth; - -return [ - 'api' => [ - // 全局变量 名称 - 'requestName' => 'api', - // 实现类,请实现接口 \Lengbin\Auth\IdentityRepositoryInterface::class - 'identityClass' => User::class, - // 验证器方法,支持 - // header: \Lengbin\Auth\Method\HttpHeaderAuth::class //默认接收参数名称:X-Api-Token - // query : \Lengbin\Auth\Method\QueryParamAuth::class //默认接收参数名称:access-token - // sign : \Lengbin\Auth\Method\SignAuth::class - // 单个 - // 'method' => \Lengbin\Auth\Method\QueryParamAuth::class, - // 如果为 数组 则为 混合验证 - // key => val 接收参数名称 => 验证类 - 'method' => [ - 'token' => HttpHeaderAuth::class, -// \Lengbin\Auth\Method\QueryParamAuth::class, - ], - //路由白名单。列如 /test/{id}, 可以使用*来通配, /test/* - 'whitelist' => [], - //公共访问,不走验证。列如 /test/{id}, 可以使用*来通配, /test/* - 'public' => [ - '/favicon.ico' - ], - ], -]; diff --git a/config/autoload/cache.php b/config/autoload/cache.php index 42d7a8a..def82eb 100644 --- a/config/autoload/cache.php +++ b/config/autoload/cache.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/config/autoload/commands.php b/config/autoload/commands.php index 55b80d5..f46bd96 100644 --- a/config/autoload/commands.php +++ b/config/autoload/commands.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/config/autoload/databases.php b/config/autoload/databases.php index 68abb95..4deb286 100644 --- a/config/autoload/databases.php +++ b/config/autoload/databases.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/config/autoload/dependencies.php b/config/autoload/dependencies.php index 55b80d5..f46bd96 100644 --- a/config/autoload/dependencies.php +++ b/config/autoload/dependencies.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/config/autoload/devtool.php b/config/autoload/devtool.php index 0db04bf..3c2f607 100644 --- a/config/autoload/devtool.php +++ b/config/autoload/devtool.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/config/autoload/exceptions.php b/config/autoload/exceptions.php index cc1ae64..b848177 100644 --- a/config/autoload/exceptions.php +++ b/config/autoload/exceptions.php @@ -5,23 +5,15 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ - -use App\Exception\Handler\ApiDogExceptionHandler; -use Lengbin\Hyperf\Common\Exception\Handler\AppExceptionHandler; -use Lengbin\Hyperf\Common\Exception\Handler\BusinessExceptionHandler; -use Lengbin\Hyperf\Auth\Exception\Handler\AuthTokenExceptionHandler; - return [ 'handler' => [ 'http' => [ - AuthTokenExceptionHandler::class, - ApiDogExceptionHandler::class, - BusinessExceptionHandler::class, - AppExceptionHandler::class, + Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler::class, + App\Exception\Handler\AppExceptionHandler::class, ], ], ]; diff --git a/config/autoload/genCode.php b/config/autoload/genCode.php deleted file mode 100644 index 586f636..0000000 --- a/config/autoload/genCode.php +++ /dev/null @@ -1,167 +0,0 @@ - [ - 'controller' => [ - 'path' => 'app/Controller', - ], - 'service' => [ - 'path' => 'app/Service', - ], - 'errorCode' => [ - 'path' => 'app/Constant/Errors', - ], - // 操作 默认选项配置 - 'actions' => [ - [ - 'name' => '删除', - 'type' => 'action', - 'target' => 'button', - 'path' => 'remove', - 'tip' => '您确定删除吗?', - ], - [ - 'name' => '创建', - 'type' => 'action', - 'target' => 'button', - 'path' => 'create', - 'form' => [], - ], - [ - 'name' => '导入', - 'type' => 'action', - 'target' => 'button', - 'path' => 'import', - ], - [ - 'name' => '导出', - 'type' => 'action', - 'target' => 'button', - 'path' => 'export', - ], - [ - 'name' => '冻结', - 'type' => 'action', - 'target' => 'button', - 'path' => 'changeStatus', - 'data' => [ - 'status' => 2, - ], - ], - [ - 'name' => '编辑', - 'label' => '行内编辑', - 'type' => 'operation', - 'target' => 'link', - 'path' => 'detail', - 'form' => [], - ], - [ - 'name' => '删除', - 'label' => '行内删除', - 'type' => 'operation', - 'target' => 'link', - 'path' => 'remove', - 'tip' => '您确定删除吗?', - ], - [ - 'name' => '修改状态', - 'type' => 'operation', - 'target' => 'link', - 'path' => 'changeStatus', - 'form' => [], - 'condition' => [ - [ - 'judge' => [ - [ - 'attribute' => 'status', - 'type' => '=', - 'value' => 1, - ], - ], - 'type' => 'and', - 'label' => '冻结', - ], - [ - 'judge' => [ - [ - 'attribute' => 'status', - 'type' => '=', - 'value' => 2, - ], - ], - 'type' => 'and', - 'label' => '解冻', - ], - ], - ], - ], - ], - //控制器 继承配置 - 'controller' => [ - 'prefix'=> '/admin', - 'inheritance' => 'Controller', - 'uses' => [ - 'App\Controller\Controller', - 'Hyperf\Apidog\Annotation\ApiController', - 'Hyperf\Apidog\Annotation\Header', - 'Hyperf\Di\Annotation\Inject', - 'Hyperf\Apidog\Annotation\PostApi', - 'Hyperf\Apidog\Annotation\Body', - 'Hyperf\Apidog\Annotation\ApiResponse', - 'Hyperf\Utils\Context' - ], - 'comment' => function ($build) { - $name = $build->getGenerateCodeEntity()->getName(); - return [ - '@ApiController(tag="'.$name.'")', - '@Header(key="Token|token", rule="required|string")' - ]; - }, - 'properties' => function ($build) { - $serviceName = $build->getService()->getClassname(); - $properties[] = [ - "name" => lcfirst($serviceName), - 'comments' => [ - '@Inject()', - "@var {$serviceName}", - ], - ]; - return $properties; - }, - 'annotationValidateParse' => 'App\Component\Generate\Build\Action\Controller\ValidateParse\ApidogValidateParse', - ], - 'errorCode' => [ - 'inheritance' => 'BaseEnum', - 'use' => 'Lengbin\Hyperf\ErrorCode\BaseEnum', - // 错误码 业务码 前缀版本 - 'prefix' => [ -// 'api' => 'B-002', // 其他服务应用 -// 'admin' => 'B-001', - 'default' => 'B-001', - ], - ], - 'exception' => [ - 'inheritance' => 'BusinessException', - 'use' => 'Lengbin\Hyperf\Common\Exception\BusinessException', - ], - 'service' => [ - 'inheritance' => 'BaseService', - 'use' => 'Lengbin\Hyperf\Common\Framework\BaseService', - ], - // build action config - // class = (firstNamespace ? firstNamespace : namespace ). path . suffix - 'action' => [ - 'service' => [ - 'namespace' => '\App\Component\Generate\Build\Action\Service\Hyperf', - 'suffix' => 'ActionServiceBuild', -// 'firstNamespace' - ], - 'controller' => [ - 'namespace' => '\App\Component\Generate\Build\Action\Controller\Hyperf', - 'suffix' => 'ActionControllerBuild', - ], - ], -]; - - diff --git a/config/autoload/jwt.php b/config/autoload/jwt.php deleted file mode 100644 index ae2b2dc..0000000 --- a/config/autoload/jwt.php +++ /dev/null @@ -1,12 +0,0 @@ - 'HMACSHA256', - 'key' => 'ice', - // jwt 过期时间 - 'exp' => 2 * 3600, - // 刷新token 过期时间 - 'ttl' => 24 * 3600 * 30, - // 是否 单点登录 - 'sso' => true, - 'ssoKey' => 'admin_id' -]; diff --git a/config/autoload/listeners.php b/config/autoload/listeners.php index 55b80d5..f46bd96 100644 --- a/config/autoload/listeners.php +++ b/config/autoload/listeners.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/config/autoload/logger.php b/config/autoload/logger.php index 332145b..5341811 100644 --- a/config/autoload/logger.php +++ b/config/autoload/logger.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/config/autoload/middlewares.php b/config/autoload/middlewares.php index aeeeb94..77286ee 100644 --- a/config/autoload/middlewares.php +++ b/config/autoload/middlewares.php @@ -5,21 +5,15 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ -use Hyperf\Apidog\Middleware\ApiValidationMiddleware; -use Lengbin\Hyperf\Auth\Middleware\ApiMiddleware; use Lengbin\Hyperf\Common\Middleware\CorsMiddleware; -use Lengbin\Hyperf\YiiSoft\Rbac\Middleware\PermissionMiddleware; return [ 'http' => [ CorsMiddleware::class, - ApiMiddleware::class, - ApiValidationMiddleware::class, - PermissionMiddleware::class ], ]; diff --git a/config/autoload/processes.php b/config/autoload/processes.php index 55b80d5..f46bd96 100644 --- a/config/autoload/processes.php +++ b/config/autoload/processes.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/config/autoload/rbac.php b/config/autoload/rbac.php deleted file mode 100644 index 98c599e..0000000 --- a/config/autoload/rbac.php +++ /dev/null @@ -1,47 +0,0 @@ - \Lengbin\YiiSoft\Rbac\Manager\DbManager::class, - * 'connection' => null, // 连接db ,可以不需要 - * 'cache' => \Cache\Cache::class, //缓存类,可以不需要 - * 'log' => null // log key 名称 - * 'defaultRoles' => [], // 默认角色,可以不需要 - * 'item' => null, // item 表名称,可以不需要 - * 'assignment' => null, // assignment 表名称,可以不需要 - * 'rule' => null, // rule 表名称,可以不需要 - * 'itemChild' => null, // itemChild 表名称,可以不需要 - * 'menu' => null, // menu 表名称,可以不需要 - * ]; - * - * PhpManager - * return [ - * 'driver' => \Lengbin\YiiSoft\Rbac\Manager\PhpManager::class, - * 'cache' => \Cache\Cache::class, //缓存类,可以不需要 - * 'log' => null // log key 名称 - * 'defaultRoles' => [], // 默认角色,可以不需要 - * 'item' => null, // item 缓存名称,可以不需要 - * 'assignment' => null, // assignment 缓存名称,可以不需要 - * 'rule' => null, // rule 缓存名称,可以不需要 - * 'menu' => null, // menu 表名称,可以不需要 - * ]; - * - * PhpManagerFile - * return [ - * 'driver' => \Lengbin\YiiSoft\Rbac\Manager\PhpManagerFile::class, - * 'directory' => './cache', //保存文件路径,可以不需要 - * 'log' => null // log key 名称 - * 'defaultRoles' => [], // 默认角色,可以不需要 - * 'item' => null, // item 保存文件名称,可以不需要 - * 'assignment' => null, // assignment 保存文件名称,可以不需要 - * 'rule' => null ,// rule 保存文件名称,可以不需要 - * 'menu' => null, // menu 表名称,可以不需要 - * ]; - */ - -use Lengbin\YiiSoft\Rbac\Manager\DbManager; - -return [ - 'driver' => DbManager::class, -]; diff --git a/config/autoload/redis.php b/config/autoload/redis.php index 026a480..3180b62 100644 --- a/config/autoload/redis.php +++ b/config/autoload/redis.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/config/autoload/server.php b/config/autoload/server.php index 7c4666a..56f6afb 100644 --- a/config/autoload/server.php +++ b/config/autoload/server.php @@ -5,12 +5,13 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use Hyperf\Server\Event; use Hyperf\Server\Server; -use Hyperf\Server\SwooleEvent; +use Swoole\Constant; return [ 'mode' => SWOOLE_PROCESS, @@ -19,27 +20,27 @@ 'name' => 'http', 'type' => Server::SERVER_HTTP, 'host' => '0.0.0.0', - 'port' => 9511, + 'port' => 9501, 'sock_type' => SWOOLE_SOCK_TCP, 'callbacks' => [ - SwooleEvent::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'], + Event::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'], ], ], ], 'settings' => [ - 'enable_coroutine' => true, - 'worker_num' => swoole_cpu_num(), - 'pid_file' => BASE_PATH . '/runtime/hyperf.pid', - 'open_tcp_nodelay' => true, - 'max_coroutine' => 100000, - 'open_http2_protocol' => true, - 'max_request' => 100000, - 'socket_buffer_size' => 2 * 1024 * 1024, - 'buffer_output_size' => 2 * 1024 * 1024, + Constant::OPTION_ENABLE_COROUTINE => true, + Constant::OPTION_WORKER_NUM => swoole_cpu_num(), + Constant::OPTION_PID_FILE => BASE_PATH . '/runtime/hyperf.pid', + Constant::OPTION_OPEN_TCP_NODELAY => true, + Constant::OPTION_MAX_COROUTINE => 100000, + Constant::OPTION_OPEN_HTTP2_PROTOCOL => true, + Constant::OPTION_MAX_REQUEST => 100000, + Constant::OPTION_SOCKET_BUFFER_SIZE => 2 * 1024 * 1024, + Constant::OPTION_BUFFER_OUTPUT_SIZE => 2 * 1024 * 1024, ], 'callbacks' => [ - SwooleEvent::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'], - SwooleEvent::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'], - SwooleEvent::ON_WORKER_EXIT => [Hyperf\Framework\Bootstrap\WorkerExitCallback::class, 'onWorkerExit'], + Event::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'], + Event::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'], + Event::ON_WORKER_EXIT => [Hyperf\Framework\Bootstrap\WorkerExitCallback::class, 'onWorkerExit'], ], ]; diff --git a/config/config.php b/config/config.php index 1a900f2..38823e0 100644 --- a/config/config.php +++ b/config/config.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ @@ -16,7 +16,6 @@ 'app_name' => env('APP_NAME', 'skeleton'), 'app_env' => env('APP_ENV', 'dev'), 'scan_cacheable' => env('SCAN_CACHEABLE', false), - 'image_url' => env('IMAGE_URL', ''), StdoutLoggerInterface::class => [ 'log_level' => [ LogLevel::ALERT, diff --git a/config/container.php b/config/container.php index aab53b5..2a09133 100644 --- a/config/container.php +++ b/config/container.php @@ -8,7 +8,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/config/routes.php b/config/routes.php index 4efb174..b3879ed 100644 --- a/config/routes.php +++ b/config/routes.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/doc/swagger/DemoController.php b/doc/swagger/DemoController.php deleted file mode 100644 index b84a599..0000000 --- a/doc/swagger/DemoController.php +++ /dev/null @@ -1,167 +0,0 @@ - 0, - 'id' => 1, - 'params' => $this->request->post(), - ]; - } - - // 自定义的校验方法 rule 中 cb_*** 方式调用 - public function checkName($attribute, $value) - { - if ($value === 'a') { - return "拒绝添加 " . $value; - } - - return true; - } - - /** - * 请注意 body 类型 rules 为数组类型 - * @DeleteApi(path="/demo", description="删除用户") - * @Body(rules={ - * "id|用户id":"required|integer|max:10", - * "deepAssoc|深层关联":{ - * "name_1|名称": "required|integer|max:20" - * }, - * "deepUassoc|深层索引":{{ - * "name_2|名称": "required|integer|max:20" - * }}, - * "a.b.c.*.e|aa":"required|integer|max:10", - * }) - * @ApiResponse(code="-1", description="参数错误") - * @ApiResponse(code="0", description="删除成功", schema={"id":1}) - */ - public function delete() - { - $body = $this->request->getBody()->getContents(); - return [ - 'code' => 0, - 'query' => $this->request->getQueryParams(), - 'body' => json_decode($body, true), - ]; - } - - /** - * @GetApi(path="/demo", description="获取用户详情") - * @Query(key="id", rule="required|integer|max:10") - * @ApiResponse(code="-1", description="参数错误") - * @ApiResponse(code="0", schema={"id":1,"name":"张三","age":1}, template="success") - * @RouterAuthAnnotation(isWhitelist=true) - */ - public function get() - { - return [ - 'code' => 0, - 'id' => 1, - 'name' => '张三', - 'age' => 1, - 'data' => $this->getValidateData(), - 'user_id' => $this->getAuth()->getId(), - ]; - } - - /** - * schema中可以指定$ref属性引用定义好的definition - * @GetApi(path="/demo/info", description="获取用户详情") - * @Query(key="id", rule="required|integer|max:0") - * @ApiResponse(code="-1", description="参数错误") - * @ApiResponse(code="0", schema={"$ref": "DemoOkResponse"}) - */ - public function info() - { - return [ - 'code' => 0, - 'id' => 1, - 'name' => '张三', - 'age' => 1, - ]; - } - - /** - * @GetApi(path="/demos", summary="用户列表") - * @ApiResponse(code="200", description="ok", schema={{ - * "a|aa": {{ - * "a|aaa":"b","c|ccc":5.2 - * }}, - * "b|ids": {1,2,3}, - * "c|strings": {"a","b","c"}, - * "d|dd": {"a":"b","c":"d"}, - * "e|ee": "f" - * }}) - */ - public function list() - { - return [ - [ - "a" => [ - ["a" => "b", "c" => "d"], - ], - "b" => [1, 2, 3], - "c" => ["a", "b", "c"], - "d" => [ - "a" => "b", - "c" => "d", - ], - "e" => "f", - ], - ]; - } - -} diff --git a/phpstan.neon b/phpstan.neon index fd82253..56a03d9 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,5 +4,7 @@ # vendor/bin/phpstan analyse app --memory-limit 200M -l 0 # parameters: + reportUnmatchedIgnoredErrors: false ignoreErrors: -# - '#Static call to instance method Hyperf\\DbConnection\\Db::[a-zA-Z0-9\\_]+\(\)#' \ No newline at end of file + - '#Static call to instance method Hyperf\\HttpServer\\Router\\Router::[a-zA-Z0-9\\_]+\(\)#' + - '#Static call to instance method Hyperf\\DbConnection\\Db::[a-zA-Z0-9\\_]+\(\)#' diff --git a/server.sh b/server.sh deleted file mode 100644 index b80456f..0000000 --- a/server.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -#pidFile="runtime/hyperf.pid" -# -#if [ -f "$pidFile" ]; then -# kill -15 `cat $pidFile` -#fi -# -#rm -rf runtime/container - -php -d swoole.use_shortname=Off bin/hyperf.php gen:error-code - -# php -d swoole.use_shortname=Off -e bin/hyperf.php start diff --git a/test/Cases/ExampleTest.php b/test/Cases/ExampleTest.php index 1c8d028..6f28d24 100644 --- a/test/Cases/ExampleTest.php +++ b/test/Cases/ExampleTest.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ diff --git a/test/HttpTestCase.php b/test/HttpTestCase.php index d22b243..cabfcbf 100644 --- a/test/HttpTestCase.php +++ b/test/HttpTestCase.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ @@ -20,6 +20,7 @@ * @method post($uri, $data = [], $headers = []) * @method json($uri, $data = [], $headers = []) * @method file($uri, $data = [], $headers = []) + * @method request($method, $path, $options = []) */ abstract class HttpTestCase extends TestCase { diff --git a/test/bootstrap.php b/test/bootstrap.php index 012bd42..8396ecb 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://doc.hyperf.io + * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ @@ -22,6 +22,8 @@ require BASE_PATH . '/vendor/autoload.php'; +Hyperf\Di\ClassLoader::init(); + $container = require BASE_PATH . '/config/container.php'; $container->get(Hyperf\Contract\ApplicationInterface::class); From 90f2a889825a5920e6580fdefb750c9dc2c5db6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Thu, 2 Sep 2021 23:31:34 +0800 Subject: [PATCH 76/82] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=9F=BA=E7=A1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 42 +- .env.online | 41 + README.md | 15 +- app/Controller/IndexController.php | 23 + app/Kernel/BaseModel.php | 17 + app/Kernel/ClassMap/Coroutine.php | 106 ++ app/Kernel/Commands/Model/ModelCommand.php | 96 ++ .../Commands/Model/ModelUpdateVisitor.php | 60 + app/Kernel/Commands/Model/stubs/Model.stub | 45 + .../Exceptions}/BusinessException.php | 2 +- .../Handler/AppExceptionHandler.php | 2 +- app/Kernel/Log/AppendRequestIdProcessor.php | 35 + app/Kernel/Log/LoggerFactory.php | 21 + app/Kernel/Middleware/CorsMiddleware.php | 54 + app/Kernel/Middleware/DebugLogMiddleware.php | 38 + app/Middleware/TokenMiddleware.php | 15 + bin/hyperf.php | 4 +- composer.json | 10 +- composer.lock | 1333 +++++++++++++---- config/autoload/annotations.php | 5 +- config/autoload/cache.php | 2 +- config/autoload/databases.php | 17 +- config/autoload/dependencies.php | 39 +- config/autoload/exceptions.php | 2 +- config/autoload/listeners.php | 4 + config/autoload/logger.php | 24 +- config/autoload/middlewares.php | 8 +- config/autoload/processes.php | 4 + config/autoload/redis.php | 17 +- config/autoload/server.php | 43 +- config/autoload/snowflake.php | 26 + .../autoload/translation.php | 12 +- config/config.php | 1 + config/routes.php | 2 +- 34 files changed, 1807 insertions(+), 358 deletions(-) create mode 100644 .env.online create mode 100644 app/Kernel/BaseModel.php create mode 100644 app/Kernel/ClassMap/Coroutine.php create mode 100644 app/Kernel/Commands/Model/ModelCommand.php create mode 100644 app/Kernel/Commands/Model/ModelUpdateVisitor.php create mode 100644 app/Kernel/Commands/Model/stubs/Model.stub rename app/{Exception => Kernel/Exceptions}/BusinessException.php (95%) rename app/{Exception => Kernel/Exceptions}/Handler/AppExceptionHandler.php (96%) create mode 100644 app/Kernel/Log/AppendRequestIdProcessor.php create mode 100644 app/Kernel/Log/LoggerFactory.php create mode 100644 app/Kernel/Middleware/CorsMiddleware.php create mode 100644 app/Kernel/Middleware/DebugLogMiddleware.php create mode 100644 app/Middleware/TokenMiddleware.php create mode 100644 config/autoload/snowflake.php rename app/Model/Model.php => config/autoload/translation.php (67%) diff --git a/.env.example b/.env.example index 6879583..4a72fa3 100644 --- a/.env.example +++ b/.env.example @@ -1,17 +1,41 @@ -APP_NAME=skeleton +# 环境 APP_ENV=dev -DB_DRIVER=mysql -DB_HOST=localhost -DB_PORT=3306 -DB_DATABASE=hyperf +# 项目名称 +APP_NAME=hyperf-advanced + +# 是否缓存扫描注解 +SCAN_CACHEABLE=false + +CRONTAB_ENABLE=false + +# 监听端口 +HTTP_PORT=9501 +# RPC_PORT=9503 + +# 日志等级,默认DEBUG +LOG_LEVEL=200 + +# Swoole进程数配置 +WORKER_NUM=2 +TASK_WORKER_NUM=2 + +# MySQL数据库配置 +DB_READ_HOST=127.0.0.1 +DB_WRITE_HOST=127.0.0.1 DB_USERNAME=root +DB_PORT=3306 +DB_DATABASE=hyperf_admin DB_PASSWORD= DB_CHARSET=utf8mb4 DB_COLLATION=utf8mb4_unicode_ci -DB_PREFIX= +DB_PREFIX=t_ -REDIS_HOST=localhost -REDIS_AUTH=(null) + +# Redis配置 +REDIS_HOST=127.0.0.1 REDIS_PORT=6379 -REDIS_DB=0 \ No newline at end of file +REDIS_DB=3 +REDIS_AUTH= + +HOST=http://127.0.0.1:9501 diff --git a/.env.online b/.env.online new file mode 100644 index 0000000..11c0bcc --- /dev/null +++ b/.env.online @@ -0,0 +1,41 @@ +# 环境 +APP_ENV=production + +# 项目名称 +APP_NAME=hyperf-advanced + +# 是否缓存扫描注解 +SCAN_CACHEABLE=false + +CRONTAB_ENABLE=true + +# 监听端口 +HTTP_PORT=9501 +# RPC_PORT=9503 + +# 日志等级,默认DEBUG +LOG_LEVEL=200 + +# Swoole进程数配置 +WORKER_NUM=2 +TASK_WORKER_NUM=2 + +# MySQL数据库配置 +DB_READ_HOST=127.0.0.1 +DB_WRITE_HOST=127.0.0.1 +DB_USERNAME=root +DB_PORT=3306 +DB_DATABASE=hyperf_admin +DB_PASSWORD= +DB_CHARSET=utf8mb4 +DB_COLLATION=utf8mb4_unicode_ci +DB_PREFIX=t_ + + +# Redis配置 +REDIS_HOST=127.0.0.1 +REDIS_PORT=6379 +REDIS_DB=3 +REDIS_AUTH= + +HOST=http://127.0.0.1:9501 diff --git a/README.md b/README.md index d3d7429..038de16 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ If You Like This Please Give Me Star -基于 Hyperf 2.0 && YII3 +基于 Hyperf 2.0 -目前还在研发中,请慎用 +目前还在重构中,看看就行,别拉下来 安装 ------------ @@ -24,16 +24,5 @@ git clone -b 2.0 https://github.com/ice-leng/hyperf-advanced.git ``` 使用扩展 -------------- -- [jwt](https://github.com/ice-leng/hyperf-jwt) -- [授权验证-yii,支持路由白名单](https://github.com/ice-leng/hyperf-auth) -- [枚举,错误码合并生成](https://github.com/ice-leng/hyperf-error-code) - [swagger,路由](https://github.com/daodao97/apidog) -- [rbac, 菜单](https://github.com/ice-leng/hyperf-yii-rbac) -感谢 --------------- -[Hyperf](https://github.com/hyperf) - -[Yii](https://github.com/yiisoft) - -[dadao](https://github.com/daodao97) diff --git a/app/Controller/IndexController.php b/app/Controller/IndexController.php index 60a442e..87bcd0d 100644 --- a/app/Controller/IndexController.php +++ b/app/Controller/IndexController.php @@ -11,13 +11,36 @@ */ namespace App\Controller; +use App\Kernel\Context\Coroutine; +use Hyperf\Contract\StdoutLoggerInterface; +use Hyperf\Di\Annotation\Inject; + class IndexController extends AbstractController { + + /** + * @Inject() + * @var StdoutLoggerInterface + */ + protected StdoutLoggerInterface $logger; + public function index() { $user = $this->request->input('user', 'Hyperf'); $method = $this->request->getMethod(); + go(function () { + $this->logger->info('ccccc'); + }); + + $this->logger->info('zzzz'); + + go(function () { + $this->logger->info('vvv'); + }); + + $this->logger->info('xxxx'); + return [ 'method' => $method, 'message' => "Hello {$user}.", diff --git a/app/Kernel/BaseModel.php b/app/Kernel/BaseModel.php new file mode 100644 index 0000000..b0a5575 --- /dev/null +++ b/app/Kernel/BaseModel.php @@ -0,0 +1,17 @@ +has(StdoutLoggerInterface::class)) { + /* @var LoggerInterface $logger */ + $logger = $container->get(StdoutLoggerInterface::class); + /* @var FormatterInterface $formatter */ + if ($container->has(FormatterInterface::class)) { + $formatter = $container->get(FormatterInterface::class); + $logger->warning($formatter->format($throwable)); + } else { + $logger->warning(sprintf('Uncaptured exception[%s] detected in %s::%d.', get_class($throwable), $throwable->getFile(), $throwable->getLine())); + } + } + } + } + }); + + try { + return $coroutine->getId(); + } catch (Throwable $exception) { + return -1; + } + } + + /** + * Returns the current coroutine ID. + * Returns -1 when running in non-coroutine context. + */ + public static function id(): int + { + return Co::id(); + } + + public static function defer(callable $callable) + { + Co::defer($callable); + } + + public static function sleep(float $seconds) + { + usleep(intval($seconds * 1000 * 1000)); + } + + /** + * Returns the parent coroutine ID. + * Returns 0 when running in the top level coroutine. + * @throws RunningInNonCoroutineException when running in non-coroutine context + * @throws CoroutineDestroyedException when the coroutine has been destroyed + */ + public static function parentId(?int $coroutineId = null): int + { + return Co::pid($coroutineId); + } + + public static function inCoroutine(): bool + { + return Co::id() > 0; + } +} diff --git a/app/Kernel/Commands/Model/ModelCommand.php b/app/Kernel/Commands/Model/ModelCommand.php new file mode 100644 index 0000000..1f6d5f5 --- /dev/null +++ b/app/Kernel/Commands/Model/ModelCommand.php @@ -0,0 +1,96 @@ +getSchemaBuilder($option->getPool()); + $table = Str::replaceFirst($option->getPrefix(), '', $table); + $columns = $this->formatColumns($builder->getColumnTypeListing($table)); + + $project = new Project(); + $class = $option->getTableMapping()[$table] ?? Str::studly(Str::singular($table)); + $class = $project->namespace($option->getPath()) . $class; + $path = BASE_PATH . '/' . $project->path($class); + + if (! file_exists($path)) { + $this->mkdir($path); + file_put_contents($path, $this->buildClassPrimaryKey($table, $class, $this->getPrimaryKey($columns), $option)); + } + + $columns = $this->getColumns($class, $columns, $option->isForceCasts()); + + $stms = $this->astParser->parse(file_get_contents($path)); + $traverser = new NodeTraverser(); + $traverser->addVisitor(make(ModelUpdateVisitor::class, [ + 'class' => $class, + 'columns' => $columns, + 'option' => $option, + ])); + $traverser->addVisitor(make(ModelRewriteConnectionVisitor::class, [$class, $option->getPool()])); + $data = make(ModelData::class)->setClass($class)->setColumns($columns); + foreach ($option->getVisitors() as $visitorClass) { + $traverser->addVisitor(make($visitorClass, [$option, $data])); + } + $stms = $traverser->traverse($stms); + $code = $this->printer->prettyPrintFile($stms); + + file_put_contents($path, $code); + $this->output->writeln(sprintf('Model %s was created.', $class)); + + if ($option->isWithIde()) { + $this->generateIDE($code, $option, $data); + } + } + + protected function replacePrimaryKey(string &$stub, string $primaryKey): self + { + $stub = str_replace(['%PRIMARY_KEY%'], [$primaryKey], $stub); + + return $this; + } + + /** + * Build the class with the given name. + */ + protected function buildClassPrimaryKey(string $table, string $name, string $primaryKey, ModelOption $option): string + { + $stub = file_get_contents(__DIR__ . '/stubs/Model.stub'); + + return $this->replaceNamespace($stub, $name) + ->replaceInheritance($stub, $option->getInheritance()) + ->replaceConnection($stub, $option->getPool()) + ->replaceUses($stub, $option->getUses()) + ->replaceClass($stub, $name) + ->replacePrimaryKey($stub, $primaryKey) + ->replaceTable($stub, $table); + } +} diff --git a/app/Kernel/Commands/Model/ModelUpdateVisitor.php b/app/Kernel/Commands/Model/ModelUpdateVisitor.php new file mode 100644 index 0000000..52937cd --- /dev/null +++ b/app/Kernel/Commands/Model/ModelUpdateVisitor.php @@ -0,0 +1,60 @@ +columns as $column) { + if ($column['column_key'] === 'PRI' || in_array($column['column_name'], $exceptColumn)) { + continue; + } + $items[] = new Node\Expr\ArrayItem(new String_($column['column_name'])); + } + $node->default = new Array_($items, [ + 'kind' => Array_::KIND_SHORT, + ]); + return $node; + } + + protected function formatDatabaseType(string $type): ?string + { + switch ($type) { + case 'tinyint': + case 'smallint': + case 'mediumint': + case 'int': + return 'integer'; + case 'bigint': + case 'decimal': + case 'float': + case 'double': + case 'real': + return 'string'; + case 'bool': + case 'boolean': + return 'boolean'; + default: + return null; + } + } +} diff --git a/app/Kernel/Commands/Model/stubs/Model.stub b/app/Kernel/Commands/Model/stubs/Model.stub new file mode 100644 index 0000000..1810c39 --- /dev/null +++ b/app/Kernel/Commands/Model/stubs/Model.stub @@ -0,0 +1,45 @@ +idGenerator->generate()); + $record['context']['coroutine_id'] = Coroutine::id(); + return $record; + } +} diff --git a/app/Kernel/Log/LoggerFactory.php b/app/Kernel/Log/LoggerFactory.php new file mode 100644 index 0000000..57e44c9 --- /dev/null +++ b/app/Kernel/Log/LoggerFactory.php @@ -0,0 +1,21 @@ +get(HyperfLoggerFactory::class)->make(); + } +} diff --git a/app/Kernel/Middleware/CorsMiddleware.php b/app/Kernel/Middleware/CorsMiddleware.php new file mode 100644 index 0000000..b8e0590 --- /dev/null +++ b/app/Kernel/Middleware/CorsMiddleware.php @@ -0,0 +1,54 @@ +getHeaderLine('Access-Control-Request-Headers'); + if (empty($header)) { + $header = '*'; + } + + // 设置跨域 + $response = Context::get(ResponseInterface::class); + $response = $response->withAddedHeader('Access-Control-Expose-Headers', '*') + ->withAddedHeader('Access-Control-Allow-Origin', '*') + ->withAddedHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, DELETE') + ->withAddedHeader('Access-Control-Allow-Headers', $header); + Context::set(ResponseInterface::class, $response); + + if (strtoupper($request->getMethod()) == 'OPTIONS') { + return $response; + } + + $response = $handler->handle($request); + return $response; + } +} diff --git a/app/Kernel/Middleware/DebugLogMiddleware.php b/app/Kernel/Middleware/DebugLogMiddleware.php new file mode 100644 index 0000000..4b64bd4 --- /dev/null +++ b/app/Kernel/Middleware/DebugLogMiddleware.php @@ -0,0 +1,38 @@ +idGenerator = $idGenerator; + } + + public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface + { + Context::getOrSet(AppendRequestIdProcessor::REQUEST_ID, $this->idGenerator->generate()); + return $handler->handle($request); + } +} diff --git a/app/Middleware/TokenMiddleware.php b/app/Middleware/TokenMiddleware.php new file mode 100644 index 0000000..8a56fe7 --- /dev/null +++ b/app/Middleware/TokenMiddleware.php @@ -0,0 +1,15 @@ +=7.3", + "php": ">=7.4", + "daodao97/apidog": "^1.5", "hyperf/cache": "~2.2.0", "hyperf/command": "~2.2.0", "hyperf/config": "~2.2.0", + "hyperf/constants": "~2.2.0", + "hyperf/crontab": "^2.2", + "hyperf/database": "~2.2.0", "hyperf/db-connection": "~2.2.0", "hyperf/framework": "~2.2.0", "hyperf/guzzle": "~2.2.0", @@ -23,9 +27,9 @@ "hyperf/logger": "~2.2.0", "hyperf/memory": "~2.2.0", "hyperf/process": "~2.2.0", - "hyperf/database": "~2.2.0", "hyperf/redis": "~2.2.0", - "hyperf/constants": "~2.2.0" + "hyperf/snowflake": "^2.2", + "hyperf/task": "^2.2" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.0", diff --git a/composer.lock b/composer.lock index 5d2757f..6b87342 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,67 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b9c38c27754cada82ad67b6d2f84fa5a", + "content-hash": "ea513485f1154a0ce02e7c99756ecc4f", "packages": [ + { + "name": "daodao97/apidog", + "version": "1.5.17", + "source": { + "type": "git", + "url": "https://github.com/daodao97/apidog.git", + "reference": "f2c9f7bf6b96665dd19de6685fabe96a66099317" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/daodao97/apidog/zipball/f2c9f7bf6b96665dd19de6685fabe96a66099317", + "reference": "f2c9f7bf6b96665dd19de6685fabe96a66099317", + "shasum": "" + }, + "require": { + "ext-json": "*", + "hyperf/command": "^2.0.0", + "hyperf/http-server": "^2.0.0", + "hyperf/logger": "^2.0.0", + "hyperf/validation": "^2.0.0", + "php": ">=7.2" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.17", + "mockery/mockery": "^1.0", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": ">=8.5" + }, + "type": "library", + "extra": { + "hyperf": { + "config": "Hyperf\\Apidog\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Apidog\\": "src/" + }, + "files": [ + "./src/function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A swagger library for Hyperf.", + "keywords": [ + "hyperf", + "php", + "swagger", + "swoole" + ], + "support": { + "issues": "https://github.com/daodao97/apidog/issues", + "source": "https://github.com/daodao97/apidog/tree/1.5.17" + }, + "time": "2021-08-29T06:42:21+00:00" + }, { "name": "doctrine/annotations", "version": "1.13.2", @@ -322,6 +381,74 @@ ], "time": "2020-05-25T17:44:05+00:00" }, + { + "name": "egulias/email-validator", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/egulias/EmailValidator.git", + "reference": "c81f18a3efb941d8c4d2e025f6183b5c6d697307" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/c81f18a3efb941d8c4d2e025f6183b5c6d697307", + "reference": "c81f18a3efb941d8c4d2e025f6183b5c6d697307", + "shasum": "" + }, + "require": { + "doctrine/lexer": "^1.2", + "php": ">=7.2", + "symfony/polyfill-intl-idn": "^1.15" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.2", + "phpunit/phpunit": "^8.5.8|^9.3.3", + "vimeo/psalm": "^4" + }, + "suggest": { + "ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Egulias\\EmailValidator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eduardo Gulias Davis" + } + ], + "description": "A library for validating emails against several RFCs", + "homepage": "https://github.com/egulias/EmailValidator", + "keywords": [ + "email", + "emailvalidation", + "emailvalidator", + "validation", + "validator" + ], + "support": { + "issues": "https://github.com/egulias/EmailValidator/issues", + "source": "https://github.com/egulias/EmailValidator/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/egulias", + "type": "github" + } + ], + "time": "2021-04-01T18:37:14+00:00" + }, { "name": "fig/http-message-util", "version": "1.1.5", @@ -952,6 +1079,59 @@ }, "time": "2021-07-18T06:50:14+00:00" }, + { + "name": "hyperf/crontab", + "version": "v2.2.5", + "source": { + "type": "git", + "url": "https://github.com/hyperf/crontab.git", + "reference": "f91d9a773faf403797a009552f439b7edf28c6e9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/crontab/zipball/f91d9a773faf403797a009552f439b7edf28c6e9", + "reference": "f91d9a773faf403797a009552f439b7edf28c6e9", + "shasum": "" + }, + "require": { + "hyperf/utils": "~2.2.0", + "nesbot/carbon": "^2.0", + "php": ">=7.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Crontab\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Crontab\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A crontab component for Hyperf.", + "homepage": "https://hyperf.io", + "keywords": [ + "crontab", + "hyperf", + "php", + "swoole" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-08-19T02:21:00+00:00" + }, { "name": "hyperf/database", "version": "v2.2.5", @@ -1984,61 +2164,51 @@ "time": "2021-07-18T06:50:14+00:00" }, { - "name": "hyperf/utils", - "version": "v2.2.5", + "name": "hyperf/snowflake", + "version": "v2.2.0", "source": { "type": "git", - "url": "https://github.com/hyperf/utils.git", - "reference": "bff47ad92d5d85cd6b941d9766c8a251d1648860" + "url": "https://github.com/hyperf/snowflake.git", + "reference": "f1e28b6d9557c4323da1cd4d579ae2c467151c2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hyperf/utils/zipball/bff47ad92d5d85cd6b941d9766c8a251d1648860", - "reference": "bff47ad92d5d85cd6b941d9766c8a251d1648860", + "url": "https://api.github.com/repos/hyperf/snowflake/zipball/f1e28b6d9557c4323da1cd4d579ae2c467151c2d", + "reference": "f1e28b6d9557c4323da1cd4d579ae2c467151c2d", "shasum": "" }, "require": { - "doctrine/inflector": "^2.0", "hyperf/contract": "~2.2.0", - "hyperf/engine": "^1.1", "php": ">=7.2" }, "suggest": { - "ext-swoole": "Required to use methods related to swoole (>=4.5).", - "hyperf/di": "Required to use ExceptionNormalizer", - "nikic/php-parser": "Required to use PhpParser. (^4.0)", - "symfony/property-access": "Required to use SymfonyNormalizer (^5.0)", - "symfony/serializer": "Required to use SymfonyNormalizer (^5.0)", - "symfony/var-dumper": "Required to use the dd function (^5.0)." + "hyperf/config": "Required to read snowflake config.", + "hyperf/redis": "Required to use RedisMilliSecondMetaGenerator or RedisSecondMetaGenerator.", + "psr/container": "Required to use MetaGeneratorFactory." }, "type": "library", "extra": { - "hyperf": { - "config": "Hyperf\\Utils\\ConfigProvider" - }, "branch-alias": { "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Snowflake\\ConfigProvider" } }, "autoload": { - "files": [ - "src/Functions.php" - ], "psr-4": { - "Hyperf\\Utils\\": "src/" + "Hyperf\\Snowflake\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "description": "A tools package that could help developer solved the problem quickly.", + "description": "A snowflake library", "homepage": "https://hyperf.io", "keywords": [ - "hyperf", "php", - "swoole", - "utils" + "snowflake" ], "support": { "docs": "https://hyperf.wiki", @@ -2046,112 +2216,349 @@ "pull-request": "https://github.com/hyperf/hyperf/pulls", "source": "https://github.com/hyperf/hyperf" }, - "time": "2021-08-18T08:28:09+00:00" + "time": "2021-07-18T06:50:14+00:00" }, { - "name": "laminas/laminas-mime", - "version": "2.8.0", + "name": "hyperf/task", + "version": "v2.2.0", "source": { "type": "git", - "url": "https://github.com/laminas/laminas-mime.git", - "reference": "9a59704f33106427a384d0ae421f96043174093a" + "url": "https://github.com/hyperf/task.git", + "reference": "a0051419182d47bc7d3201639494aac62397930b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-mime/zipball/9a59704f33106427a384d0ae421f96043174093a", - "reference": "9a59704f33106427a384d0ae421f96043174093a", + "url": "https://api.github.com/repos/hyperf/task/zipball/a0051419182d47bc7d3201639494aac62397930b", + "reference": "a0051419182d47bc7d3201639494aac62397930b", "shasum": "" }, "require": { - "laminas/laminas-stdlib": "^2.7 || ^3.0", - "laminas/laminas-zendframework-bridge": "^1.0", - "php": "^7.3 || ~8.0.0" - }, - "replace": { - "zendframework/zend-mime": "^2.7.2" - }, - "require-dev": { - "laminas/laminas-coding-standard": "~1.0.0", - "laminas/laminas-mail": "^2.6", - "phpunit/phpunit": "^9.3" + "hyperf/contract": "~2.2.0", + "hyperf/framework": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2", + "psr/container": "^1.0|^2.0", + "psr/event-dispatcher": "^1.0", + "psr/log": "^1.0", + "symfony/property-access": "^5.0", + "symfony/serializer": "^5.0" }, "suggest": { - "laminas/laminas-mail": "Laminas\\Mail component" + "hyperf/di": "Required to use annotation." }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Task\\ConfigProvider" + } + }, "autoload": { "psr-4": { - "Laminas\\Mime\\": "src/" + "Hyperf\\Task\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], - "description": "Create and parse MIME messages and parts", - "homepage": "https://laminas.dev", + "description": "A task library for Hyperf.", + "homepage": "https://hyperf.io", "keywords": [ - "laminas", - "mime" + "hyperf", + "php", + "swoole", + "task" ], "support": { - "chat": "https://laminas.dev/chat", - "docs": "https://docs.laminas.dev/laminas-mime/", - "forum": "https://discourse.laminas.dev", - "issues": "https://github.com/laminas/laminas-mime/issues", - "rss": "https://github.com/laminas/laminas-mime/releases.atom", - "source": "https://github.com/laminas/laminas-mime" + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" }, - "funding": [ - { - "url": "https://funding.communitybridge.org/projects/laminas-project", - "type": "community_bridge" - } - ], - "time": "2021-02-16T17:40:06+00:00" + "time": "2021-07-18T06:50:14+00:00" }, { - "name": "laminas/laminas-stdlib", - "version": "3.5.0", + "name": "hyperf/translation", + "version": "v2.2.5", "source": { "type": "git", - "url": "https://github.com/laminas/laminas-stdlib.git", - "reference": "c8ac6a76a133e682acfabc821d4a2ec646934b12" + "url": "https://github.com/hyperf/translation.git", + "reference": "1e9cff0d8b4b3fcfc06c1adec1927125db9c06a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/c8ac6a76a133e682acfabc821d4a2ec646934b12", - "reference": "c8ac6a76a133e682acfabc821d4a2ec646934b12", + "url": "https://api.github.com/repos/hyperf/translation/zipball/1e9cff0d8b4b3fcfc06c1adec1927125db9c06a8", + "reference": "1e9cff0d8b4b3fcfc06c1adec1927125db9c06a8", "shasum": "" }, "require": { - "php": "^7.3 || ^8.0" - }, - "conflict": { - "zendframework/zend-stdlib": "*" - }, - "require-dev": { - "laminas/laminas-coding-standard": "~2.3.0", - "phpbench/phpbench": "^0.17.1", - "phpunit/phpunit": "~9.3.7", - "psalm/plugin-phpunit": "^0.16.0", - "vimeo/psalm": "^4.7" + "hyperf/contract": "~2.2.0", + "hyperf/utils": "~2.2.0", + "php": ">=7.2", + "psr/container": "^1.0|^2.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Translation\\ConfigProvider" + } + }, "autoload": { + "files": [ + "src/Functions.php" + ], "psr-4": { - "Laminas\\Stdlib\\": "src/" + "Hyperf\\Translation\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], - "description": "SPL extensions, array utilities, error handlers, and more", - "homepage": "https://laminas.dev", + "description": "An independent translation component, forked by illuminate/translation.", "keywords": [ - "laminas", - "stdlib" + "hyperf", + "translation" + ], + "support": { + "issues": "https://github.com/hyperf/translation/issues", + "source": "https://github.com/hyperf/translation/tree/v2.2.5" + }, + "time": "2021-08-23T03:09:11+00:00" + }, + { + "name": "hyperf/utils", + "version": "v2.2.5", + "source": { + "type": "git", + "url": "https://github.com/hyperf/utils.git", + "reference": "bff47ad92d5d85cd6b941d9766c8a251d1648860" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/utils/zipball/bff47ad92d5d85cd6b941d9766c8a251d1648860", + "reference": "bff47ad92d5d85cd6b941d9766c8a251d1648860", + "shasum": "" + }, + "require": { + "doctrine/inflector": "^2.0", + "hyperf/contract": "~2.2.0", + "hyperf/engine": "^1.1", + "php": ">=7.2" + }, + "suggest": { + "ext-swoole": "Required to use methods related to swoole (>=4.5).", + "hyperf/di": "Required to use ExceptionNormalizer", + "nikic/php-parser": "Required to use PhpParser. (^4.0)", + "symfony/property-access": "Required to use SymfonyNormalizer (^5.0)", + "symfony/serializer": "Required to use SymfonyNormalizer (^5.0)", + "symfony/var-dumper": "Required to use the dd function (^5.0)." + }, + "type": "library", + "extra": { + "hyperf": { + "config": "Hyperf\\Utils\\ConfigProvider" + }, + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "autoload": { + "files": [ + "src/Functions.php" + ], + "psr-4": { + "Hyperf\\Utils\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A tools package that could help developer solved the problem quickly.", + "homepage": "https://hyperf.io", + "keywords": [ + "hyperf", + "php", + "swoole", + "utils" + ], + "support": { + "docs": "https://hyperf.wiki", + "issues": "https://github.com/hyperf/hyperf/issues", + "pull-request": "https://github.com/hyperf/hyperf/pulls", + "source": "https://github.com/hyperf/hyperf" + }, + "time": "2021-08-18T08:28:09+00:00" + }, + { + "name": "hyperf/validation", + "version": "v2.2.6", + "source": { + "type": "git", + "url": "https://github.com/hyperf/validation.git", + "reference": "f746675a832844a037e1ab4980c48d535717be5f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hyperf/validation/zipball/f746675a832844a037e1ab4980c48d535717be5f", + "reference": "f746675a832844a037e1ab4980c48d535717be5f", + "shasum": "" + }, + "require": { + "egulias/email-validator": "^3.0", + "hyperf/contract": "~2.2.0", + "hyperf/database": "~2.2.0", + "hyperf/di": "~2.2.0", + "hyperf/framework": "~2.2.0", + "hyperf/http-server": "~2.2.0", + "hyperf/translation": "~2.2.0", + "hyperf/utils": "~2.2.0", + "nesbot/carbon": "^2.21", + "php": ">=7.2", + "psr/container": "^1.0|^2.0", + "psr/event-dispatcher": "^1.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "hyperf": { + "config": "Hyperf\\Validation\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Hyperf\\Validation\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "hyperf validation", + "keywords": [ + "hyperf", + "validation" + ], + "support": { + "issues": "https://github.com/hyperf/validation/issues", + "source": "https://github.com/hyperf/validation/tree/v2.2.6" + }, + "time": "2021-08-23T07:38:19+00:00" + }, + { + "name": "laminas/laminas-mime", + "version": "2.8.0", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-mime.git", + "reference": "9a59704f33106427a384d0ae421f96043174093a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-mime/zipball/9a59704f33106427a384d0ae421f96043174093a", + "reference": "9a59704f33106427a384d0ae421f96043174093a", + "shasum": "" + }, + "require": { + "laminas/laminas-stdlib": "^2.7 || ^3.0", + "laminas/laminas-zendframework-bridge": "^1.0", + "php": "^7.3 || ~8.0.0" + }, + "replace": { + "zendframework/zend-mime": "^2.7.2" + }, + "require-dev": { + "laminas/laminas-coding-standard": "~1.0.0", + "laminas/laminas-mail": "^2.6", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "laminas/laminas-mail": "Laminas\\Mail component" + }, + "type": "library", + "autoload": { + "psr-4": { + "Laminas\\Mime\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Create and parse MIME messages and parts", + "homepage": "https://laminas.dev", + "keywords": [ + "laminas", + "mime" + ], + "support": { + "chat": "https://laminas.dev/chat", + "docs": "https://docs.laminas.dev/laminas-mime/", + "forum": "https://discourse.laminas.dev", + "issues": "https://github.com/laminas/laminas-mime/issues", + "rss": "https://github.com/laminas/laminas-mime/releases.atom", + "source": "https://github.com/laminas/laminas-mime" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2021-02-16T17:40:06+00:00" + }, + { + "name": "laminas/laminas-stdlib", + "version": "3.5.0", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-stdlib.git", + "reference": "c8ac6a76a133e682acfabc821d4a2ec646934b12" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/c8ac6a76a133e682acfabc821d4a2ec646934b12", + "reference": "c8ac6a76a133e682acfabc821d4a2ec646934b12", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "conflict": { + "zendframework/zend-stdlib": "*" + }, + "require-dev": { + "laminas/laminas-coding-standard": "~2.3.0", + "phpbench/phpbench": "^0.17.1", + "phpunit/phpunit": "~9.3.7", + "psalm/plugin-phpunit": "^0.16.0", + "vimeo/psalm": "^4.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Laminas\\Stdlib\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "SPL extensions, array utilities, error handlers, and more", + "homepage": "https://laminas.dev", + "keywords": [ + "laminas", + "stdlib" ], "support": { "chat": "https://laminas.dev/chat", @@ -3595,28 +4002,431 @@ "type": "tidelift" } ], - "time": "2021-05-27T12:26:48+00:00" + "time": "2021-05-27T12:26:48+00:00" + }, + { + "name": "symfony/polyfill-intl-idn", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-idn.git", + "reference": "65bd267525e82759e7d8c4e8ceea44f398838e65" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/65bd267525e82759e7d8c4e8ceea44f398838e65", + "reference": "65bd267525e82759e7d8c4e8ceea44f398838e65", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "symfony/polyfill-intl-normalizer": "^1.10", + "symfony/polyfill-php72": "^1.10" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Idn\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Laurent Bassin", + "email": "laurent@bassin.info" + }, + { + "name": "Trevor Rowbotham", + "email": "trevor.rowbotham@pm.me" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "idn", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-27T09:27:20+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-27T12:26:48+00:00" + }, + { + "name": "symfony/polyfill-php72", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "9a142215a36a3888e30d0a9eeea9766764e96976" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9a142215a36a3888e30d0a9eeea9766764e96976", + "reference": "9a142215a36a3888e30d0a9eeea9766764e96976", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php72/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-27T09:17:38+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010", + "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" }, { - "name": "symfony/polyfill-intl-normalizer", - "version": "v1.23.0", + "name": "symfony/polyfill-php80", + "version": "v1.23.1", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8" + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8", - "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", "shasum": "" }, "require": { "php": ">=7.1" }, - "suggest": { - "ext-intl": "For best performance" - }, "type": "library", "extra": { "branch-alias": { @@ -3629,7 +4439,7 @@ }, "autoload": { "psr-4": { - "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + "Symfony\\Polyfill\\Php80\\": "" }, "files": [ "bootstrap.php" @@ -3643,6 +4453,10 @@ "MIT" ], "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, { "name": "Nicolas Grekas", "email": "p@tchwork.com" @@ -3652,18 +4466,16 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill for intl's Normalizer class and related functions", + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", - "intl", - "normalizer", "polyfill", "portable", "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" }, "funding": [ { @@ -3679,44 +4491,41 @@ "type": "tidelift" } ], - "time": "2021-02-19T12:13:01+00:00" + "time": "2021-07-28T13:41:28+00:00" }, { - "name": "symfony/polyfill-mbstring", - "version": "v1.23.1", + "name": "symfony/property-access", + "version": "v5.3.7", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" + "url": "https://github.com/symfony/property-access.git", + "reference": "a4bbf09b8f3e2d2c89cc2c8b3d6682bf4c3d5589" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", - "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", + "url": "https://api.github.com/repos/symfony/property-access/zipball/a4bbf09b8f3e2d2c89cc2c8b3d6682bf4c3d5589", + "reference": "a4bbf09b8f3e2d2c89cc2c8b3d6682bf4c3d5589", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-php80": "^1.16", + "symfony/property-info": "^5.2" + }, + "require-dev": { + "symfony/cache": "^4.4|^5.0" }, "suggest": { - "ext-mbstring": "For best performance" + "psr/cache-implementation": "To cache access methods." }, "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, "autoload": { "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" + "Symfony\\Component\\PropertyAccess\\": "" }, - "files": [ - "bootstrap.php" + "exclude-from-classmap": [ + "/Tests/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -3725,25 +4534,29 @@ ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill for the Mbstring extension", + "description": "Provides functions to read and write from/to an object or array using a simple string notation", "homepage": "https://symfony.com", "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" + "access", + "array", + "extraction", + "index", + "injection", + "object", + "property", + "property path", + "reflection" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" + "source": "https://github.com/symfony/property-access/tree/v5.3.7" }, "funding": [ { @@ -3759,44 +4572,53 @@ "type": "tidelift" } ], - "time": "2021-05-27T12:26:48+00:00" + "time": "2021-08-09T12:23:10+00:00" }, { - "name": "symfony/polyfill-php73", - "version": "v1.23.0", + "name": "symfony/property-info", + "version": "v5.3.7", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010" + "url": "https://github.com/symfony/property-info.git", + "reference": "7202b6c93a07df5df83eb58e3757dffb77fc5d90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010", - "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010", + "url": "https://api.github.com/repos/symfony/property-info/zipball/7202b6c93a07df5df83eb58e3757dffb77fc5d90", + "reference": "7202b6c93a07df5df83eb58e3757dffb77fc5d90", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-php80": "^1.16", + "symfony/string": "^5.1" }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } + "conflict": { + "phpdocumentor/reflection-docblock": "<3.2.2", + "phpdocumentor/type-resolver": "<1.4.0", + "symfony/dependency-injection": "<4.4" }, + "require-dev": { + "doctrine/annotations": "^1.10.4", + "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", + "symfony/cache": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/serializer": "^4.4|^5.0" + }, + "suggest": { + "phpdocumentor/reflection-docblock": "To use the PHPDoc", + "psr/cache-implementation": "To cache results", + "symfony/doctrine-bridge": "To use Doctrine metadata", + "symfony/serializer": "To use Serializer metadata" + }, + "type": "library", "autoload": { "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" + "Symfony\\Component\\PropertyInfo\\": "" }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" + "exclude-from-classmap": [ + "/Tests/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -3805,24 +4627,26 @@ ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" + "name": "Kévin Dunglas", + "email": "dunglas@gmail.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "description": "Extracts information about PHP class' properties using metadata of popular sources", "homepage": "https://symfony.com", "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" + "doctrine", + "phpdoc", + "property", + "symfony", + "type", + "validator" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.23.0" + "source": "https://github.com/symfony/property-info/tree/v5.3.7" }, "funding": [ { @@ -3838,44 +4662,73 @@ "type": "tidelift" } ], - "time": "2021-02-19T12:13:01+00:00" + "time": "2021-08-23T12:57:24+00:00" }, { - "name": "symfony/polyfill-php80", - "version": "v1.23.1", + "name": "symfony/serializer", + "version": "v5.3.4", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" + "url": "https://github.com/symfony/serializer.git", + "reference": "f04e368e3cb35948550c7e95cc8918cb7e761c0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", - "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", + "url": "https://api.github.com/repos/symfony/serializer/zipball/f04e368e3cb35948550c7e95cc8918cb7e761c0c", + "reference": "f04e368e3cb35948550c7e95cc8918cb7e761c0c", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.16" }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } + "conflict": { + "doctrine/annotations": "<1.12", + "phpdocumentor/reflection-docblock": "<3.2.2", + "phpdocumentor/type-resolver": "<1.4.0", + "symfony/dependency-injection": "<4.4", + "symfony/property-access": "<4.4", + "symfony/property-info": "<5.3", + "symfony/yaml": "<4.4" }, + "require-dev": { + "doctrine/annotations": "^1.12", + "phpdocumentor/reflection-docblock": "^3.2|^4.0|^5.0", + "symfony/cache": "^4.4|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/error-handler": "^4.4|^5.0", + "symfony/filesystem": "^4.4|^5.0", + "symfony/form": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", + "symfony/mime": "^4.4|^5.0", + "symfony/property-access": "^4.4.9|^5.0.9", + "symfony/property-info": "^5.3", + "symfony/uid": "^5.1", + "symfony/validator": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0", + "symfony/var-exporter": "^4.4|^5.0", + "symfony/yaml": "^4.4|^5.0" + }, + "suggest": { + "psr/cache-implementation": "For using the metadata cache.", + "symfony/config": "For using the XML mapping loader.", + "symfony/mime": "For using a MIME type guesser within the DataUriNormalizer.", + "symfony/property-access": "For using the ObjectNormalizer.", + "symfony/property-info": "To deserialize relations.", + "symfony/var-exporter": "For using the metadata compiler.", + "symfony/yaml": "For using the default YAML mapping loader." + }, + "type": "library", "autoload": { "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" + "Symfony\\Component\\Serializer\\": "" }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" + "exclude-from-classmap": [ + "/Tests/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -3884,28 +4737,18 @@ ], "authors": [ { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "description": "Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.", "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" + "source": "https://github.com/symfony/serializer/tree/v5.3.4" }, "funding": [ { @@ -3921,7 +4764,7 @@ "type": "tidelift" } ], - "time": "2021-07-28T13:41:28+00:00" + "time": "2021-07-21T13:18:10+00:00" }, { "name": "symfony/service-contracts", @@ -5274,16 +6117,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.96", + "version": "0.12.97", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "a98bdc51318f20fcae8c953d266f81a70254917f" + "reference": "a8867e63a00e606589faf8d3613164f20722c4ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/a98bdc51318f20fcae8c953d266f81a70254917f", - "reference": "a98bdc51318f20fcae8c953d266f81a70254917f", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/a8867e63a00e606589faf8d3613164f20722c4ee", + "reference": "a8867e63a00e606589faf8d3613164f20722c4ee", "shasum": "" }, "require": { @@ -5314,7 +6157,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.96" + "source": "https://github.com/phpstan/phpstan/tree/0.12.97" }, "funding": [ { @@ -5334,7 +6177,7 @@ "type": "tidelift" } ], - "time": "2021-08-21T11:55:13+00:00" + "time": "2021-09-01T10:51:52+00:00" }, { "name": "phpunit/php-code-coverage", @@ -7065,82 +7908,6 @@ ], "time": "2021-08-04T21:20:46+00:00" }, - { - "name": "symfony/polyfill-php72", - "version": "v1.23.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "9a142215a36a3888e30d0a9eeea9766764e96976" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9a142215a36a3888e30d0a9eeea9766764e96976", - "reference": "9a142215a36a3888e30d0a9eeea9766764e96976", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php72\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.23.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-05-27T09:17:38+00:00" - }, { "name": "symfony/polyfill-php81", "version": "v1.23.0", diff --git a/config/autoload/annotations.php b/config/autoload/annotations.php index 1423a25..a287014 100644 --- a/config/autoload/annotations.php +++ b/config/autoload/annotations.php @@ -11,11 +11,14 @@ */ return [ 'scan' => [ - 'paths' => [ + 'paths' => [ BASE_PATH . '/app', ], 'ignore_annotations' => [ 'mixin', ], + 'class_map' => [ + \Hyperf\Utils\Coroutine::class => BASE_PATH . '/app/Kernel/ClassMap/Coroutine.php' + ], ], ]; diff --git a/config/autoload/cache.php b/config/autoload/cache.php index def82eb..015ba0d 100644 --- a/config/autoload/cache.php +++ b/config/autoload/cache.php @@ -13,6 +13,6 @@ 'default' => [ 'driver' => Hyperf\Cache\Driver\RedisDriver::class, 'packer' => Hyperf\Utils\Packer\PhpSerializerPacker::class, - 'prefix' => 'c:', + 'prefix' => 'hyperf-advanced:', ], ]; diff --git a/config/autoload/databases.php b/config/autoload/databases.php index 4deb286..d3453ed 100644 --- a/config/autoload/databases.php +++ b/config/autoload/databases.php @@ -12,17 +12,22 @@ return [ 'default' => [ 'driver' => env('DB_DRIVER', 'mysql'), - 'host' => env('DB_HOST', 'localhost'), + 'read' => [ + 'host' => env('DB_READ_HOST', '127.0.0.1'), + ], + 'write' => [ + 'host' => env('DB_WRITE_HOST', '127.0.0.1'), + ], 'database' => env('DB_DATABASE', 'hyperf'), 'port' => env('DB_PORT', 3306), 'username' => env('DB_USERNAME', 'root'), 'password' => env('DB_PASSWORD', ''), - 'charset' => env('DB_CHARSET', 'utf8'), - 'collation' => env('DB_COLLATION', 'utf8_unicode_ci'), - 'prefix' => env('DB_PREFIX', ''), + 'charset' => env('DB_CHARSET', 'utf8mb4'), + 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), + 'prefix' => env('DB_PREFIX', 't_'), 'pool' => [ 'min_connections' => 1, - 'max_connections' => 10, + 'max_connections' => 50, 'connect_timeout' => 10.0, 'wait_timeout' => 3.0, 'heartbeat' => -1, @@ -33,7 +38,7 @@ 'path' => 'app/Model', 'force_casts' => true, 'inheritance' => 'BaseModel', - 'uses' => 'Lengbin\Hyperf\Common\Framework\BaseModel', + 'uses' => \App\Kernel\BaseModel::class, 'refresh_fillable' => true, 'with_comments' => true, ], diff --git a/config/autoload/dependencies.php b/config/autoload/dependencies.php index f46bd96..ec7d61a 100644 --- a/config/autoload/dependencies.php +++ b/config/autoload/dependencies.php @@ -1,6 +1,7 @@ allFiles($path); + if (!$scans) { + return []; + } + $data = []; + foreach ($scans as $scan) { + $file = substr($scan->getRealPath(), 0, -4); + $interface = implode('\\', array_map(function ($str) { + return ucfirst($str); + }, explode('/', str_replace(BASE_PATH, '', $file)))); + $interface = substr($interface, 1); + $impl = str_replace('Contracts', 'MySQL', $interface); + $impl = str_replace('Interface', '', $impl); + if (interface_exists($interface) && class_exists($impl)) { + $data[$interface] = $impl; + } + } + return $data; +}); + +return array_merge($daoInterface, [ + //ResponseInterface::class => Response::class, + //Hyperf\HttpServer\Response::class => Response::class, + //ErrorCode::class => App\Constants\ErrorCode::class, + StdoutLoggerInterface::class => LoggerFactory::class, + Hyperf\Database\Commands\ModelCommand::class => App\Kernel\Commands\Model\ModelCommand::class, +]); diff --git a/config/autoload/exceptions.php b/config/autoload/exceptions.php index b848177..dc6f7ef 100644 --- a/config/autoload/exceptions.php +++ b/config/autoload/exceptions.php @@ -13,7 +13,7 @@ 'handler' => [ 'http' => [ Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler::class, - App\Exception\Handler\AppExceptionHandler::class, + App\Kernel\Exceptions\Handler\AppExceptionHandler::class, ], ], ]; diff --git a/config/autoload/listeners.php b/config/autoload/listeners.php index f46bd96..dd869da 100644 --- a/config/autoload/listeners.php +++ b/config/autoload/listeners.php @@ -9,5 +9,9 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + +use App\Listener\DbQueryExecutedListener; + return [ + DbQueryExecutedListener::class ]; diff --git a/config/autoload/logger.php b/config/autoload/logger.php index 5341811..53a263c 100644 --- a/config/autoload/logger.php +++ b/config/autoload/logger.php @@ -9,22 +9,30 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + +use App\Kernel\Log\AppendRequestIdProcessor; + return [ 'default' => [ - 'handler' => [ - 'class' => Monolog\Handler\StreamHandler::class, + 'handler' => [ + 'class' => Monolog\Handler\StreamHandler::class, 'constructor' => [ - 'stream' => BASE_PATH . '/runtime/logs/hyperf.log', - 'level' => Monolog\Logger::DEBUG, + 'stream' => 'php://stdout', + 'level' => intval(env('LOG_LEVEL', Monolog\Logger::DEBUG)), ], ], - 'formatter' => [ - 'class' => Monolog\Formatter\LineFormatter::class, + 'formatter' => [ + 'class' => Monolog\Formatter\LineFormatter::class, 'constructor' => [ - 'format' => null, - 'dateFormat' => null, + 'format' => null, + 'dateFormat' => 'Y-m-d H:i:s', 'allowInlineLineBreaks' => true, ], ], + 'processors' => [ + [ + 'class' => AppendRequestIdProcessor::class, + ] + ], ], ]; diff --git a/config/autoload/middlewares.php b/config/autoload/middlewares.php index 77286ee..cfb801c 100644 --- a/config/autoload/middlewares.php +++ b/config/autoload/middlewares.php @@ -10,10 +10,16 @@ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ -use Lengbin\Hyperf\Common\Middleware\CorsMiddleware; +use App\Kernel\Middleware\CorsMiddleware; +use App\Kernel\Middleware\DebugLogMiddleware; +use App\Middleware\TokenMiddleware; +use Hyperf\Apidog\Middleware\ApiValidationMiddleware; return [ 'http' => [ CorsMiddleware::class, + DebugLogMiddleware::class, +// TokenMiddleware::class, + ApiValidationMiddleware::class, ], ]; diff --git a/config/autoload/processes.php b/config/autoload/processes.php index f46bd96..7a70b57 100644 --- a/config/autoload/processes.php +++ b/config/autoload/processes.php @@ -9,5 +9,9 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + +use Hyperf\Crontab\Process\CrontabDispatcherProcess; + return [ + CrontabDispatcherProcess::class, ]; diff --git a/config/autoload/redis.php b/config/autoload/redis.php index 3180b62..e575baf 100644 --- a/config/autoload/redis.php +++ b/config/autoload/redis.php @@ -5,7 +5,7 @@ * This file is part of Hyperf. * * @link https://www.hyperf.io - * @document https://hyperf.wiki + * @document https://doc.hyperf.io * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ @@ -15,6 +15,21 @@ 'auth' => env('REDIS_AUTH', null), 'port' => (int) env('REDIS_PORT', 6379), 'db' => (int) env('REDIS_DB', 0), + 'pool' => [ + 'min_connections' => 10, + 'max_connections' => 60, + 'connect_timeout' => 10.0, + 'wait_timeout' => 3.0, + 'heartbeat' => -1, + 'max_idle_time' => (float) env('REDIS_MAX_IDLE_TIME', 60), + ], + ], + + 'online' => [ + 'host' => env('REDIS_ONLINE_HOST', 'localhost'), + 'auth' => env('REDIS_ONLINE_AUTH', null), + 'port' => (int) env('REDIS_PORT', 6379), + 'db' => (int) env('REDIS_DB', 0), 'pool' => [ 'min_connections' => 1, 'max_connections' => 10, diff --git a/config/autoload/server.php b/config/autoload/server.php index 56f6afb..629cd01 100644 --- a/config/autoload/server.php +++ b/config/autoload/server.php @@ -1,6 +1,7 @@ SWOOLE_PROCESS, - 'servers' => [ + 'mode' => SWOOLE_PROCESS, + 'servers' => [ [ - 'name' => 'http', - 'type' => Server::SERVER_HTTP, - 'host' => '0.0.0.0', - 'port' => 9501, + 'name' => 'http', + 'type' => Server::SERVER_HTTP, + 'host' => '0.0.0.0', + 'port' => intval(env('HTTP_PORT', 9501)), 'sock_type' => SWOOLE_SOCK_TCP, 'callbacks' => [ Event::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'], ], ], ], - 'settings' => [ - Constant::OPTION_ENABLE_COROUTINE => true, - Constant::OPTION_WORKER_NUM => swoole_cpu_num(), - Constant::OPTION_PID_FILE => BASE_PATH . '/runtime/hyperf.pid', - Constant::OPTION_OPEN_TCP_NODELAY => true, - Constant::OPTION_MAX_COROUTINE => 100000, - Constant::OPTION_OPEN_HTTP2_PROTOCOL => true, - Constant::OPTION_MAX_REQUEST => 100000, - Constant::OPTION_SOCKET_BUFFER_SIZE => 2 * 1024 * 1024, - Constant::OPTION_BUFFER_OUTPUT_SIZE => 2 * 1024 * 1024, + 'settings' => [ + Constant::OPTION_ENABLE_COROUTINE => true, + Constant::OPTION_WORKER_NUM => intval(env('WORKER_NUM', swoole_cpu_num())), + Constant::OPTION_TASK_ENABLE_COROUTINE => false, + Constant::OPTION_TASK_WORKER_NUM => intval(env('TASK_WORKER_NUM', swoole_cpu_num() * 16)), + Constant::OPTION_PID_FILE => BASE_PATH . '/runtime/hyperf.pid', + Constant::OPTION_OPEN_TCP_NODELAY => true, + Constant::OPTION_MAX_COROUTINE => 100000, + Constant::OPTION_OPEN_HTTP2_PROTOCOL => true, + Constant::OPTION_MAX_REQUEST => 100000, + Constant::OPTION_SOCKET_BUFFER_SIZE => 2 * 1024 * 1024, + Constant::OPTION_BUFFER_OUTPUT_SIZE => 2 * 1024 * 1024, + Constant::OPTION_DOCUMENT_ROOT => BASE_PATH . '/public', + Constant::OPTION_ENABLE_STATIC_HANDLER => true, ], 'callbacks' => [ Event::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'], Event::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'], - Event::ON_WORKER_EXIT => [Hyperf\Framework\Bootstrap\WorkerExitCallback::class, 'onWorkerExit'], + Event::ON_WORKER_EXIT => [Hyperf\Framework\Bootstrap\WorkerExitCallback::class, 'onWorkerExit'], + + Event::ON_TASK => [Hyperf\Framework\Bootstrap\TaskCallback::class, 'onTask'], + Event::ON_FINISH => [Hyperf\Framework\Bootstrap\FinishCallback::class, 'onFinish'], ], ]; diff --git a/config/autoload/snowflake.php b/config/autoload/snowflake.php new file mode 100644 index 0000000..d9230c9 --- /dev/null +++ b/config/autoload/snowflake.php @@ -0,0 +1,26 @@ + MetaGeneratorInterface::DEFAULT_BEGIN_SECOND, + RedisMilliSecondMetaGenerator::class => [ + 'pool' => 'default', + 'key' => RedisMilliSecondMetaGenerator::DEFAULT_REDIS_KEY + ], + RedisSecondMetaGenerator::class => [ + 'pool' => 'default', + 'key' => RedisMilliSecondMetaGenerator::DEFAULT_REDIS_KEY + ], +]; diff --git a/app/Model/Model.php b/config/autoload/translation.php similarity index 67% rename from app/Model/Model.php rename to config/autoload/translation.php index fe03061..35b9f06 100644 --- a/app/Model/Model.php +++ b/config/autoload/translation.php @@ -9,10 +9,8 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ -namespace App\Model; - -use Hyperf\DbConnection\Model\Model as BaseModel; - -abstract class Model extends BaseModel -{ -} +return [ + 'locale' => 'zh_CN', + 'fallback_locale' => 'en', + 'path' => BASE_PATH . '/storage/languages', +]; diff --git a/config/config.php b/config/config.php index 38823e0..4f6e4c4 100644 --- a/config/config.php +++ b/config/config.php @@ -28,4 +28,5 @@ LogLevel::WARNING, ], ], + 'host' => env('HOST', 'http://127.0.0.1:9501'), ]; diff --git a/config/routes.php b/config/routes.php index b3879ed..46d04e5 100644 --- a/config/routes.php +++ b/config/routes.php @@ -11,7 +11,7 @@ */ use Hyperf\HttpServer\Router\Router; -//Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@index'); +Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@index'); Router::get('/favicon.ico', function () { return ''; From ba49cb754031ad5ee6aa4b239293e8e6f3b9270b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Thu, 2 Sep 2021 23:57:25 +0800 Subject: [PATCH 77/82] base model --- app/Controller/IndexController.php | 1 - app/Kernel/BaseModel.php | 171 +++++++++++++++++++++++++++ app/Kernel/Constants/SoftDeleted.php | 29 +++++ composer.json | 1 + 4 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 app/Kernel/Constants/SoftDeleted.php diff --git a/app/Controller/IndexController.php b/app/Controller/IndexController.php index 87bcd0d..4b4cdb6 100644 --- a/app/Controller/IndexController.php +++ b/app/Controller/IndexController.php @@ -11,7 +11,6 @@ */ namespace App\Controller; -use App\Kernel\Context\Coroutine; use Hyperf\Contract\StdoutLoggerInterface; use Hyperf\Di\Annotation\Inject; diff --git a/app/Kernel/BaseModel.php b/app/Kernel/BaseModel.php index b0a5575..ff85ffb 100644 --- a/app/Kernel/BaseModel.php +++ b/app/Kernel/BaseModel.php @@ -9,9 +9,180 @@ namespace App\Kernel; +use App\Kernel\Constants\SoftDeleted; +use Hyperf\Database\Model\Builder; +use Hyperf\Database\Query\Expression; +use Hyperf\Database\Query\Grammars\Grammar; +use Hyperf\DbConnection\Db; use Hyperf\DbConnection\Model\Model; +use Hyperf\Utils\Arr; abstract class BaseModel extends Model { + const CREATED_AT = 'create_at'; + const UPDATED_AT = 'update_at'; + + protected $dateFormat = 'U'; + + /** + * 删除 + * @return bool + */ + public function disable() + { + $this->enable = SoftDeleted::DISABLE; + return $this->save(); + } + + /** + * @param mixed $value + * @return string + */ + public function fromDateTime($value) + { + return strval($this->asTimestamp($value)); + } + + public static function betweenTime(Builder $model, string $field, array $data) + { + $model->where(function (Builder $builder) use ($field, $data) { + if ($data['start'] > 0) { + $builder->where($field, '>=', $data['start']); + } + if ($data['end'] > 0) { + $builder->where($field, '<', $data['end']); + } + }); + } + + /** + * @param array $conditions + * @param array $field + * @param bool $forUpdate + * @return null|BaseModel|object|static + */ + public static function findOneCondition(array $conditions, $field = ['*'], $forUpdate = false): ?self + { + $model = self::query(); + + if (count($conditions) === count($conditions, 1)) { + foreach ($conditions as $key => $value) { + if (is_null($value)) { + continue; + } + if (is_array($value)) { + $model->whereIn($key, $value); + } else { + $model->where($key, $value); + } + } + } else { + $model->where($conditions); + } + + $model->where('enable', SoftDeleted::ENABLE); + if ($forUpdate) { + $model->lockForUpdate(); + } + return $model->first($field); + } + + /** + * @param array $conditions + * @param array $field + * @param bool $forUpdate + * @return \Hyperf\Database\Model\Collection|static[] + */ + public static function findCondition(array $conditions, $field = ['*'], $forUpdate = false) + { + $model = self::query(); + if (count($conditions) === count($conditions, 1)) { + foreach ($conditions as $key => $value) { + if (is_null($value)) { + continue; + } + if (is_array($value)) { + $model->whereIn($key, $value); + } else { + $model->where($key, $value); + } + } + } else { + $model->where($conditions); + } + $model->where('enable', SoftDeleted::ENABLE); + if ($forUpdate) { + $model->lockForUpdate(); + } + return $model->get($field); + } + + /** + * insert or update a record + * + * @param array $values + * @param array $column + * @return bool + */ + public static function insertOrUpdate(array $values, array $column) + { + if (empty($column)) { + $column = array_keys($values); + } + $value = []; + foreach ($column as $item) { + $value[$item] = Db::raw("values(`{$item}`)"); + } + $model = new static(); + $connection = $model->getConnection(); // 数据库连接 + $builder = $model->newQuery()->getQuery(); // 查询构造器 + $grammar = $builder->getGrammar(); // 语法器 + // 编译插入语句 + $insert = $grammar->compileInsert($builder, $values); + // 编译重复后更新列语句。 + $update = $model->compileUpdateColumns($grammar, $value); + // 构造查询语句 + $query = $insert . ' on duplicate key update ' . $update; + // 组装sql绑定参数 + $bindings = $model->prepareBindingsForInsertOrUpdate($values, $value); + // 执行数据库查询 + return $connection->insert($query, $bindings); + } + + /** + * Compile all of the columns for an update statement. + * + * @param Grammar $grammar + * @param array $values + * @return string + */ + private function compileUpdateColumns(Grammar $grammar, array $values) + { + return collect($values)->map(function ($value, $key) use ($grammar) { + return $grammar->wrap($key) . ' = ' . $grammar->parameter($value); + })->implode(', '); + } + + /** + * Prepare the bindings for an insert or update statement. + * + * @param array $values + * @param array $value + * @return array + */ + private function prepareBindingsForInsertOrUpdate(array $values, array $value) + { + // Merge array of bindings + $bindings = array_merge_recursive($values, [$value]); + // Remove all of the expressions from a list of bindings. + return array_values(array_filter(Arr::flatten($bindings, 1), function ($binding) { + return !$binding instanceof Expression; + })); + } + + protected function asJson($value) + { + return json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + } } diff --git a/app/Kernel/Constants/SoftDeleted.php b/app/Kernel/Constants/SoftDeleted.php new file mode 100644 index 0000000..8b4a0f5 --- /dev/null +++ b/app/Kernel/Constants/SoftDeleted.php @@ -0,0 +1,29 @@ +=7.4", + "ext-json": "*", "daodao97/apidog": "^1.5", "hyperf/cache": "~2.2.0", "hyperf/command": "~2.2.0", From 46a3dc33d6187958736a35a0b1354d6734bebb9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Fri, 3 Sep 2021 00:44:33 +0800 Subject: [PATCH 78/82] =?UTF-8?q?=E6=A0=B8=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.online | 2 +- Dockerfile | 125 +++++++++++++++++++------ app/Kernel/BaseObject.php | 15 +++ app/Kernel/Constants/BaseStatus.php | 29 ++++++ app/Kernel/Constants/WhetherStatus.php | 22 +++++ config/autoload/apidog.php | 2 +- 6 files changed, 166 insertions(+), 29 deletions(-) create mode 100644 app/Kernel/BaseObject.php create mode 100644 app/Kernel/Constants/BaseStatus.php create mode 100644 app/Kernel/Constants/WhetherStatus.php diff --git a/.env.online b/.env.online index 11c0bcc..40d1272 100644 --- a/.env.online +++ b/.env.online @@ -1,5 +1,5 @@ # 环境 -APP_ENV=production +APP_ENV=prod # 项目名称 APP_NAME=hyperf-advanced diff --git a/Dockerfile b/Dockerfile index 92318ff..825dd6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,54 +1,125 @@ -# Default Dockerfile + +# hyperf/hyperf:7.4 # # @link https://www.hyperf.io -# @document https://hyperf.wiki +# @document https://doc.hyperf.io # @contact group@hyperf.io # @license https://github.com/hyperf/hyperf/blob/master/LICENSE -FROM hyperf/hyperf:8.0-alpine-v3.12-swoole -LABEL maintainer="Hyperf Developers " version="1.0" license="MIT" app.name="Hyperf" +FROM alpine:3.12 -## -# ---------- env settings ---------- -## -# --build-arg timezone=Asia/Shanghai ARG timezone ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \ APP_ENV=prod \ SCAN_CACHEABLE=(true) -# update +ENV SWOOLE_VERSION 4.7.0 +ENV PHPIZE_DEPS="autoconf dpkg-dev dpkg file g++ gcc libc-dev make php7-dev php7-pear pkgconf re2c pcre-dev pcre2-dev zlib-dev libtool automake" + + +LABEL maintainer="Hyperf Developers " version="1.0" license="MIT" + +# trust this project public key to trust the packages. +ADD https://alpine-apk-repository.knowyourself.cc/php-alpine.rsa.pub /etc/apk/keys/php-alpine.rsa.pub + RUN set -ex \ - # show php version and extensions - && php -v \ - && php -m \ - && php --ri swoole \ - # ---------- some config ---------- - && cd /etc/php8 \ - # - config PHP + # change apk source repo + && echo "https://alpine-apk-repository.knowyourself.cc/v3.12/php-7.4" >> /etc/apk/repositories \ + && echo "@php https://alpine-apk-repository.knowyourself.cc/v3.12/php-7.4" >> /etc/apk/repositories \ + && apk update \ + && apk add --no-cache \ + # Install base packages ('ca-certificates' will install 'nghttp2-libs') + ca-certificates \ + curl \ + wget \ + tar \ + xz \ + libressl \ + tzdata \ + pcre \ + php7 \ + php7-bcmath \ + php7-curl \ + php7-ctype \ + php7-dom \ + php7-gd \ + php7-iconv \ + php7-json \ + php7-mbstring \ + php7-mysqlnd \ + php7-openssl \ + php7-pdo \ + php7-pdo_mysql \ + php7-pdo_sqlite \ + php7-phar \ + php7-posix \ + php7-redis \ + php7-sockets \ + php7-sodium \ + php7-sysvshm \ + php7-sysvmsg \ + php7-sysvsem \ + php7-zip \ + php7-zlib \ + php7-xml \ + php7-xmlreader \ + php7-pcntl \ + php7-opcache \ + && ln -sf /usr/bin/php7 /usr/bin/php + +RUN set -ex \ + && apk update \ + # for swoole extension libaio linux-headers + && apk add --no-cache libstdc++ openssl git bash \ + && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS libaio-dev openssl-dev curl-dev + +# composer +RUN curl -O https://mirrors.aliyun.com/composer/composer.phar \ + && chmod +x composer.phar \ + && mv composer.phar /usr/bin/composer +# use aliyun composer +RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ + +# swoole ext +RUN cd /tmp \ + && wget https://github.com/swoole/swoole-src/archive/v${SWOOLE_VERSION}.tar.gz -O swoole.tar.gz \ + && mkdir -p swoole \ + && tar -xf swoole.tar.gz -C swoole --strip-components=1 \ + && rm swoole.tar.gz \ + && ln -s /usr/bin/phpize7 /usr/local/bin/phpize \ + && ln -s /usr/bin/php-config7 /usr/local/bin/php-config \ + && ( \ + cd swoole \ + && phpize \ + && ./configure --enable-openssl --enable-http2 --enable-swoole-curl --enable-swoole-json \ + && make -s -j$(nproc) && make install \ + ) \ && { \ echo "upload_max_filesize=128M"; \ echo "post_max_size=128M"; \ echo "memory_limit=1G"; \ echo "date.timezone=${TIMEZONE}"; \ - } | tee conf.d/99_overrides.ini \ - # - config timezone + } | tee /etc/php7/conf.d/99_overrides.ini \ && ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \ && echo "${TIMEZONE}" > /etc/timezone \ - # ---------- clear works ---------- - && rm -rf /var/cache/apk/* /tmp/* /usr/share/man \ + && echo "opcache.enable_cli = 'On'" >> /etc/php7/conf.d/00_opcache.ini \ + && echo "extension=swoole.so" > /etc/php7/conf.d/50_swoole.ini \ + && echo "swoole.use_shortname = 'Off'" >> /etc/php7/conf.d/50_swoole.ini \ + && rm -r swoole \ + && php -v \ + && php -m \ + && php --ri swoole \ + && composer \ + && apk del --purge *-dev \ + && rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/share/php7 \ && echo -e "\033[42;37m Build Completed :).\033[0m\n" -WORKDIR /opt/www - -# Composer Cache -# COPY ./composer.* /opt/www/ -# RUN composer install --no-dev --no-scripts +WORKDIR /hyperf -COPY . /opt/www +COPY . /hyperf RUN composer install --no-dev -o && php bin/hyperf.php EXPOSE 9501 -ENTRYPOINT ["php", "/opt/www/bin/hyperf.php", "start"] +ENTRYPOINT ["php", "/hyperf/bin/hyperf.php", "start"] diff --git a/app/Kernel/BaseObject.php b/app/Kernel/BaseObject.php new file mode 100644 index 0000000..7f0cdf6 --- /dev/null +++ b/app/Kernel/BaseObject.php @@ -0,0 +1,15 @@ + env('APP_ENV') !== 'production', + 'enable' => env('APP_ENV') !== 'prod', // swagger 配置的输出文件 // 当你有多个 http server 时, 可以在输出文件的名称中增加 {server} 字面变量 // 比如 /public/swagger/swagger_{server}.json From b105862a873a24bca95d3e9bc79cd82175c5c4f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Fri, 3 Sep 2021 11:38:22 +0800 Subject: [PATCH 79/82] =?UTF-8?q?=E6=A0=B8=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Kernel/BaseController.php | 71 ++++++++++++++ app/Kernel/BaseMySQLDao.php | 35 +++++++ app/Kernel/BaseService.php | 57 ++++++++++++ app/Kernel/Entity/Page.php | 33 +++++++ app/Kernel/Exceptions/FrameworkException.php | 15 +++ app/Kernel/Http/Response.php | 97 ++++++++++++++++++++ config/autoload/dependencies.php | 6 +- 7 files changed, 312 insertions(+), 2 deletions(-) create mode 100644 app/Kernel/BaseController.php create mode 100644 app/Kernel/BaseMySQLDao.php create mode 100644 app/Kernel/BaseService.php create mode 100644 app/Kernel/Entity/Page.php create mode 100644 app/Kernel/Exceptions/FrameworkException.php create mode 100644 app/Kernel/Http/Response.php diff --git a/app/Kernel/BaseController.php b/app/Kernel/BaseController.php new file mode 100644 index 0000000..f80207d --- /dev/null +++ b/app/Kernel/BaseController.php @@ -0,0 +1,71 @@ +container = $container; + $this->request = $container->get(RequestInterface::class); + $this->response = $container->get(Response::class); + } + + /** + * 真实 ip + * + * @param string $headerName + * + * @return mixed|string + */ + public function getClientIp($headerName = 'x-real-ip') + { + $client = $this->request->getServerParams(); + $xri = $this->request->getHeader($headerName); + if (!empty($xri)) { + $clientAddress = $xri[0]; + } else { + $clientAddress = $client['remote_addr']; + } + $xff = $this->request->getHeader('x-forwarded-for'); + if ($clientAddress === '127.0.0.1') { + if (!empty($xri)) { + // 如果有xri 则判定为前端有NGINX等代理 + $clientAddress = $xri[0]; + } elseif (!empty($xff)) { + // 如果不存在xri 则继续判断xff + $list = explode(',', $xff[0]); + if (isset($list[0])) { + $clientAddress = $list[0]; + } + } + } + return $clientAddress; + } +} diff --git a/app/Kernel/BaseMySQLDao.php b/app/Kernel/BaseMySQLDao.php new file mode 100644 index 0000000..337649e --- /dev/null +++ b/app/Kernel/BaseMySQLDao.php @@ -0,0 +1,35 @@ +total) { + $sql = sprintf("select count(*) as count from (%s) as b", $query->toSql()); + $output['total'] = Db::selectOne($sql, $query->getBindings())->count; + } + + if (!$page->all) { + $query->forPage($page->page, $page->pageSize); + $output['page'] = $page->page; + $output['page_size'] = $page->pageSize; + } + + $output['list'] = $query->get()->toArray(); + return $output; + } +} diff --git a/app/Kernel/BaseService.php b/app/Kernel/BaseService.php new file mode 100644 index 0000000..cf461aa --- /dev/null +++ b/app/Kernel/BaseService.php @@ -0,0 +1,57 @@ + $item) { + $data[$key] = call_user_func($handler, $item); + } + return $data; + } + + /** + * page + * + * @param array $data + * @param Page $page + * + * @return array + */ + public function output(array $data, Page $page): array + { + $output = []; + if ($page->total) { + $total = count($data); + $output['total'] = $total; + } + + $list = $data; + if (!$page->all) { + $pageSize = $page->pageSize; + $offset = ($page->page - 1) * $pageSize; + $data = array_values($data); + $output['page'] = $page->page; + $output['page_size'] = $pageSize; + $list = array_slice($data, $offset, $pageSize); + } + + $output['list'] = $list; + return $output; + } +} diff --git a/app/Kernel/Entity/Page.php b/app/Kernel/Entity/Page.php new file mode 100644 index 0000000..e6c4dcf --- /dev/null +++ b/app/Kernel/Entity/Page.php @@ -0,0 +1,33 @@ +json([ + 'code' => "0", + 'msg' => $msg, + 'data' => empty($data) ? new stdClass() : $data, + ]); + } + + public function fail($code, $message = ''): PsrResponseInterface + { + return $this->json([ + 'code' => $code, + 'msg' => $message, + 'data' => new stdClass(), + ]); + } + + public function cookie(Cookie $cookie) + { + $response = $this->withCookie($cookie); + Context::set(PsrResponseInterface::class, $response); + return $this; + } + + + public function header(string $name, string $value) + { + $response = $this->withAddedHeader($name, $value); + Context::set(PsrResponseInterface::class, $response); + return $this; + } + + protected function toJson($data): string + { + try { + $result = Json::encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + } catch (\Throwable $exception) { + throw new EncodingException($exception->getMessage(), $exception->getCode()); + } + + return $result; + } + + public function raw($data): PsrResponseInterface + { + return $this->getResponse() + ->withBody(new SwooleStream((string) $data)); + } + + public function fileFlow(string $file) + { + $file = new SplFileInfo($file); + if (! $file->isReadable()) { + throw new FileException('File must be readable.'); + } + $contentType = value(function () use ($file) { + $mineType = null; + if (ApplicationContext::hasContainer()) { + $guesser = ApplicationContext::getContainer()->get(MimeTypeExtensionGuesser::class); + $mineType = $guesser->guessMimeType($file->getExtension()); + } + return $mineType ?? 'application/octet-stream'; + }); + + return $this->getResponse() + ->withAddedHeader('content-type', $contentType) + ->withBody(new SwooleFileStream($file)); + } +} diff --git a/config/autoload/dependencies.php b/config/autoload/dependencies.php index ec7d61a..04aae01 100644 --- a/config/autoload/dependencies.php +++ b/config/autoload/dependencies.php @@ -11,9 +11,11 @@ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use App\Kernel\Http\Response; use Hyperf\Utils\Filesystem\Filesystem; use Hyperf\Contract\StdoutLoggerInterface; use App\Kernel\Log\LoggerFactory; +use Psr\Http\Message\ResponseInterface; // todo 后期优化, 监听boostrap 事件,将数组写入文件,或者 直接 di 进去 $daoInterface = value(function () { @@ -40,8 +42,8 @@ }); return array_merge($daoInterface, [ - //ResponseInterface::class => Response::class, - //Hyperf\HttpServer\Response::class => Response::class, + ResponseInterface::class => Response::class, + Hyperf\HttpServer\Response::class => Response::class, //ErrorCode::class => App\Constants\ErrorCode::class, StdoutLoggerInterface::class => LoggerFactory::class, Hyperf\Database\Commands\ModelCommand::class => App\Kernel\Commands\Model\ModelCommand::class, From 11a9e8c7703123e220d72dab42aa301384a72841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Sat, 11 Sep 2021 22:09:29 +0800 Subject: [PATCH 80/82] =?UTF-8?q?=E6=A0=B8=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constants/ErrorCode.php | 26 - app/Controller/AbstractController.php | 38 - app/Controller/IndexController.php | 12 +- app/Kernel/BaseController.php | 71 -- app/Kernel/BaseModel.php | 188 ---- app/Kernel/BaseMySQLDao.php | 35 - app/Kernel/BaseObject.php | 15 - app/Kernel/BaseService.php | 57 - app/Kernel/ClassMap/Coroutine.php | 106 -- app/Kernel/Commands/Model/ModelCommand.php | 96 -- .../Commands/Model/ModelUpdateVisitor.php | 60 -- app/Kernel/Commands/Model/stubs/Model.stub | 45 - app/Kernel/Constants/BaseStatus.php | 29 - app/Kernel/Constants/SoftDeleted.php | 29 - app/Kernel/Constants/WhetherStatus.php | 22 - app/Kernel/Entity/Page.php | 33 - app/Kernel/Exceptions/BusinessException.php | 28 - app/Kernel/Exceptions/FrameworkException.php | 15 - .../Handler/AppExceptionHandler.php | 43 - app/Kernel/Http/Response.php | 97 -- app/Kernel/Log/AppendRequestIdProcessor.php | 35 - app/Kernel/Log/LoggerFactory.php | 21 - app/Kernel/Middleware/CorsMiddleware.php | 54 - app/Kernel/Middleware/DebugLogMiddleware.php | 38 - composer.json | 6 +- composer.lock | 985 ++++++++++++------ config/autoload/annotations.php | 3 - config/autoload/apidog.php | 2 - config/autoload/databases.php | 5 +- config/autoload/dependencies.php | 10 +- config/autoload/errorCode.php | 11 +- config/autoload/exceptions.php | 8 +- config/autoload/logger.php | 2 +- config/autoload/middlewares.php | 4 +- 34 files changed, 682 insertions(+), 1547 deletions(-) delete mode 100644 app/Constants/ErrorCode.php delete mode 100644 app/Controller/AbstractController.php delete mode 100644 app/Kernel/BaseController.php delete mode 100644 app/Kernel/BaseModel.php delete mode 100644 app/Kernel/BaseMySQLDao.php delete mode 100644 app/Kernel/BaseObject.php delete mode 100644 app/Kernel/BaseService.php delete mode 100644 app/Kernel/ClassMap/Coroutine.php delete mode 100644 app/Kernel/Commands/Model/ModelCommand.php delete mode 100644 app/Kernel/Commands/Model/ModelUpdateVisitor.php delete mode 100644 app/Kernel/Commands/Model/stubs/Model.stub delete mode 100644 app/Kernel/Constants/BaseStatus.php delete mode 100644 app/Kernel/Constants/SoftDeleted.php delete mode 100644 app/Kernel/Constants/WhetherStatus.php delete mode 100644 app/Kernel/Entity/Page.php delete mode 100644 app/Kernel/Exceptions/BusinessException.php delete mode 100644 app/Kernel/Exceptions/FrameworkException.php delete mode 100644 app/Kernel/Exceptions/Handler/AppExceptionHandler.php delete mode 100644 app/Kernel/Http/Response.php delete mode 100644 app/Kernel/Log/AppendRequestIdProcessor.php delete mode 100644 app/Kernel/Log/LoggerFactory.php delete mode 100644 app/Kernel/Middleware/CorsMiddleware.php delete mode 100644 app/Kernel/Middleware/DebugLogMiddleware.php diff --git a/app/Constants/ErrorCode.php b/app/Constants/ErrorCode.php deleted file mode 100644 index 0d99acf..0000000 --- a/app/Constants/ErrorCode.php +++ /dev/null @@ -1,26 +0,0 @@ -logger->info('xxxx'); - return [ - 'method' => $method, + return $this->response->success([ + 'method' => $method, 'message' => "Hello {$user}.", - ]; + ]); } } diff --git a/app/Kernel/BaseController.php b/app/Kernel/BaseController.php deleted file mode 100644 index f80207d..0000000 --- a/app/Kernel/BaseController.php +++ /dev/null @@ -1,71 +0,0 @@ -container = $container; - $this->request = $container->get(RequestInterface::class); - $this->response = $container->get(Response::class); - } - - /** - * 真实 ip - * - * @param string $headerName - * - * @return mixed|string - */ - public function getClientIp($headerName = 'x-real-ip') - { - $client = $this->request->getServerParams(); - $xri = $this->request->getHeader($headerName); - if (!empty($xri)) { - $clientAddress = $xri[0]; - } else { - $clientAddress = $client['remote_addr']; - } - $xff = $this->request->getHeader('x-forwarded-for'); - if ($clientAddress === '127.0.0.1') { - if (!empty($xri)) { - // 如果有xri 则判定为前端有NGINX等代理 - $clientAddress = $xri[0]; - } elseif (!empty($xff)) { - // 如果不存在xri 则继续判断xff - $list = explode(',', $xff[0]); - if (isset($list[0])) { - $clientAddress = $list[0]; - } - } - } - return $clientAddress; - } -} diff --git a/app/Kernel/BaseModel.php b/app/Kernel/BaseModel.php deleted file mode 100644 index ff85ffb..0000000 --- a/app/Kernel/BaseModel.php +++ /dev/null @@ -1,188 +0,0 @@ -enable = SoftDeleted::DISABLE; - return $this->save(); - } - - /** - * @param mixed $value - * @return string - */ - public function fromDateTime($value) - { - return strval($this->asTimestamp($value)); - } - - public static function betweenTime(Builder $model, string $field, array $data) - { - $model->where(function (Builder $builder) use ($field, $data) { - if ($data['start'] > 0) { - $builder->where($field, '>=', $data['start']); - } - if ($data['end'] > 0) { - $builder->where($field, '<', $data['end']); - } - }); - } - - /** - * @param array $conditions - * @param array $field - * @param bool $forUpdate - * @return null|BaseModel|object|static - */ - public static function findOneCondition(array $conditions, $field = ['*'], $forUpdate = false): ?self - { - $model = self::query(); - - if (count($conditions) === count($conditions, 1)) { - foreach ($conditions as $key => $value) { - if (is_null($value)) { - continue; - } - if (is_array($value)) { - $model->whereIn($key, $value); - } else { - $model->where($key, $value); - } - } - } else { - $model->where($conditions); - } - - $model->where('enable', SoftDeleted::ENABLE); - if ($forUpdate) { - $model->lockForUpdate(); - } - return $model->first($field); - } - - /** - * @param array $conditions - * @param array $field - * @param bool $forUpdate - * @return \Hyperf\Database\Model\Collection|static[] - */ - public static function findCondition(array $conditions, $field = ['*'], $forUpdate = false) - { - $model = self::query(); - if (count($conditions) === count($conditions, 1)) { - foreach ($conditions as $key => $value) { - if (is_null($value)) { - continue; - } - if (is_array($value)) { - $model->whereIn($key, $value); - } else { - $model->where($key, $value); - } - } - } else { - $model->where($conditions); - } - $model->where('enable', SoftDeleted::ENABLE); - if ($forUpdate) { - $model->lockForUpdate(); - } - return $model->get($field); - } - - /** - * insert or update a record - * - * @param array $values - * @param array $column - * @return bool - */ - public static function insertOrUpdate(array $values, array $column) - { - if (empty($column)) { - $column = array_keys($values); - } - $value = []; - foreach ($column as $item) { - $value[$item] = Db::raw("values(`{$item}`)"); - } - $model = new static(); - $connection = $model->getConnection(); // 数据库连接 - $builder = $model->newQuery()->getQuery(); // 查询构造器 - $grammar = $builder->getGrammar(); // 语法器 - // 编译插入语句 - $insert = $grammar->compileInsert($builder, $values); - // 编译重复后更新列语句。 - $update = $model->compileUpdateColumns($grammar, $value); - // 构造查询语句 - $query = $insert . ' on duplicate key update ' . $update; - // 组装sql绑定参数 - $bindings = $model->prepareBindingsForInsertOrUpdate($values, $value); - // 执行数据库查询 - return $connection->insert($query, $bindings); - } - - /** - * Compile all of the columns for an update statement. - * - * @param Grammar $grammar - * @param array $values - * @return string - */ - private function compileUpdateColumns(Grammar $grammar, array $values) - { - return collect($values)->map(function ($value, $key) use ($grammar) { - return $grammar->wrap($key) . ' = ' . $grammar->parameter($value); - })->implode(', '); - } - - /** - * Prepare the bindings for an insert or update statement. - * - * @param array $values - * @param array $value - * @return array - */ - private function prepareBindingsForInsertOrUpdate(array $values, array $value) - { - // Merge array of bindings - $bindings = array_merge_recursive($values, [$value]); - // Remove all of the expressions from a list of bindings. - return array_values(array_filter(Arr::flatten($bindings, 1), function ($binding) { - return !$binding instanceof Expression; - })); - } - - protected function asJson($value) - { - return json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); - } -} diff --git a/app/Kernel/BaseMySQLDao.php b/app/Kernel/BaseMySQLDao.php deleted file mode 100644 index 337649e..0000000 --- a/app/Kernel/BaseMySQLDao.php +++ /dev/null @@ -1,35 +0,0 @@ -total) { - $sql = sprintf("select count(*) as count from (%s) as b", $query->toSql()); - $output['total'] = Db::selectOne($sql, $query->getBindings())->count; - } - - if (!$page->all) { - $query->forPage($page->page, $page->pageSize); - $output['page'] = $page->page; - $output['page_size'] = $page->pageSize; - } - - $output['list'] = $query->get()->toArray(); - return $output; - } -} diff --git a/app/Kernel/BaseObject.php b/app/Kernel/BaseObject.php deleted file mode 100644 index 7f0cdf6..0000000 --- a/app/Kernel/BaseObject.php +++ /dev/null @@ -1,15 +0,0 @@ - $item) { - $data[$key] = call_user_func($handler, $item); - } - return $data; - } - - /** - * page - * - * @param array $data - * @param Page $page - * - * @return array - */ - public function output(array $data, Page $page): array - { - $output = []; - if ($page->total) { - $total = count($data); - $output['total'] = $total; - } - - $list = $data; - if (!$page->all) { - $pageSize = $page->pageSize; - $offset = ($page->page - 1) * $pageSize; - $data = array_values($data); - $output['page'] = $page->page; - $output['page_size'] = $pageSize; - $list = array_slice($data, $offset, $pageSize); - } - - $output['list'] = $list; - return $output; - } -} diff --git a/app/Kernel/ClassMap/Coroutine.php b/app/Kernel/ClassMap/Coroutine.php deleted file mode 100644 index d783977..0000000 --- a/app/Kernel/ClassMap/Coroutine.php +++ /dev/null @@ -1,106 +0,0 @@ -has(StdoutLoggerInterface::class)) { - /* @var LoggerInterface $logger */ - $logger = $container->get(StdoutLoggerInterface::class); - /* @var FormatterInterface $formatter */ - if ($container->has(FormatterInterface::class)) { - $formatter = $container->get(FormatterInterface::class); - $logger->warning($formatter->format($throwable)); - } else { - $logger->warning(sprintf('Uncaptured exception[%s] detected in %s::%d.', get_class($throwable), $throwable->getFile(), $throwable->getLine())); - } - } - } - } - }); - - try { - return $coroutine->getId(); - } catch (Throwable $exception) { - return -1; - } - } - - /** - * Returns the current coroutine ID. - * Returns -1 when running in non-coroutine context. - */ - public static function id(): int - { - return Co::id(); - } - - public static function defer(callable $callable) - { - Co::defer($callable); - } - - public static function sleep(float $seconds) - { - usleep(intval($seconds * 1000 * 1000)); - } - - /** - * Returns the parent coroutine ID. - * Returns 0 when running in the top level coroutine. - * @throws RunningInNonCoroutineException when running in non-coroutine context - * @throws CoroutineDestroyedException when the coroutine has been destroyed - */ - public static function parentId(?int $coroutineId = null): int - { - return Co::pid($coroutineId); - } - - public static function inCoroutine(): bool - { - return Co::id() > 0; - } -} diff --git a/app/Kernel/Commands/Model/ModelCommand.php b/app/Kernel/Commands/Model/ModelCommand.php deleted file mode 100644 index 1f6d5f5..0000000 --- a/app/Kernel/Commands/Model/ModelCommand.php +++ /dev/null @@ -1,96 +0,0 @@ -getSchemaBuilder($option->getPool()); - $table = Str::replaceFirst($option->getPrefix(), '', $table); - $columns = $this->formatColumns($builder->getColumnTypeListing($table)); - - $project = new Project(); - $class = $option->getTableMapping()[$table] ?? Str::studly(Str::singular($table)); - $class = $project->namespace($option->getPath()) . $class; - $path = BASE_PATH . '/' . $project->path($class); - - if (! file_exists($path)) { - $this->mkdir($path); - file_put_contents($path, $this->buildClassPrimaryKey($table, $class, $this->getPrimaryKey($columns), $option)); - } - - $columns = $this->getColumns($class, $columns, $option->isForceCasts()); - - $stms = $this->astParser->parse(file_get_contents($path)); - $traverser = new NodeTraverser(); - $traverser->addVisitor(make(ModelUpdateVisitor::class, [ - 'class' => $class, - 'columns' => $columns, - 'option' => $option, - ])); - $traverser->addVisitor(make(ModelRewriteConnectionVisitor::class, [$class, $option->getPool()])); - $data = make(ModelData::class)->setClass($class)->setColumns($columns); - foreach ($option->getVisitors() as $visitorClass) { - $traverser->addVisitor(make($visitorClass, [$option, $data])); - } - $stms = $traverser->traverse($stms); - $code = $this->printer->prettyPrintFile($stms); - - file_put_contents($path, $code); - $this->output->writeln(sprintf('Model %s was created.', $class)); - - if ($option->isWithIde()) { - $this->generateIDE($code, $option, $data); - } - } - - protected function replacePrimaryKey(string &$stub, string $primaryKey): self - { - $stub = str_replace(['%PRIMARY_KEY%'], [$primaryKey], $stub); - - return $this; - } - - /** - * Build the class with the given name. - */ - protected function buildClassPrimaryKey(string $table, string $name, string $primaryKey, ModelOption $option): string - { - $stub = file_get_contents(__DIR__ . '/stubs/Model.stub'); - - return $this->replaceNamespace($stub, $name) - ->replaceInheritance($stub, $option->getInheritance()) - ->replaceConnection($stub, $option->getPool()) - ->replaceUses($stub, $option->getUses()) - ->replaceClass($stub, $name) - ->replacePrimaryKey($stub, $primaryKey) - ->replaceTable($stub, $table); - } -} diff --git a/app/Kernel/Commands/Model/ModelUpdateVisitor.php b/app/Kernel/Commands/Model/ModelUpdateVisitor.php deleted file mode 100644 index 52937cd..0000000 --- a/app/Kernel/Commands/Model/ModelUpdateVisitor.php +++ /dev/null @@ -1,60 +0,0 @@ -columns as $column) { - if ($column['column_key'] === 'PRI' || in_array($column['column_name'], $exceptColumn)) { - continue; - } - $items[] = new Node\Expr\ArrayItem(new String_($column['column_name'])); - } - $node->default = new Array_($items, [ - 'kind' => Array_::KIND_SHORT, - ]); - return $node; - } - - protected function formatDatabaseType(string $type): ?string - { - switch ($type) { - case 'tinyint': - case 'smallint': - case 'mediumint': - case 'int': - return 'integer'; - case 'bigint': - case 'decimal': - case 'float': - case 'double': - case 'real': - return 'string'; - case 'bool': - case 'boolean': - return 'boolean'; - default: - return null; - } - } -} diff --git a/app/Kernel/Commands/Model/stubs/Model.stub b/app/Kernel/Commands/Model/stubs/Model.stub deleted file mode 100644 index 1810c39..0000000 --- a/app/Kernel/Commands/Model/stubs/Model.stub +++ /dev/null @@ -1,45 +0,0 @@ -logger = $logger; - } - - public function handle(Throwable $throwable, ResponseInterface $response) - { - $this->logger->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile())); - $this->logger->error($throwable->getTraceAsString()); - return $response->withHeader('Server', 'Hyperf')->withStatus(500)->withBody(new SwooleStream('Internal Server Error.')); - } - - public function isValid(Throwable $throwable): bool - { - return true; - } -} diff --git a/app/Kernel/Http/Response.php b/app/Kernel/Http/Response.php deleted file mode 100644 index 53100e2..0000000 --- a/app/Kernel/Http/Response.php +++ /dev/null @@ -1,97 +0,0 @@ -json([ - 'code' => "0", - 'msg' => $msg, - 'data' => empty($data) ? new stdClass() : $data, - ]); - } - - public function fail($code, $message = ''): PsrResponseInterface - { - return $this->json([ - 'code' => $code, - 'msg' => $message, - 'data' => new stdClass(), - ]); - } - - public function cookie(Cookie $cookie) - { - $response = $this->withCookie($cookie); - Context::set(PsrResponseInterface::class, $response); - return $this; - } - - - public function header(string $name, string $value) - { - $response = $this->withAddedHeader($name, $value); - Context::set(PsrResponseInterface::class, $response); - return $this; - } - - protected function toJson($data): string - { - try { - $result = Json::encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); - } catch (\Throwable $exception) { - throw new EncodingException($exception->getMessage(), $exception->getCode()); - } - - return $result; - } - - public function raw($data): PsrResponseInterface - { - return $this->getResponse() - ->withBody(new SwooleStream((string) $data)); - } - - public function fileFlow(string $file) - { - $file = new SplFileInfo($file); - if (! $file->isReadable()) { - throw new FileException('File must be readable.'); - } - $contentType = value(function () use ($file) { - $mineType = null; - if (ApplicationContext::hasContainer()) { - $guesser = ApplicationContext::getContainer()->get(MimeTypeExtensionGuesser::class); - $mineType = $guesser->guessMimeType($file->getExtension()); - } - return $mineType ?? 'application/octet-stream'; - }); - - return $this->getResponse() - ->withAddedHeader('content-type', $contentType) - ->withBody(new SwooleFileStream($file)); - } -} diff --git a/app/Kernel/Log/AppendRequestIdProcessor.php b/app/Kernel/Log/AppendRequestIdProcessor.php deleted file mode 100644 index 8bbe5fe..0000000 --- a/app/Kernel/Log/AppendRequestIdProcessor.php +++ /dev/null @@ -1,35 +0,0 @@ -idGenerator->generate()); - $record['context']['coroutine_id'] = Coroutine::id(); - return $record; - } -} diff --git a/app/Kernel/Log/LoggerFactory.php b/app/Kernel/Log/LoggerFactory.php deleted file mode 100644 index 57e44c9..0000000 --- a/app/Kernel/Log/LoggerFactory.php +++ /dev/null @@ -1,21 +0,0 @@ -get(HyperfLoggerFactory::class)->make(); - } -} diff --git a/app/Kernel/Middleware/CorsMiddleware.php b/app/Kernel/Middleware/CorsMiddleware.php deleted file mode 100644 index b8e0590..0000000 --- a/app/Kernel/Middleware/CorsMiddleware.php +++ /dev/null @@ -1,54 +0,0 @@ -getHeaderLine('Access-Control-Request-Headers'); - if (empty($header)) { - $header = '*'; - } - - // 设置跨域 - $response = Context::get(ResponseInterface::class); - $response = $response->withAddedHeader('Access-Control-Expose-Headers', '*') - ->withAddedHeader('Access-Control-Allow-Origin', '*') - ->withAddedHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, DELETE') - ->withAddedHeader('Access-Control-Allow-Headers', $header); - Context::set(ResponseInterface::class, $response); - - if (strtoupper($request->getMethod()) == 'OPTIONS') { - return $response; - } - - $response = $handler->handle($request); - return $response; - } -} diff --git a/app/Kernel/Middleware/DebugLogMiddleware.php b/app/Kernel/Middleware/DebugLogMiddleware.php deleted file mode 100644 index 4b64bd4..0000000 --- a/app/Kernel/Middleware/DebugLogMiddleware.php +++ /dev/null @@ -1,38 +0,0 @@ -idGenerator = $idGenerator; - } - - public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface - { - Context::getOrSet(AppendRequestIdProcessor::REQUEST_ID, $this->idGenerator->generate()); - return $handler->handle($request); - } -} diff --git a/composer.json b/composer.json index 1de7a91..05d666c 100644 --- a/composer.json +++ b/composer.json @@ -28,9 +28,9 @@ "hyperf/logger": "~2.2.0", "hyperf/memory": "~2.2.0", "hyperf/process": "~2.2.0", - "hyperf/redis": "~2.2.0", - "hyperf/snowflake": "^2.2", - "hyperf/task": "^2.2" + "hyperf/task": "^2.2", + "lengbin/hyperf-common": "2.0.x-dev", + "lengbin/hyperf-error-code": "2.0.x-dev" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.0", diff --git a/composer.lock b/composer.lock index 6b87342..f37ce5f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ea513485f1154a0ce02e7c99756ecc4f", + "content-hash": "02e1bea256b11da73098b939103a8453", "packages": [ { "name": "daodao97/apidog", @@ -804,6 +804,55 @@ }, "time": "2021-06-30T20:03:07+00:00" }, + { + "name": "hanneskod/classtools", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/hanneskod/classtools.git", + "reference": "d365ddac0e602027c0471ea292f4ba2afcb49394" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hanneskod/classtools/zipball/d365ddac0e602027c0471ea292f4ba2afcb49394", + "reference": "d365ddac0e602027c0471ea292f4ba2afcb49394", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4", + "php": ">=7.1", + "symfony/finder": "^4|^5" + }, + "type": "library", + "autoload": { + "psr-4": { + "hanneskod\\classtools\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "WTFPL" + ], + "authors": [ + { + "name": "Hannes Forsgård", + "email": "hannes.forsgard@fripost.org" + } + ], + "description": "Find, extract and process classes from file system", + "homepage": "https://github.com/hanneskod/classtools", + "keywords": [ + "class finder", + "code generator", + "metaprogramming", + "minimizer" + ], + "support": { + "issues": "https://github.com/hanneskod/classtools/issues", + "source": "https://github.com/hanneskod/classtools/tree/1.0" + }, + "time": "2020-03-05T20:41:28+00:00" + }, { "name": "hyperf/cache", "version": "v2.2.0", @@ -1247,16 +1296,16 @@ }, { "name": "hyperf/di", - "version": "v2.2.4", + "version": "v2.2.7", "source": { "type": "git", "url": "https://github.com/hyperf/di.git", - "reference": "ac4813b0b5cf677dcce479ebd8dd441ef79b361b" + "reference": "0cf98369681fca7934e6bbe5e09d98105516125b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hyperf/di/zipball/ac4813b0b5cf677dcce479ebd8dd441ef79b361b", - "reference": "ac4813b0b5cf677dcce479ebd8dd441ef79b361b", + "url": "https://api.github.com/repos/hyperf/di/zipball/0cf98369681fca7934e6bbe5e09d98105516125b", + "reference": "0cf98369681fca7934e6bbe5e09d98105516125b", "shasum": "" }, "require": { @@ -1306,7 +1355,7 @@ "pull-request": "https://github.com/hyperf/hyperf/pulls", "source": "https://github.com/hyperf/hyperf" }, - "time": "2021-08-14T02:40:30+00:00" + "time": "2021-09-03T15:52:27+00:00" }, { "name": "hyperf/dispatcher", @@ -2334,16 +2383,16 @@ }, { "name": "hyperf/utils", - "version": "v2.2.5", + "version": "v2.2.7", "source": { "type": "git", "url": "https://github.com/hyperf/utils.git", - "reference": "bff47ad92d5d85cd6b941d9766c8a251d1648860" + "reference": "add20f7421ef7130488e35527b1c03b590572af0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hyperf/utils/zipball/bff47ad92d5d85cd6b941d9766c8a251d1648860", - "reference": "bff47ad92d5d85cd6b941d9766c8a251d1648860", + "url": "https://api.github.com/repos/hyperf/utils/zipball/add20f7421ef7130488e35527b1c03b590572af0", + "reference": "add20f7421ef7130488e35527b1c03b590572af0", "shasum": "" }, "require": { @@ -2395,20 +2444,20 @@ "pull-request": "https://github.com/hyperf/hyperf/pulls", "source": "https://github.com/hyperf/hyperf" }, - "time": "2021-08-18T08:28:09+00:00" + "time": "2021-09-06T02:20:50+00:00" }, { "name": "hyperf/validation", - "version": "v2.2.6", + "version": "v2.2.7", "source": { "type": "git", "url": "https://github.com/hyperf/validation.git", - "reference": "f746675a832844a037e1ab4980c48d535717be5f" + "reference": "5dd2f6bee4c36bf7f7f99b56bd8885d52dc4daea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hyperf/validation/zipball/f746675a832844a037e1ab4980c48d535717be5f", - "reference": "f746675a832844a037e1ab4980c48d535717be5f", + "url": "https://api.github.com/repos/hyperf/validation/zipball/5dd2f6bee4c36bf7f7f99b56bd8885d52dc4daea", + "reference": "5dd2f6bee4c36bf7f7f99b56bd8885d52dc4daea", "shasum": "" }, "require": { @@ -2451,35 +2500,34 @@ ], "support": { "issues": "https://github.com/hyperf/validation/issues", - "source": "https://github.com/hyperf/validation/tree/v2.2.6" + "source": "https://github.com/hyperf/validation/tree/v2.2.7" }, - "time": "2021-08-23T07:38:19+00:00" + "time": "2021-09-04T16:00:43+00:00" }, { "name": "laminas/laminas-mime", - "version": "2.8.0", + "version": "2.9.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-mime.git", - "reference": "9a59704f33106427a384d0ae421f96043174093a" + "reference": "02cc861f704d468726866457dcf8338d1fe74e76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-mime/zipball/9a59704f33106427a384d0ae421f96043174093a", - "reference": "9a59704f33106427a384d0ae421f96043174093a", + "url": "https://api.github.com/repos/laminas/laminas-mime/zipball/02cc861f704d468726866457dcf8338d1fe74e76", + "reference": "02cc861f704d468726866457dcf8338d1fe74e76", "shasum": "" }, "require": { "laminas/laminas-stdlib": "^2.7 || ^3.0", - "laminas/laminas-zendframework-bridge": "^1.0", - "php": "^7.3 || ~8.0.0" + "php": "^7.3 || ~8.0.0 || ~8.1.0" }, - "replace": { - "zendframework/zend-mime": "^2.7.2" + "conflict": { + "zendframework/zend-mime": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "~1.0.0", - "laminas/laminas-mail": "^2.6", + "laminas/laminas-coding-standard": "~2.2.1", + "laminas/laminas-mail": "^2.12", "phpunit/phpunit": "^9.3" }, "suggest": { @@ -2515,24 +2563,24 @@ "type": "community_bridge" } ], - "time": "2021-02-16T17:40:06+00:00" + "time": "2021-09-03T02:18:35+00:00" }, { "name": "laminas/laminas-stdlib", - "version": "3.5.0", + "version": "3.6.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-stdlib.git", - "reference": "c8ac6a76a133e682acfabc821d4a2ec646934b12" + "reference": "c53d8537f108fac3fae652677a19735db730ba46" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/c8ac6a76a133e682acfabc821d4a2ec646934b12", - "reference": "c8ac6a76a133e682acfabc821d4a2ec646934b12", + "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/c53d8537f108fac3fae652677a19735db730ba46", + "reference": "c53d8537f108fac3fae652677a19735db730ba46", "shasum": "" }, "require": { - "php": "^7.3 || ^8.0" + "php": "^7.3 || ~8.0.0 || ~8.1.0" }, "conflict": { "zendframework/zend-stdlib": "*" @@ -2574,69 +2622,337 @@ "type": "community_bridge" } ], - "time": "2021-08-03T13:40:40+00:00" + "time": "2021-09-02T16:11:32+00:00" }, { - "name": "laminas/laminas-zendframework-bridge", - "version": "1.3.0", + "name": "lengbin/common", + "version": "v2.0.x-dev", "source": { "type": "git", - "url": "https://github.com/laminas/laminas-zendframework-bridge.git", - "reference": "13af2502d9bb6f7d33be2de4b51fb68c6cdb476e" + "url": "https://github.com/ice-leng/common.git", + "reference": "e306517c52d31a8de3e20ee415ac59920f6051b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/13af2502d9bb6f7d33be2de4b51fb68c6cdb476e", - "reference": "13af2502d9bb6f7d33be2de4b51fb68c6cdb476e", + "url": "https://api.github.com/repos/ice-leng/common/zipball/e306517c52d31a8de3e20ee415ac59920f6051b2", + "reference": "e306517c52d31a8de3e20ee415ac59920f6051b2", "shasum": "" }, "require": { - "php": "^7.3 || ^8.0" + "lengbin/helper": "^1.0", + "php": ">=7.2", + "phpdocumentor/reflection-docblock": "^5.2" }, - "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1 || ^9.3", - "psalm/plugin-phpunit": "^0.15.1", - "squizlabs/php_codesniffer": "^3.5", - "vimeo/psalm": "^4.6" + "type": "library", + "autoload": { + "psr-4": { + "Lengbin\\Common\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "lengbin", + "email": "xykxyk2008@163.com" + } + ], + "description": "php common", + "keywords": [ + "common", + "extension", + "php" + ], + "support": { + "issues": "https://github.com/ice-leng/common/issues", + "source": "https://github.com/ice-leng/common/tree/v2.0" + }, + "time": "2021-09-11T12:47:19+00:00" + }, + { + "name": "lengbin/error-code", + "version": "2.0.x-dev", + "source": { + "type": "git", + "url": "https://github.com/ice-leng/error-code.git", + "reference": "1064c50af09ef80b845349e83997df673adcff82" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ice-leng/error-code/zipball/1064c50af09ef80b845349e83997df673adcff82", + "reference": "1064c50af09ef80b845349e83997df673adcff82", + "shasum": "" + }, + "require": { + "hanneskod/classtools": "^1.2", + "lengbin/common": "@dev", + "marc-mabe/php-enum": "^4.3", + "php": ">=7.2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Lengbin\\ErrorCode\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "lengbin", + "email": "xykxyk2008@163.com" + } + ], + "description": "php error code", + "keywords": [ + "error-code", + "extension", + "php" + ], + "support": { + "issues": "https://github.com/ice-leng/error-code/issues", + "source": "https://github.com/ice-leng/error-code/tree/2.0" + }, + "time": "2021-09-11T12:47:18+00:00" + }, + { + "name": "lengbin/helper", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/ice-leng/helper.git", + "reference": "59eae02cde1f718997e095108c1dd5b0a6108e6e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ice-leng/helper/zipball/59eae02cde1f718997e095108c1dd5b0a6108e6e", + "reference": "59eae02cde1f718997e095108c1dd5b0a6108e6e", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "php": ">=7.2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Lengbin\\Helper\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "lengbin", + "email": "xykxyk2008@163.com" + } + ], + "description": "php helper", + "keywords": [ + "extension", + "helper", + "php", + "yii2" + ], + "support": { + "issues": "https://github.com/ice-leng/helper/issues", + "source": "https://github.com/ice-leng/helper/tree/1.0.3" + }, + "time": "2021-09-06T02:48:38+00:00" + }, + { + "name": "lengbin/hyperf-common", + "version": "2.0.x-dev", + "source": { + "type": "git", + "url": "https://github.com/ice-leng/hyperf-common.git", + "reference": "0ac7b29af1b386540690a16d5792c36faf136aeb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ice-leng/hyperf-common/zipball/0ac7b29af1b386540690a16d5792c36faf136aeb", + "reference": "0ac7b29af1b386540690a16d5792c36faf136aeb", + "shasum": "" + }, + "require": { + "ext-swoole": ">=4.5", + "hyperf/command": "~2.0.0|~2.1.0|~2.2.0", + "hyperf/config": "~2.0.0|~2.1.0|~2.2.0", + "hyperf/db-connection": "~2.0.0|~2.1.0|~2.2.0", + "hyperf/framework": "~2.0.0|~2.1.0|~2.2.0", + "hyperf/http-server": "~2.0.0|~2.1.0|~2.2.0", + "hyperf/redis": "~2.0.0|~2.1.0|~2.2.0", + "hyperf/snowflake": "^2.2", + "lengbin/common": "v2.0.x-dev", + "lengbin/error-code": "2.0.x-dev", + "php": ">=7.2.0" }, "type": "library", "extra": { - "laminas": { - "module": "Laminas\\ZendFrameworkBridge" + "hyperf": { + "config": "Lengbin\\Hyperf\\Common\\ConfigProvider" } }, "autoload": { - "files": [ - "src/autoload.php" - ], "psr-4": { - "Laminas\\ZendFrameworkBridge\\": "src//" + "Lengbin\\Hyperf\\Common\\": "src" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], - "description": "Alias legacy ZF class names to Laminas Project equivalents.", + "authors": [ + { + "name": "lengbin", + "email": "xykxyk2008@163.com" + } + ], + "description": "hyperf common", "keywords": [ - "ZendFramework", - "autoloading", - "laminas", - "zf" + "common", + "extension", + "hyperf", + "php" ], "support": { - "forum": "https://discourse.laminas.dev/", - "issues": "https://github.com/laminas/laminas-zendframework-bridge/issues", - "rss": "https://github.com/laminas/laminas-zendframework-bridge/releases.atom", - "source": "https://github.com/laminas/laminas-zendframework-bridge" + "issues": "https://github.com/ice-leng/hyperf-common/issues", + "source": "https://github.com/ice-leng/hyperf-common/tree/2.0" }, - "funding": [ + "time": "2021-09-11T14:07:26+00:00" + }, + { + "name": "lengbin/hyperf-error-code", + "version": "2.0.x-dev", + "source": { + "type": "git", + "url": "https://github.com/ice-leng/hyperf-error-code.git", + "reference": "f2b7d8b5fc60cc404274f5eb2761761c355b3569" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ice-leng/hyperf-error-code/zipball/f2b7d8b5fc60cc404274f5eb2761761c355b3569", + "reference": "f2b7d8b5fc60cc404274f5eb2761761c355b3569", + "shasum": "" + }, + "require": { + "hyperf/command": "^2.2", + "lengbin/error-code": "2.0.x-dev", + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "hyperf": { + "config": "Lengbin\\Hyperf\\ErrorCode\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Lengbin\\Hyperf\\ErrorCode\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { - "url": "https://funding.communitybridge.org/projects/laminas-project", - "type": "community_bridge" + "name": "lengbin", + "email": "xykxyk2008@163.com" } ], - "time": "2021-06-24T12:49:22+00:00" + "description": "hyperf error code", + "keywords": [ + "command", + "error-code", + "extension", + "hyperf", + "hyperf-command", + "php" + ], + "support": { + "issues": "https://github.com/ice-leng/hyperf-error-code/issues", + "source": "https://github.com/ice-leng/hyperf-error-code/tree/2.0" + }, + "time": "2021-09-11T12:47:18+00:00" + }, + { + "name": "marc-mabe/php-enum", + "version": "v4.4.0", + "source": { + "type": "git", + "url": "https://github.com/marc-mabe/php-enum.git", + "reference": "e9dd4704d7cd2dd53cd19156f08f7dbdb9824f8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/marc-mabe/php-enum/zipball/e9dd4704d7cd2dd53cd19156f08f7dbdb9824f8c", + "reference": "e9dd4704d7cd2dd53cd19156f08f7dbdb9824f8c", + "shasum": "" + }, + "require": { + "ext-reflection": "*", + "php": "^7.1 | ^8.0" + }, + "require-dev": { + "phpbench/phpbench": "^0.16.10", + "phpstan/phpstan": "^0.12.42", + "phpunit/phpunit": "^7.5.20 | ^8.5.8 | ^9.3.8", + "vimeo/psalm": "^3.15.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.3-dev", + "dev-3.x": "3.1-dev", + "dev-2.x": "2.3-dev", + "dev-1.x": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "MabeEnum\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Marc Bennewitz", + "email": "dev@mabe.berlin", + "homepage": "https://mabe.berlin/", + "role": "Lead" + } + ], + "description": "Simple and fast implementation of enumerations with native PHP", + "homepage": "https://github.com/marc-mabe/php-enum", + "keywords": [ + "enum", + "enum-map", + "enum-set", + "enumeration", + "enumerator", + "enummap", + "enumset", + "map", + "set", + "type", + "type-hint", + "typehint" + ], + "support": { + "issues": "https://github.com/marc-mabe/php-enum/issues", + "source": "https://github.com/marc-mabe/php-enum/tree/v4.4.0" + }, + "time": "2020-10-12T21:17:47+00:00" }, { "name": "monolog/monolog", @@ -2736,16 +3052,16 @@ }, { "name": "nesbot/carbon", - "version": "2.52.0", + "version": "2.53.1", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "369c0e2737c56a0f39c946dd261855255a6fccbe" + "reference": "f4655858a784988f880c1b8c7feabbf02dfdf045" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/369c0e2737c56a0f39c946dd261855255a6fccbe", - "reference": "369c0e2737c56a0f39c946dd261855255a6fccbe", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/f4655858a784988f880c1b8c7feabbf02dfdf045", + "reference": "f4655858a784988f880c1b8c7feabbf02dfdf045", "shasum": "" }, "require": { @@ -2757,7 +3073,7 @@ }, "require-dev": { "doctrine/orm": "^2.7", - "friendsofphp/php-cs-fixer": "^2.14 || ^3.0", + "friendsofphp/php-cs-fixer": "^3.0", "kylekatarnls/multi-tester": "^2.0", "phpmd/phpmd": "^2.9", "phpstan/extension-installer": "^1.0", @@ -2826,7 +3142,7 @@ "type": "tidelift" } ], - "time": "2021-08-14T19:10:52+00:00" + "time": "2021-09-06T09:29:23+00:00" }, { "name": "nikic/fast-route", @@ -2976,6 +3292,164 @@ }, "time": "2020-10-12T12:39:22+00:00" }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, + "time": "2020-06-27T09:03:43+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "5.2.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.3", + "webmozart/assert": "^1.9.1" + }, + "require-dev": { + "mockery/mockery": "~1.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + }, + "time": "2020-09-03T19:13:55+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.0" + }, + "require-dev": { + "ext-tokenizer": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0" + }, + "time": "2020-09-17T18:55:26+00:00" + }, { "name": "phpoption/phpoption", "version": "1.8.0", @@ -5122,46 +5596,104 @@ }, "autoload": { "psr-4": { - "Dotenv\\": "src/" + "Dotenv\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "graham@alt-three.com", + "homepage": "https://gjcampbell.co.uk/" + }, + { + "name": "Vance Lucas", + "email": "vance@vancelucas.com", + "homepage": "https://vancelucas.com/" + } + ], + "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", + "keywords": [ + "dotenv", + "env", + "environment" + ], + "support": { + "issues": "https://github.com/vlucas/phpdotenv/issues", + "source": "https://github.com/vlucas/phpdotenv/tree/v5.3.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", + "type": "tidelift" + } + ], + "time": "2021-01-20T15:23:13+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.10.0", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", + "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<4.6.1 || 4.6.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.13" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Graham Campbell", - "email": "graham@alt-three.com", - "homepage": "https://gjcampbell.co.uk/" - }, - { - "name": "Vance Lucas", - "email": "vance@vancelucas.com", - "homepage": "https://vancelucas.com/" + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" } ], - "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", + "description": "Assertions to validate method input/output with nice error messages.", "keywords": [ - "dotenv", - "env", - "environment" + "assert", + "check", + "validate" ], "support": { - "issues": "https://github.com/vlucas/phpdotenv/issues", - "source": "https://github.com/vlucas/phpdotenv/tree/v5.3.0" + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.10.0" }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", - "type": "tidelift" - } - ], - "time": "2021-01-20T15:23:13+00:00" + "time": "2021-03-09T10:59:23+00:00" } ], "packages-dev": [ @@ -5890,193 +6422,35 @@ }, "time": "2020-10-14T08:32:19+00:00" }, - { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" - }, - "time": "2020-06-27T09:03:43+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "5.2.2", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", - "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", - "shasum": "" - }, - "require": { - "ext-filter": "*", - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", - "webmozart/assert": "^1.9.1" - }, - "require-dev": { - "mockery/mockery": "~1.3.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - }, - { - "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" - }, - "time": "2020-09-03T19:13:55+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.4.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", - "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0" - }, - "time": "2020-09-17T18:55:26+00:00" - }, { "name": "phpspec/prophecy", - "version": "1.13.0", + "version": "1.14.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea" + "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea", - "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", + "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", "shasum": "" }, "require": { "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.1", + "php": "^7.2 || ~8.0, <8.2", "phpdocumentor/reflection-docblock": "^5.2", "sebastian/comparator": "^3.0 || ^4.0", "sebastian/recursion-context": "^3.0 || ^4.0" }, "require-dev": { - "phpspec/phpspec": "^6.0", + "phpspec/phpspec": "^6.0 || ^7.0", "phpunit/phpunit": "^8.0 || ^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { @@ -6111,22 +6485,22 @@ ], "support": { "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/1.13.0" + "source": "https://github.com/phpspec/prophecy/tree/1.14.0" }, - "time": "2021-03-17T13:42:18+00:00" + "time": "2021-09-10T09:02:12+00:00" }, { "name": "phpstan/phpstan", - "version": "0.12.97", + "version": "0.12.98", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "a8867e63a00e606589faf8d3613164f20722c4ee" + "reference": "3bb7cc246c057405dd5e290c3ecc62ab51d57e00" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/a8867e63a00e606589faf8d3613164f20722c4ee", - "reference": "a8867e63a00e606589faf8d3613164f20722c4ee", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/3bb7cc246c057405dd5e290c3ecc62ab51d57e00", + "reference": "3bb7cc246c057405dd5e290c3ecc62ab51d57e00", "shasum": "" }, "require": { @@ -6157,7 +6531,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.97" + "source": "https://github.com/phpstan/phpstan/tree/0.12.98" }, "funding": [ { @@ -6177,7 +6551,7 @@ "type": "tidelift" } ], - "time": "2021-09-01T10:51:52+00:00" + "time": "2021-09-02T12:33:01+00:00" }, { "name": "phpunit/php-code-coverage", @@ -7453,6 +7827,7 @@ "type": "github" } ], + "abandoned": true, "time": "2020-09-28T06:45:17+00:00" }, { @@ -8160,73 +8535,19 @@ } ], "time": "2021-07-28T10:34:58+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.10.0", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<4.6.1 || 4.6.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.13" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "support": { - "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.10.0" - }, - "time": "2021-03-09T10:59:23+00:00" } ], "aliases": [], "minimum-stability": "dev", - "stability-flags": [], + "stability-flags": { + "lengbin/hyperf-common": 20, + "lengbin/hyperf-error-code": 20 + }, "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": ">=7.3" + "php": ">=7.4", + "ext-json": "*" }, "platform-dev": [], "plugin-api-version": "2.0.0" diff --git a/config/autoload/annotations.php b/config/autoload/annotations.php index a287014..5089693 100644 --- a/config/autoload/annotations.php +++ b/config/autoload/annotations.php @@ -17,8 +17,5 @@ 'ignore_annotations' => [ 'mixin', ], - 'class_map' => [ - \Hyperf\Utils\Coroutine::class => BASE_PATH . '/app/Kernel/ClassMap/Coroutine.php' - ], ], ]; diff --git a/config/autoload/apidog.php b/config/autoload/apidog.php index c6d887b..cc41c3e 100644 --- a/config/autoload/apidog.php +++ b/config/autoload/apidog.php @@ -1,7 +1,5 @@ env('APP_ENV') !== 'prod', diff --git a/config/autoload/databases.php b/config/autoload/databases.php index d3453ed..ef8fd8f 100644 --- a/config/autoload/databases.php +++ b/config/autoload/databases.php @@ -9,6 +9,9 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + +use Lengbin\Hyperf\Common\BaseModel; + return [ 'default' => [ 'driver' => env('DB_DRIVER', 'mysql'), @@ -38,7 +41,7 @@ 'path' => 'app/Model', 'force_casts' => true, 'inheritance' => 'BaseModel', - 'uses' => \App\Kernel\BaseModel::class, + 'uses' => BaseModel::class, 'refresh_fillable' => true, 'with_comments' => true, ], diff --git a/config/autoload/dependencies.php b/config/autoload/dependencies.php index 04aae01..8dd3a65 100644 --- a/config/autoload/dependencies.php +++ b/config/autoload/dependencies.php @@ -11,11 +11,7 @@ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ -use App\Kernel\Http\Response; use Hyperf\Utils\Filesystem\Filesystem; -use Hyperf\Contract\StdoutLoggerInterface; -use App\Kernel\Log\LoggerFactory; -use Psr\Http\Message\ResponseInterface; // todo 后期优化, 监听boostrap 事件,将数组写入文件,或者 直接 di 进去 $daoInterface = value(function () { @@ -42,9 +38,5 @@ }); return array_merge($daoInterface, [ - ResponseInterface::class => Response::class, - Hyperf\HttpServer\Response::class => Response::class, - //ErrorCode::class => App\Constants\ErrorCode::class, - StdoutLoggerInterface::class => LoggerFactory::class, - Hyperf\Database\Commands\ModelCommand::class => App\Kernel\Commands\Model\ModelCommand::class, + Hyperf\Database\Commands\ModelCommand::class => Lengbin\Hyperf\Common\Commands\Model\ModelCommand::class, ]); diff --git a/config/autoload/errorCode.php b/config/autoload/errorCode.php index e4708e6..0ad28f7 100644 --- a/config/autoload/errorCode.php +++ b/config/autoload/errorCode.php @@ -3,16 +3,13 @@ return [ // 错误码文件 目录 'path' => [ - BASE_PATH . '/vendor/lengbin/hyperf-common/src/Error', - BASE_PATH . '/app/Constant/Errors', + BASE_PATH . '/vendor/lengbin/hyperf-common/src/Constants/Errors', + BASE_PATH . '/app/Constants/Errors', ], // 合并生成 类 文件名称 'classname' => 'Error', // 合并生成 类 命名空间 - 'classNamespace' => 'App\\Constant', + 'classNamespace' => 'App\\Constants', // 合并生成 类 文件输出目录 - 'output' => BASE_PATH . '/app/Constant', - // 多语言 文件名称 - 'translate_enable' => false, - 'translate' => 'errorCode', + 'output' => BASE_PATH . '/app/Constants', ]; diff --git a/config/autoload/exceptions.php b/config/autoload/exceptions.php index dc6f7ef..9e2983f 100644 --- a/config/autoload/exceptions.php +++ b/config/autoload/exceptions.php @@ -9,11 +9,15 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + +use Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler; +use Lengbin\Hyperf\Common\Exceptions\Handler\AppExceptionHandler; + return [ 'handler' => [ 'http' => [ - Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler::class, - App\Kernel\Exceptions\Handler\AppExceptionHandler::class, + HttpExceptionHandler::class, + AppExceptionHandler::class ], ], ]; diff --git a/config/autoload/logger.php b/config/autoload/logger.php index 53a263c..b5734d8 100644 --- a/config/autoload/logger.php +++ b/config/autoload/logger.php @@ -10,7 +10,7 @@ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ -use App\Kernel\Log\AppendRequestIdProcessor; +use Lengbin\Hyperf\Common\Logs\AppendRequestIdProcessor; return [ 'default' => [ diff --git a/config/autoload/middlewares.php b/config/autoload/middlewares.php index cfb801c..de7c9fa 100644 --- a/config/autoload/middlewares.php +++ b/config/autoload/middlewares.php @@ -10,10 +10,10 @@ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ -use App\Kernel\Middleware\CorsMiddleware; -use App\Kernel\Middleware\DebugLogMiddleware; use App\Middleware\TokenMiddleware; use Hyperf\Apidog\Middleware\ApiValidationMiddleware; +use Lengbin\Hyperf\Common\Middlewares\CorsMiddleware; +use Lengbin\Hyperf\Common\Middlewares\DebugLogMiddleware; return [ 'http' => [ From 92f38803c0976d0d279a42a45055415a1208348d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Wed, 7 Jun 2023 21:15:39 +0800 Subject: [PATCH 81/82] Create data.js --- data.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 data.js diff --git a/data.js b/data.js new file mode 100644 index 0000000..6b62a17 --- /dev/null +++ b/data.js @@ -0,0 +1,8 @@ +getjson({ + 'guihua': 'http:aa.6709ss.com', + 'juhua': 'http:bb.6709ss.com', + 'lanhua': 'http:cc.6709ss.com', + 'meihua': 'http:dd.6709ss.com', + 'mudan': 'http:ee.6709ss.com', + 'taohua': 'http:ff.6709ss.com', +}) From ebbcefa6291b33505b3b1d9d2e54d8c5fdc6949e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=96=8C?= Date: Wed, 7 Jun 2023 21:19:43 +0800 Subject: [PATCH 82/82] Delete data.js --- data.js | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 data.js diff --git a/data.js b/data.js deleted file mode 100644 index 6b62a17..0000000 --- a/data.js +++ /dev/null @@ -1,8 +0,0 @@ -getjson({ - 'guihua': 'http:aa.6709ss.com', - 'juhua': 'http:bb.6709ss.com', - 'lanhua': 'http:cc.6709ss.com', - 'meihua': 'http:dd.6709ss.com', - 'mudan': 'http:ee.6709ss.com', - 'taohua': 'http:ff.6709ss.com', -})