From e41db946dd4389183095a017f89d30cccf76495f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Fri, 14 May 2021 15:17:42 +0800 Subject: [PATCH] ComposerUpdate --- vendor/composer/InstalledVersions.php | 6 +- vendor/composer/installed.json | 8 +- vendor/composer/installed.php | 6 +- vendor/services.php | 2 +- .../zoujingli/think-library/src/Command.php | 61 +++++++++------ .../think-library/src/Controller.php | 33 ++++----- vendor/zoujingli/think-library/src/Helper.php | 2 +- .../zoujingli/think-library/src/Library.php | 3 +- vendor/zoujingli/think-library/src/Queue.php | 19 +---- .../zoujingli/think-library/src/Storage.php | 21 +++--- .../think-library/src/command/Database.php | 8 +- .../think-library/src/command/Queue.php | 51 +++++++------ vendor/zoujingli/think-library/src/common.php | 35 +++++---- .../think-library/src/extend/CodeExtend.php | 4 +- .../think-library/src/extend/DataExtend.php | 9 ++- .../think-library/src/extend/HttpExtend.php | 2 +- .../src/extend/JsonRpcServer.php | 15 ++-- .../think-library/src/helper/DeleteHelper.php | 12 +-- .../think-library/src/helper/FormHelper.php | 12 ++- .../think-library/src/helper/PageHelper.php | 29 ++++---- .../think-library/src/helper/QueryHelper.php | 34 +++++---- .../think-library/src/helper/SaveHelper.php | 15 ++-- .../think-library/src/helper/TokenHelper.php | 2 +- .../src/helper/ValidateHelper.php | 2 +- .../think-library/src/multiple/BuildUrl.php | 5 +- .../src/multiple/command/Clear.php | 6 +- .../src/service/AdminService.php | 14 ++-- .../src/service/InterfaceService.php | 31 ++++---- .../think-library/src/service/MenuService.php | 16 ++-- .../src/service/MessageService.php | 25 ++++--- .../src/service/ModuleService.php | 2 + .../think-library/src/service/NodeService.php | 9 ++- .../src/service/ProcessService.php | 55 ++++++-------- .../src/service/QueueService.php | 70 +++++++++--------- .../src/service/SystemService.php | 74 +++++++++++-------- .../src/service/TokenService.php | 13 ++-- .../src/service/ZtSmsService.php | 17 +++-- .../src/storage/AliossStorage.php | 26 ++++--- .../src/storage/LocalStorage.php | 20 +++-- .../src/storage/QiniuStorage.php | 40 +++++----- .../src/storage/TxcosStorage.php | 26 ++++--- 41 files changed, 460 insertions(+), 380 deletions(-) diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index 484506a15..d408ebc8d 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -32,7 +32,7 @@ private static $installed = array ( 'aliases' => array ( ), - 'reference' => '2c3c98457bfabfff63dacfc826d66f0847c04145', + 'reference' => 'c4a746789ced7470423ee1d2c8b9429cf13c8199', 'name' => 'zoujingli/thinkadmin', ), 'versions' => @@ -171,7 +171,7 @@ private static $installed = array ( array ( 0 => '9999999-dev', ), - 'reference' => '066e557c25c299f7df8c36f0ea602473a4229156', + 'reference' => '3b7302e778953ef7f5d1d7f403fd8cb18aa6b047', ), 'zoujingli/thinkadmin' => array ( @@ -180,7 +180,7 @@ private static $installed = array ( 'aliases' => array ( ), - 'reference' => '2c3c98457bfabfff63dacfc826d66f0847c04145', + 'reference' => 'c4a746789ced7470423ee1d2c8b9429cf13c8199', ), 'zoujingli/wechat-developer' => array ( diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index fc539d121..3561b143f 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -849,12 +849,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "066e557c25c299f7df8c36f0ea602473a4229156" + "reference": "3b7302e778953ef7f5d1d7f403fd8cb18aa6b047" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/066e557c25c299f7df8c36f0ea602473a4229156", - "reference": "066e557c25c299f7df8c36f0ea602473a4229156", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/3b7302e778953ef7f5d1d7f403fd8cb18aa6b047", + "reference": "3b7302e778953ef7f5d1d7f403fd8cb18aa6b047", "shasum": "", "mirrors": [ { @@ -871,7 +871,7 @@ "ext-mbstring": "*", "topthink/framework": "^6.0" }, - "time": "2021-05-13T08:49:03+00:00", + "time": "2021-05-14T07:14:17+00:00", "default-branch": true, "type": "library", "extra": { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 27592a01e..6e7dc7ec5 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -6,7 +6,7 @@ 'aliases' => array ( ), - 'reference' => '2c3c98457bfabfff63dacfc826d66f0847c04145', + 'reference' => 'c4a746789ced7470423ee1d2c8b9429cf13c8199', 'name' => 'zoujingli/thinkadmin', ), 'versions' => @@ -145,7 +145,7 @@ array ( 0 => '9999999-dev', ), - 'reference' => '066e557c25c299f7df8c36f0ea602473a4229156', + 'reference' => '3b7302e778953ef7f5d1d7f403fd8cb18aa6b047', ), 'zoujingli/thinkadmin' => array ( @@ -154,7 +154,7 @@ 'aliases' => array ( ), - 'reference' => '2c3c98457bfabfff63dacfc826d66f0847c04145', + 'reference' => 'c4a746789ced7470423ee1d2c8b9429cf13c8199', ), 'zoujingli/wechat-developer' => array ( diff --git a/vendor/services.php b/vendor/services.php index c9965b1b0..d787e76a3 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\admin\\Library', diff --git a/vendor/zoujingli/think-library/src/Command.php b/vendor/zoujingli/think-library/src/Command.php index f2225bcb1..8bb249f1c 100644 --- a/vendor/zoujingli/think-library/src/Command.php +++ b/vendor/zoujingli/think-library/src/Command.php @@ -19,16 +19,18 @@ namespace think\admin; use think\admin\service\ProcessService; use think\admin\service\QueueService; -use think\console\Command as ThinkCommand; use think\console\Input; use think\console\Output; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; /** * 自定义指令基类 * Class Command * @package think\admin */ -abstract class Command extends ThinkCommand +abstract class Command extends \think\console\Command { /** * 任务控制服务 @@ -48,9 +50,9 @@ abstract class Command extends ThinkCommand * @param Output $output * @return static * @throws Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ protected function initialize(Input $input, Output $output): Command { @@ -67,23 +69,6 @@ abstract class Command extends ThinkCommand return $this; } - /** - * 设置进度消息并继续执行 - * @param null|string $message 进度消息 - * @param null|float $progress 进度数值 - * @param integer $backline 回退行数 - * @return static - */ - protected function setQueueProgress(?string $message = null, $progress = null, $backline = 0): Command - { - if (defined('WorkQueueCode')) { - $this->queue->progress(2, $message, $progress, $backline); - } elseif (is_string($message)) { - $this->output->writeln($message); - } - return $this; - } - /** * 设置失败消息并结束进程 * @param string $message 消息内容 @@ -116,4 +101,36 @@ abstract class Command extends ThinkCommand return $this; } + /** + * 设置进度消息并继续执行 + * @param null|string $message 进度消息 + * @param null|string $progress 进度数值 + * @param integer $backline 回退行数 + * @return static + */ + protected function setQueueProgress(?string $message = null, ?string $progress = null, int $backline = 0): Command + { + if (defined('WorkQueueCode')) { + $this->queue->progress(2, $message, $progress, $backline); + } elseif (is_string($message)) { + $this->output->writeln($message); + } + return $this; + } + + /** + * 更新任务进度 + * @param integer $total 记录总和 + * @param integer $count 当前记录 + * @param string $message 文字描述 + * @param integer $backline 回退行数 + * @return static + */ + public function setQueueMessage(int $total, int $count, string $message = '', int $backline = 0): Command + { + $total = $total < 1 ? 1 : $total; + $prefix = str_pad("{$count}", strlen("{$total}"), '0', STR_PAD_LEFT); + return $this->setQueueProgress("[{$prefix}/{$total}] {$message}", sprintf("%.2f", $count / $total * 100), $backline); + } + } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/Controller.php b/vendor/zoujingli/think-library/src/Controller.php index e5c3ca330..f2b88dd34 100644 --- a/vendor/zoujingli/think-library/src/Controller.php +++ b/vendor/zoujingli/think-library/src/Controller.php @@ -17,6 +17,7 @@ declare (strict_types=1); namespace think\admin; +use stdClass; use think\admin\helper\DeleteHelper; use think\admin\helper\FormHelper; use think\admin\helper\PageHelper; @@ -38,7 +39,7 @@ use think\Request; * Class Controller * @package think\admin */ -abstract class Controller extends \stdClass +abstract class Controller extends stdClass { /** @@ -53,12 +54,6 @@ abstract class Controller extends \stdClass */ public $request; - /** - * 控制器中间键 - * @var array - */ - protected $middleware = []; - /** * 表单CSRF验证状态 * @var boolean @@ -66,7 +61,7 @@ abstract class Controller extends \stdClass public $csrf_state = false; /** - * 表单CSRF验证失败提示 + * 表单CSRF验证消息 * @var string */ public $csrf_message; @@ -98,11 +93,11 @@ abstract class Controller extends \stdClass * 返回失败的操作 * @param mixed $info 消息内容 * @param mixed $data 返回数据 - * @param integer $code 返回代码 + * @param mixed $code 返回代码 */ public function error($info, $data = '{-null-}', $code = 0): void { - if ($data === '{-null-}') $data = new \stdClass(); + if ($data === '{-null-}') $data = new stdClass(); throw new HttpResponseException(json([ 'code' => $code, 'info' => $info, 'data' => $data, ])); @@ -112,14 +107,14 @@ abstract class Controller extends \stdClass * 返回成功的操作 * @param mixed $info 消息内容 * @param mixed $data 返回数据 - * @param integer $code 返回代码 + * @param mixed $code 返回代码 */ public function success($info, $data = '{-null-}', $code = 1): void { if ($this->csrf_state) { TokenHelper::instance()->clear(); } - if ($data === '{-null-}') $data = new \stdClass(); + if ($data === '{-null-}') $data = new stdClass(); throw new HttpResponseException(json([ 'code' => $code, 'info' => $info, 'data' => $data, ])); @@ -130,7 +125,7 @@ abstract class Controller extends \stdClass * @param string $url 跳转链接 * @param integer $code 跳转代码 */ - public function redirect(string $url, $code = 301): void + public function redirect(string $url, int $code = 301): void { throw new HttpResponseException(redirect($url, $code)); } @@ -157,7 +152,7 @@ abstract class Controller extends \stdClass * @param mixed $value 变量的值 * @return $this */ - public function assign($name, $value = '') + public function assign($name, $value = ''): Controller { if (is_string($name)) { $this->$name = $value; @@ -211,7 +206,7 @@ abstract class Controller extends \stdClass * @throws DbException * @throws ModelNotFoundException */ - protected function _page($dbQuery, bool $page = true, bool $display = true, $total = false, int $limit = 0, string $template = '') + protected function _page($dbQuery, bool $page = true, bool $display = true, $total = false, int $limit = 0, string $template = ''): array { return PageHelper::instance()->init($dbQuery, $page, $display, $total, $limit, $template); } @@ -239,7 +234,7 @@ abstract class Controller extends \stdClass * @param string|array $type 输入方式 ( post. 或 get. ) * @return array */ - protected function _vali(array $rules, $type = '') + protected function _vali(array $rules, $type = ''): array { return ValidateHelper::instance()->init($rules, $type); } @@ -253,7 +248,7 @@ abstract class Controller extends \stdClass * @return boolean * @throws DbException */ - protected function _save($dbQuery, array $data = [], string $field = '', array $where = []) + protected function _save($dbQuery, array $data = [], string $field = '', array $where = []): bool { return SaveHelper::instance()->init($dbQuery, $data, $field, $where); } @@ -266,7 +261,7 @@ abstract class Controller extends \stdClass * @return boolean|null * @throws DbException */ - protected function _delete($dbQuery, string $field = '', array $where = []) + protected function _delete($dbQuery, string $field = '', array $where = []): ?bool { return DeleteHelper::instance()->init($dbQuery, $field, $where); } @@ -276,7 +271,7 @@ abstract class Controller extends \stdClass * @param boolean $return 是否返回结果 * @return boolean */ - protected function _applyFormToken(bool $return = false) + protected function _applyFormToken(bool $return = false): bool { return TokenHelper::instance()->init($return); } diff --git a/vendor/zoujingli/think-library/src/Helper.php b/vendor/zoujingli/think-library/src/Helper.php index 0e0859789..21c7051f8 100644 --- a/vendor/zoujingli/think-library/src/Helper.php +++ b/vendor/zoujingli/think-library/src/Helper.php @@ -37,7 +37,7 @@ abstract class Helper /** * 数据库实例 - * @var Query + * @var Db|Query */ public $query; diff --git a/vendor/zoujingli/think-library/src/Library.php b/vendor/zoujingli/think-library/src/Library.php index ce320a2f1..b26e6dca2 100644 --- a/vendor/zoujingli/think-library/src/Library.php +++ b/vendor/zoujingli/think-library/src/Library.php @@ -15,6 +15,7 @@ namespace think\admin; +use Closure; use think\admin\command\Database; use think\admin\command\Install; use think\admin\command\Queue; @@ -95,7 +96,7 @@ class Library extends Service $this->app->middleware->add(LoadLangPack::class); } // 注册访问处理中间键 - $this->app->middleware->add(function (Request $request, \Closure $next) { + $this->app->middleware->add(function (Request $request, Closure $next) { $header = []; if (($origin = $request->header('origin', '*')) !== '*') { $header['Access-Control-Allow-Origin'] = $origin; diff --git a/vendor/zoujingli/think-library/src/Queue.php b/vendor/zoujingli/think-library/src/Queue.php index d40553695..8a04a350e 100644 --- a/vendor/zoujingli/think-library/src/Queue.php +++ b/vendor/zoujingli/think-library/src/Queue.php @@ -1,18 +1,5 @@ queue->progress(2, $message, $progress, $backline); return $this; diff --git a/vendor/zoujingli/think-library/src/Storage.php b/vendor/zoujingli/think-library/src/Storage.php index c499cc9c8..fa2a1499e 100644 --- a/vendor/zoujingli/think-library/src/Storage.php +++ b/vendor/zoujingli/think-library/src/Storage.php @@ -20,6 +20,9 @@ namespace think\admin; use think\admin\storage\LocalStorage; use think\App; use think\Container; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; /** * 文件存储引擎管理 @@ -63,9 +66,9 @@ abstract class Storage /** * Storage constructor. * @param App $app - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function __construct(App $app) { @@ -85,9 +88,9 @@ abstract class Storage * @param array $arguments 调用参数 * @return mixed * @throws Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public static function __callStatic(string $method, array $arguments) { @@ -103,9 +106,9 @@ abstract class Storage * @param null|string $name 驱动名称 * @return static * @throws Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public static function instance(?string $name = null) { diff --git a/vendor/zoujingli/think-library/src/command/Database.php b/vendor/zoujingli/think-library/src/command/Database.php index ac6b39921..7b2ee3e0c 100644 --- a/vendor/zoujingli/think-library/src/command/Database.php +++ b/vendor/zoujingli/think-library/src/command/Database.php @@ -59,9 +59,9 @@ class Database extends Command */ protected function _repair(): void { - $this->setQueueProgress("正在获取需要修复的数据表", 0); + $this->setQueueProgress("正在获取需要修复的数据表", '0'); [$tables, $total, $count] = SystemService::instance()->getTables(); - $this->setQueueProgress("总共需要修复 {$total} 张数据表", 0); + $this->setQueueProgress("总共需要修复 {$total} 张数据表", '0'); foreach ($tables as $table) { $this->queue->message($total, ++$count, "正在修复数据表 {$table}"); $this->app->db->query("REPAIR TABLE `{$table}`"); @@ -76,9 +76,9 @@ class Database extends Command */ protected function _optimize(): void { - $this->setQueueProgress("正在获取需要优化的数据表", 0); + $this->setQueueProgress("正在获取需要优化的数据表", '0'); [$tables, $total, $count] = SystemService::instance()->getTables(); - $this->setQueueProgress("总共需要优化 {$total} 张数据表", 0); + $this->setQueueProgress("总共需要优化 {$total} 张数据表", '0'); foreach ($tables as $table) { $this->queue->message($total, ++$count, "正在优化数据表 {$table}"); $this->app->db->query("OPTIMIZE TABLE `{$table}`"); diff --git a/vendor/zoujingli/think-library/src/command/Queue.php b/vendor/zoujingli/think-library/src/command/Queue.php index a4aec6678..38716eaa7 100644 --- a/vendor/zoujingli/think-library/src/command/Queue.php +++ b/vendor/zoujingli/think-library/src/command/Queue.php @@ -17,13 +17,20 @@ declare (strict_types=1); namespace think\admin\command; +use Error; +use Exception; use Psr\Log\NullLogger; use think\admin\Command; +use think\admin\service\QueueService; use think\Collection; use think\console\Input; use think\console\input\Argument; use think\console\input\Option; use think\console\Output; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; +use Throwable; /** * 异步任务管理指令 @@ -128,9 +135,9 @@ class Queue extends Command /** * 停止所有任务 - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ protected function stopAction() { @@ -144,9 +151,9 @@ class Queue extends Command /** * 启动后台任务 - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ protected function startAction() { @@ -166,9 +173,9 @@ class Queue extends Command /** * 查询所有任务 - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ protected function queryAction() { @@ -182,7 +189,7 @@ class Queue extends Command /** * 清理所有任务 - * @throws \Exception + * @throws Exception */ protected function cleanAction() { @@ -211,9 +218,9 @@ class Queue extends Command /** * 查询兼听状态 - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ protected function statusAction() { @@ -226,7 +233,7 @@ class Queue extends Command /** * 立即监听任务 - * @throws \think\db\exception\DbException + * @throws DbException */ protected function listenAction() { @@ -247,7 +254,7 @@ class Queue extends Command $this->process->thinkCreate($args); $this->output->writeln("># Created new process -> [{$vo['code']}] {$vo['title']}"); } - } catch (\Exception $exception) { + } catch (Exception $exception) { $this->app->db->name($this->table)->where(['code' => $vo['code']])->update([ 'status' => 4, 'outer_time' => time(), 'exec_desc' => $exception->getMessage(), ]); @@ -259,7 +266,7 @@ class Queue extends Command /** * 执行指定的任务内容 - * @throws \think\db\exception\DbException + * @throws DbException */ protected function doRunAction() { @@ -279,7 +286,7 @@ class Queue extends Command 'enter_time' => microtime(true), 'attempts' => $this->app->db->raw('attempts+1'), 'outer_time' => 0, 'exec_pid' => getmypid(), 'exec_desc' => '', 'status' => 2, ]); - $this->queue->progress(2, '>>> 任务处理开始 <<<', 0); + $this->queue->progress(2, '>>> 任务处理开始 <<<', '0'); // 执行任务内容 defined('WorkQueueCall') or define('WorkQueueCall', true); defined('WorkQueueCode') or define('WorkQueueCode', $this->code); @@ -288,7 +295,7 @@ class Queue extends Command $class = $this->app->make($command, [], true); if ($class instanceof \think\admin\Queue) { $this->updateQueue(3, $class->initialize($this->queue)->execute($this->queue->data) ?: ''); - } elseif ($class instanceof \think\admin\service\QueueService) { + } elseif ($class instanceof QueueService) { $this->updateQueue(3, $class->initialize($this->queue->code)->execute($this->queue->data) ?: ''); } else { throw new \think\admin\Exception("自定义 {$command} 未继承 Queue 或 QueueService"); @@ -299,7 +306,7 @@ class Queue extends Command $this->updateQueue(3, $this->app->console->call(array_shift($attr), $attr)->fetch(), false); } } - } catch (\Exception | \Throwable | \Error $exception) { + } catch (Exception | Throwable | Error $exception) { $code = $exception->getCode(); if (intval($code) !== 3) $code = 4; $this->updateQueue($code, $exception->getMessage()); @@ -311,7 +318,7 @@ class Queue extends Command * @param integer $status 任务状态 * @param string $message 消息内容 * @param boolean $isSplit 是否分隔 - * @throws \think\db\exception\DbException + * @throws DbException */ protected function updateQueue(int $status, string $message, bool $isSplit = true) { @@ -327,7 +334,7 @@ class Queue extends Command $this->queue->progress($status, ">>> {$desc[0]} <<<"); } if ($status == 3) { - $this->queue->progress($status, '>>> 任务处理完成 <<<', 100); + $this->queue->progress($status, '>>> 任务处理完成 <<<', '100.00'); } elseif ($status == 4) { $this->queue->progress($status, '>>> 任务处理失败 <<<'); } @@ -335,7 +342,7 @@ class Queue extends Command if (isset($this->queue->record['loops_time']) && $this->queue->record['loops_time'] > 0) { try { $this->queue->initialize($this->code)->reset($this->queue->record['loops_time']); - } catch (\Exception | \Throwable | \Error $exception) { + } catch (Exception | Throwable | Error $exception) { $this->app->log->error("Queue {$this->queue->record['code']} Loops Failed. {$exception->getMessage()}"); } } diff --git a/vendor/zoujingli/think-library/src/common.php b/vendor/zoujingli/think-library/src/common.php index 2757bbdd4..00105133d 100644 --- a/vendor/zoujingli/think-library/src/common.php +++ b/vendor/zoujingli/think-library/src/common.php @@ -19,6 +19,9 @@ use think\admin\service\QueueService; use think\admin\service\SystemService; use think\admin\service\TokenService; use think\admin\Storage; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; use think\db\Query; if (!function_exists('p')) { @@ -29,7 +32,7 @@ if (!function_exists('p')) { * @param null|string $file 保存文件名称 * @return false|int */ - function p($data, $new = false, $file = null) + function p($data, bool $new = false, ?string $file = null) { return SystemService::instance()->putDebug($data, $new, $file); } @@ -66,11 +69,11 @@ if (!function_exists('sysconf')) { * @param string $name 参数名称 * @param mixed $value 参数内容 * @return mixed - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ - function sysconf($name = '', $value = null) + function sysconf(string $name = '', $value = null) { if (is_null($value) && is_string($name)) { return SystemService::instance()->get($name); @@ -85,9 +88,9 @@ if (!function_exists('sysdata')) { * @param string $name 数据名称 * @param mixed $value 数据内容 * @return mixed - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ function sysdata(string $name, $value = null) { @@ -109,9 +112,9 @@ if (!function_exists('sysqueue')) { * @param integer $loops 循环等待时间 * @return string * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ function sysqueue(string $title, string $command, int $later = 0, array $data = [], int $rscript = 1, int $loops = 0): string { @@ -229,7 +232,7 @@ if (!function_exists('debase64url')) { */ function debase64url(string $string): string { - return base64_decode(str_pad(strtr($string, '-_', '+/'), strlen($string) % 4, '=', STR_PAD_RIGHT)); + return base64_decode(str_pad(strtr($string, '-_', '+/'), strlen($string) % 4, '=')); } } if (!function_exists('http_get')) { @@ -266,9 +269,9 @@ if (!function_exists('data_save')) { * @param string $key 条件主键限制 * @param array $where 其它的where条件 * @return boolean|integer - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ function data_save($dbQuery, array $data, string $key = 'id', array $where = []) { @@ -299,7 +302,7 @@ if (!function_exists('format_datetime')) { * @param string $format 输出格式 * @return string */ - function format_datetime($datetime, $format = 'Y年m月d日 H:i:s'): string + function format_datetime($datetime, string $format = 'Y年m月d日 H:i:s'): string { if (empty($datetime)) return '-'; if (is_numeric($datetime)) { diff --git a/vendor/zoujingli/think-library/src/extend/CodeExtend.php b/vendor/zoujingli/think-library/src/extend/CodeExtend.php index d27d479f9..1356f0a65 100644 --- a/vendor/zoujingli/think-library/src/extend/CodeExtend.php +++ b/vendor/zoujingli/think-library/src/extend/CodeExtend.php @@ -35,8 +35,8 @@ class CodeExtend { $numbs = '0123456789'; $chars = 'abcdefghijklmnopqrstuvwxyz'; - if (intval($type) === 1) $chars = $numbs; - if (intval($type) === 3) $chars = "{$numbs}{$chars}"; + if ($type === 1) $chars = $numbs; + if ($type === 3) $chars = "{$numbs}{$chars}"; $code = $prefix . $chars[rand(1, strlen($chars) - 1)]; while (strlen($code) < $size) $code .= $chars[rand(0, strlen($chars) - 1)]; return $code; diff --git a/vendor/zoujingli/think-library/src/extend/DataExtend.php b/vendor/zoujingli/think-library/src/extend/DataExtend.php index 1bea74a7e..9dd7eb943 100644 --- a/vendor/zoujingli/think-library/src/extend/DataExtend.php +++ b/vendor/zoujingli/think-library/src/extend/DataExtend.php @@ -35,9 +35,12 @@ class DataExtend */ public static function arr2tree(array $list, string $cid = 'id', string $pid = 'pid', string $sub = 'sub'): array { - [$tree, $tmp] = [[], array_combine(array_column($list, $cid), array_values($list))]; - foreach ($list as $vo) isset($vo[$pid]) && isset($tmp[$vo[$pid]]) ? $tmp[$vo[$pid]][$sub][] = &$tmp[$vo[$cid]] : $tree[] = &$tmp[$vo[$cid]]; - unset($tmp, $list); + [$tree, $temp] = [[], array_combine(array_column($list, $cid), array_values($list))]; + foreach ($list as $vo) if (isset($vo[$pid]) && isset($temp[$vo[$pid]])) { + $temp[$vo[$pid]][$sub][] = &$temp[$vo[$cid]]; + } else { + $tree[] = &$temp[$vo[$cid]]; + } return $tree; } diff --git a/vendor/zoujingli/think-library/src/extend/HttpExtend.php b/vendor/zoujingli/think-library/src/extend/HttpExtend.php index cf73e2bd0..b31838d7e 100644 --- a/vendor/zoujingli/think-library/src/extend/HttpExtend.php +++ b/vendor/zoujingli/think-library/src/extend/HttpExtend.php @@ -162,6 +162,6 @@ class HttpExtend "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11", ]; - return $agents[array_rand($agents, 1)]; + return $agents[array_rand($agents)]; } } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/extend/JsonRpcServer.php b/vendor/zoujingli/think-library/src/extend/JsonRpcServer.php index 60cfad09c..be799519b 100644 --- a/vendor/zoujingli/think-library/src/extend/JsonRpcServer.php +++ b/vendor/zoujingli/think-library/src/extend/JsonRpcServer.php @@ -17,6 +17,9 @@ declare (strict_types=1); namespace think\admin\extend; +use Exception; +use ReflectionClass; +use ReflectionMethod; use think\App; use think\Container; use think\exception\HttpResponseException; @@ -64,10 +67,10 @@ class JsonRpcServer $this->printMethod($object); } else { // Reads the input data - $request = json_decode(file_get_contents('php://input'), true); + $request = json_decode(file_get_contents('php://input'), true) ?: []; if (empty($request)) { $error = ['code' => '-32700', 'message' => '语法解析错误', 'meaning' => '服务端接收到无效的JSON']; - $response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => null, 'error' => $error]; + $response = ['jsonrpc' => '2.0', 'id' => '0', 'result' => null, 'error' => $error]; } elseif (!isset($request['id']) || !isset($request['method']) || !isset($request['params'])) { $error = ['code' => '-32600', 'message' => '无效的请求', 'meaning' => '发送的JSON不是一个有效的请求对象']; $response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => null, 'error' => $error]; @@ -80,7 +83,7 @@ class JsonRpcServer $error = ['code' => '-32601', 'message' => '找不到方法', 'meaning' => '该方法不存在或无效']; $response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => null, 'error' => $error]; } - } catch (\Exception $exception) { + } catch (Exception $exception) { $error = ['code' => $exception->getCode(), 'message' => $exception->getMessage()]; $response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => null, 'error' => $error]; } @@ -96,9 +99,9 @@ class JsonRpcServer protected function printMethod($object) { try { - $object = new \ReflectionClass($object); + $object = new ReflectionClass($object); echo "

" . $object->getName() . "


"; - foreach ($object->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { + foreach ($object->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { $params = []; foreach ($method->getParameters() as $parameter) { $type = $parameter->getType(); @@ -108,7 +111,7 @@ class JsonRpcServer echo '
' . nl2br($method->getDocComment() ?: '') . '
'; echo "
{$object->getShortName()}::{$method->getName()}({$params})

"; } - } catch (\Exception $exception) { + } catch (Exception $exception) { echo "

[{$exception->getCode()}] {$exception->getMessage()}

"; } } diff --git a/vendor/zoujingli/think-library/src/helper/DeleteHelper.php b/vendor/zoujingli/think-library/src/helper/DeleteHelper.php index cf69557fa..5ae0498bd 100644 --- a/vendor/zoujingli/think-library/src/helper/DeleteHelper.php +++ b/vendor/zoujingli/think-library/src/helper/DeleteHelper.php @@ -18,6 +18,8 @@ declare (strict_types=1); namespace think\admin\helper; use think\admin\Helper; +use think\Db; +use think\db\exception\DbException; use think\db\Query; /** @@ -29,17 +31,17 @@ class DeleteHelper extends Helper { /** * 逻辑器初始化 - * @param string|Query $dbQuery + * @param string|Db|Query $dbQuery * @param string $field 操作数据主键 * @param array $where 额外更新条件 - * @return boolean|null|void - * @throws \think\db\exception\DbException + * @return boolean|null + * @throws DbException */ - public function init($dbQuery, string $field = '', array $where = []) + public function init($dbQuery, string $field = '', array $where = []): ?bool { $query = $this->buildQuery($dbQuery); $field = $field ?: ($query->getPk() ?: 'id'); - $value = $this->app->request->post($field, null); + $value = $this->app->request->post($field); // 查询限制处理 if (!empty($where)) $query->where($where); if (!isset($where[$field]) && is_string($value)) { diff --git a/vendor/zoujingli/think-library/src/helper/FormHelper.php b/vendor/zoujingli/think-library/src/helper/FormHelper.php index d6d8c12e7..0d1139c60 100644 --- a/vendor/zoujingli/think-library/src/helper/FormHelper.php +++ b/vendor/zoujingli/think-library/src/helper/FormHelper.php @@ -18,6 +18,10 @@ declare (strict_types=1); namespace think\admin\helper; use think\admin\Helper; +use think\Db; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; use think\db\Query; /** @@ -30,15 +34,15 @@ class FormHelper extends Helper /** * 逻辑器初始化 - * @param string|Query $dbQuery + * @param string|Db|Query $dbQuery * @param string $template 模板名称 * @param string $field 指定数据主键 * @param array $where 额外更新条件 * @param array $data 表单扩展数据 * @return array|boolean|mixed|void - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function init($dbQuery, string $template = '', string $field = '', array $where = [], array $data = []) { diff --git a/vendor/zoujingli/think-library/src/helper/PageHelper.php b/vendor/zoujingli/think-library/src/helper/PageHelper.php index 8d0579865..ad90d75b3 100644 --- a/vendor/zoujingli/think-library/src/helper/PageHelper.php +++ b/vendor/zoujingli/think-library/src/helper/PageHelper.php @@ -18,6 +18,9 @@ declare (strict_types=1); namespace think\admin\helper; use think\admin\Helper; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; use think\db\Query; /** @@ -36,12 +39,12 @@ class PageHelper extends Helper * @param boolean|integer $total 集合分页记录数 * @param integer $limit 集合每页记录数 * @param string $template 模板文件名称 - * @return array|mixed|void - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @return array + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ - public function init($dbQuery, bool $page = true, bool $display = true, $total = false, int $limit = 0, string $template = '') + public function init($dbQuery, bool $page = true, bool $display = true, $total = false, int $limit = 0, string $template = ''): array { $this->query = $this->buildQuery($dbQuery); // 数据列表排序自动处理 @@ -50,9 +53,7 @@ class PageHelper extends Helper if (!$this->query->getOptions('order')) $this->_orderAction(); // 列表分页及结果集处理 if ($page) { - if ($limit > 0) { - $limit = intval($limit); - } else { + if (empty($limit)) { $limit = $this->app->request->get('limit', $this->app->cookie->get('limit', 20)); if (intval($this->app->request->get('not_cache_limit', 0)) < 1) { $this->app->cookie->set('limit', ($limit = intval($limit >= 10 ? $limit : 20)) . ''); @@ -60,7 +61,7 @@ class PageHelper extends Helper } [$options, $query] = ['', $this->app->request->get()]; $pager = $this->query->paginate(['list_rows' => $limit, 'query' => $query], $total); - foreach ([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200] as $num) { + foreach ([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 300, 400, 500, 600] as $num) { [$query['limit'], $query['page'], $selects] = [$num, 1, $limit === $num ? 'selected' : '']; if (stripos($this->app->request->get('spm', '-'), 'm-') === 0) { $url = sysuri('admin/index/index') . '#' . $this->app->request->baseUrl() . '?' . urldecode(http_build_query($query)); @@ -77,9 +78,10 @@ class PageHelper extends Helper } else { $this->class->assign('pagehtml', $pagehtml); } - $result = ['page' => ['limit' => intval($limit), 'total' => intval($pager->total()), 'pages' => intval($pager->lastPage()), 'current' => intval($pager->currentPage())], 'list' => $pager->items()]; + $result = ['page' => ['limit' => $limit, 'total' => $pager->total(), 'pages' => $pager->lastPage(), 'current' => $pager->currentPage()], 'list' => $pager->items()]; } else { - $result = ['list' => $this->query->select()->toArray()]; + $pager = $this->query->select(); + $result = ['page' => ['limit' => $pager->count(), 'total' => 1, 'pages' => 1, 'current' => 1], 'list' => $pager->toArray()]; } if (false !== $this->class->callback('_page_filter', $result['list']) && $display) { if ($this->app->request->get('output') === 'json') { @@ -87,15 +89,14 @@ class PageHelper extends Helper } else { $this->class->fetch($template, $result); } - } else { - return $result; } + return $result; } /** * 执行列表排序操作 * POST 提交 {action:sort,PK:$PK,SORT:$SORT} - * @throws \think\db\exception\DbException + * @throws DbException */ private function _sortAction() { diff --git a/vendor/zoujingli/think-library/src/helper/QueryHelper.php b/vendor/zoujingli/think-library/src/helper/QueryHelper.php index 0e9934aed..523979821 100644 --- a/vendor/zoujingli/think-library/src/helper/QueryHelper.php +++ b/vendor/zoujingli/think-library/src/helper/QueryHelper.php @@ -18,6 +18,10 @@ declare (strict_types=1); namespace think\admin\helper; use think\admin\Helper; +use think\Db; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; use think\db\Query; /** @@ -25,7 +29,7 @@ use think\db\Query; * Class QueryHelper * @package think\admin\helper * @see \think\db\Query - * @mixin \think\db\Query + * @mixin Query */ class QueryHelper extends Helper { @@ -37,7 +41,7 @@ class QueryHelper extends Helper /** * 获取当前Db操作对象 - * @return \think\db\Query + * @return Db|Query */ public function db() { @@ -46,14 +50,14 @@ class QueryHelper extends Helper /** * 逻辑器初始化 - * @param string|Query $dbQuery + * @param string|Query|Db $dbQuery * @param array|string|null $input 输入数据 * @return $this */ public function init($dbQuery, $input = null): QueryHelper { $this->query = $this->buildQuery($dbQuery); - $this->input = $this->_getInputData($input); + $this->input = $this->getInputData($input); return $this; } @@ -67,7 +71,7 @@ class QueryHelper extends Helper */ public function like($fields, string $split = '', $input = null, string $alias = '#'): QueryHelper { - $data = $this->_getInputData($input ?: $this->input); + $data = $this->getInputData($input ?: $this->input); foreach (is_array($fields) ? $fields : explode(',', $fields) as $field) { [$dk, $qk] = [$field, $field]; if (stripos($field, $alias) !== false) { @@ -89,7 +93,7 @@ class QueryHelper extends Helper */ public function equal($fields, $input = null, string $alias = '#'): QueryHelper { - $data = $this->_getInputData($input ?: $this->input); + $data = $this->getInputData($input ?: $this->input); foreach (is_array($fields) ? $fields : explode(',', $fields) as $field) { [$dk, $qk] = [$field, $field]; if (stripos($field, $alias) !== false) { @@ -112,7 +116,7 @@ class QueryHelper extends Helper */ public function in($fields, string $split = ',', $input = null, string $alias = '#'): QueryHelper { - $data = $this->_getInputData($input ?: $this->input); + $data = $this->getInputData($input ?: $this->input); foreach (is_array($fields) ? $fields : explode(',', $fields) as $field) { [$dk, $qk] = [$field, $field]; if (stripos($field, $alias) !== false) { @@ -174,15 +178,15 @@ class QueryHelper extends Helper * 实例化分页管理器 * @param boolean $page 是否启用分页 * @param boolean $display 是否渲染模板 - * @param boolean $total 集合分页记录数 + * @param boolean|int $total 集合分页记录数 * @param integer $limit 集合每页记录数 * @param string $template 模板文件名称 - * @return mixed - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @return array + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ - public function page(bool $page = true, bool $display = true, $total = false, int $limit = 0, string $template = '') + public function page(bool $page = true, bool $display = true, $total = false, int $limit = 0, string $template = ''): array { return PageHelper::instance()->init($this->query, $page, $display, $total, $limit, $template); } @@ -223,7 +227,7 @@ class QueryHelper extends Helper */ private function _setBetweenWhere($fields, string $split = ' ', $input = null, string $alias = '#', ?callable $callback = null): QueryHelper { - $data = $this->_getInputData($input ?: $this->input); + $data = $this->getInputData($input ?: $this->input); foreach (is_array($fields) ? $fields : explode(',', $fields) as $field) { [$dk, $qk] = [$field, $field]; if (stripos($field, $alias) !== false) { @@ -246,7 +250,7 @@ class QueryHelper extends Helper * @param array|string|null $input * @return array */ - private function _getInputData($input): array + private function getInputData($input): array { if (is_array($input)) { return $input; diff --git a/vendor/zoujingli/think-library/src/helper/SaveHelper.php b/vendor/zoujingli/think-library/src/helper/SaveHelper.php index da61b8892..6fd13d7ac 100644 --- a/vendor/zoujingli/think-library/src/helper/SaveHelper.php +++ b/vendor/zoujingli/think-library/src/helper/SaveHelper.php @@ -18,6 +18,7 @@ declare (strict_types=1); namespace think\admin\helper; use think\admin\Helper; +use think\db\exception\DbException; use think\db\Query; /** @@ -34,18 +35,18 @@ class SaveHelper extends Helper * @param array $data 表单扩展数据 * @param string $field 数据对象主键 * @param array $where 额外更新条件 - * @return boolean|void - * @throws \think\db\exception\DbException + * @return boolean + * @throws DbException */ - public function init($dbQuery, array $data = [], string $field = '', array $where = []) + public function init($dbQuery, array $data = [], string $field = '', array $where = []): bool { $query = $this->buildQuery($dbQuery); $data = $data ?: $this->app->request->post(); $field = $field ?: ($query->getPk() ?: 'id'); - $value = $this->app->request->post($field, null); + $value = $this->app->request->post($field); // 主键限制处理 if (!isset($where[$field]) && is_string($value)) { - $query->whereIn($field, explode(',', $value)); + $query->whereIn($field, str2arr($value)); if (isset($data)) unset($data[$field]); } // 前置回调处理 @@ -53,10 +54,10 @@ class SaveHelper extends Helper return false; } // 执行更新操作 - $result = $query->where($where)->update($data) !== false; + $query->where($where)->update($data); // 结果回调处理 if (false === $this->class->callback('_save_result', $result)) { - return $result; + return true; } // 回复前端结果 if ($result !== false) { diff --git a/vendor/zoujingli/think-library/src/helper/TokenHelper.php b/vendor/zoujingli/think-library/src/helper/TokenHelper.php index b9f2294f0..0c9cd781c 100644 --- a/vendor/zoujingli/think-library/src/helper/TokenHelper.php +++ b/vendor/zoujingli/think-library/src/helper/TokenHelper.php @@ -34,7 +34,7 @@ class TokenHelper extends Helper * @param boolean $return * @return boolean */ - public function init($return = false) + public function init(bool $return = false): bool { $this->class->csrf_state = true; if ($this->app->request->isPost() && !TokenService::instance()->checkFormToken()) { diff --git a/vendor/zoujingli/think-library/src/helper/ValidateHelper.php b/vendor/zoujingli/think-library/src/helper/ValidateHelper.php index 85dacfbe1..79c87a8a3 100644 --- a/vendor/zoujingli/think-library/src/helper/ValidateHelper.php +++ b/vendor/zoujingli/think-library/src/helper/ValidateHelper.php @@ -32,7 +32,7 @@ class ValidateHelper extends Helper * @param array $rules 验证规则( 验证信息数组 ) * @param string|array $input 输入内容 ( post. 或 get. ) * @param callable|null $callable 异常处理操作 - * @return array|void + * @return array * age.require => message // 最大值限定 * age.between:1,120 => message // 范围限定 * name.require => message // 必填内容 diff --git a/vendor/zoujingli/think-library/src/multiple/BuildUrl.php b/vendor/zoujingli/think-library/src/multiple/BuildUrl.php index 6687bff6c..9e4abed8d 100644 --- a/vendor/zoujingli/think-library/src/multiple/BuildUrl.php +++ b/vendor/zoujingli/think-library/src/multiple/BuildUrl.php @@ -16,6 +16,7 @@ declare (strict_types=1); namespace think\admin\multiple; +use InvalidArgumentException; use think\admin\service\NodeService; use think\route\Url; @@ -99,7 +100,7 @@ class BuildUrl extends Url } if ($url) { $checkDomain = $domain && is_string($domain) ? $domain : null; - $checkName = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : ''); + $checkName = $name ?? $url . (isset($info['query']) ? '?' . $info['query'] : ''); $rule = $this->route->getName($checkName, $checkDomain); if (empty($rule) && isset($info['query'])) { $rule = $this->route->getName($url, $checkDomain); @@ -116,7 +117,7 @@ class BuildUrl extends Url $url = $this->app->http->getName() . '/' . $url; } } elseif (!empty($rule) && isset($name)) { - throw new \InvalidArgumentException('route name not exists:' . $name); + throw new InvalidArgumentException('route name not exists:' . $name); } else { // 检测URL绑定 $bind = $this->route->getDomainBind($domain && is_string($domain) ? $domain : null); diff --git a/vendor/zoujingli/think-library/src/multiple/command/Clear.php b/vendor/zoujingli/think-library/src/multiple/command/Clear.php index becab581b..3a5009721 100644 --- a/vendor/zoujingli/think-library/src/multiple/command/Clear.php +++ b/vendor/zoujingli/think-library/src/multiple/command/Clear.php @@ -31,7 +31,7 @@ class Clear extends Command protected function configure() { $this->setName('clear')->addArgument('app', Argument::OPTIONAL, 'app name'); - $this->addOption('path', 'd', Option::VALUE_OPTIONAL, 'path to clear', null); + $this->addOption('path', 'd', Option::VALUE_OPTIONAL, 'path to clear'); $this->addOption('cache', 'c', Option::VALUE_NONE, 'clear cache file'); $this->addOption('log', 'l', Option::VALUE_NONE, 'clear log file'); $this->addOption('dir', 'r', Option::VALUE_NONE, 'clear empty dir'); @@ -42,7 +42,7 @@ class Clear extends Command /** * @param Input $input * @param Output $output - * @return int|void|null + * @return void */ protected function execute(Input $input, Output $output) { @@ -55,7 +55,7 @@ class Clear extends Command } else { $path = $input->getOption('path') ?: $runtimePath; } - $rmdir = $input->getOption('dir') ? true : false; + $rmdir = (bool)$input->getOption('dir'); // --expire 仅当 --cache 时生效 $expire = $input->getOption('expire') && $input->getOption('cache'); $this->clear(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, $rmdir, $expire); diff --git a/vendor/zoujingli/think-library/src/service/AdminService.php b/vendor/zoujingli/think-library/src/service/AdminService.php index 1c8eb2a4e..3baa9d010 100644 --- a/vendor/zoujingli/think-library/src/service/AdminService.php +++ b/vendor/zoujingli/think-library/src/service/AdminService.php @@ -17,8 +17,12 @@ declare (strict_types=1); namespace think\admin\service; +use ReflectionException; use think\admin\extend\DataExtend; use think\admin\Service; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; /** * 系统权限管理服务 @@ -69,7 +73,7 @@ class AdminService extends Service * --- 需要读取缓存或扫描所有节点 * @param null|string $node * @return boolean - * @throws \ReflectionException + * @throws ReflectionException */ public function check(?string $node = ''): bool { @@ -95,7 +99,7 @@ class AdminService extends Service * 获取授权节点列表 * @param array $checkeds * @return array - * @throws \ReflectionException + * @throws ReflectionException */ public function getTree(array $checkeds = []): array { @@ -121,9 +125,9 @@ class AdminService extends Service * 初始化用户权限 * @param boolean $force 强刷权限 * @return $this - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function apply(bool $force = false): AdminService { diff --git a/vendor/zoujingli/think-library/src/service/InterfaceService.php b/vendor/zoujingli/think-library/src/service/InterfaceService.php index af25c7186..8eb0979c4 100644 --- a/vendor/zoujingli/think-library/src/service/InterfaceService.php +++ b/vendor/zoujingli/think-library/src/service/InterfaceService.php @@ -17,10 +17,15 @@ declare (strict_types=1); namespace think\admin\service; +use stdClass; +use think\admin\Exception; use think\admin\extend\HttpExtend; use think\admin\helper\ValidateHelper; use think\admin\Service; use think\App; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; use think\exception\HttpResponseException; /** @@ -64,9 +69,9 @@ class InterfaceService extends Service * 接口服务初始化 * InterfaceService constructor. * @param App $app - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function __construct(App $app) { @@ -132,7 +137,7 @@ class InterfaceService extends Service /** * 获取请求数据 * @param boolean $check 验证数据 - * @return mixed + * @return array|InterfaceService */ public function getInput(bool $check = true) { @@ -187,7 +192,7 @@ class InterfaceService extends Service if ($this->debug) { return $this->app->request->request(); } else { - if (empty($this->input)) $this->getInput(true); + if (empty($this->input)) $this->getInput(); return json_decode($this->input['data'], true) ?: []; } } @@ -200,8 +205,8 @@ class InterfaceService extends Service */ public function error($info, $data = '{-null-}', $code = 0): void { - if ($data === '{-null-}') $data = new \stdClass(); - $this->baseResponse(lang('think_library_response_success'), ['code' => $code, 'info' => $info, 'data' => $data], 1); + if ($data === '{-null-}') $data = new stdClass(); + $this->baseResponse(lang('think_library_response_success'), ['code' => $code, 'info' => $info, 'data' => $data]); } /** @@ -212,8 +217,8 @@ class InterfaceService extends Service */ public function success($info, $data = '{-null-}', $code = 1): void { - if ($data === '{-null-}') $data = new \stdClass(); - $this->baseResponse(lang('think_library_response_success'), ['code' => $code, 'info' => $info, 'data' => $data], 1); + if ($data === '{-null-}') $data = new stdClass(); + $this->baseResponse(lang('think_library_response_success'), ['code' => $code, 'info' => $info, 'data' => $data]); } /** @@ -249,7 +254,7 @@ class InterfaceService extends Service $array = $this->_buildSign($data); throw new HttpResponseException(json([ 'code' => $code, 'info' => $info, 'time' => $array['time'], 'sign' => $array['sign'], - 'appid' => input('appid', null), 'nostr' => $array['nostr'], 'data' => $data, + 'appid' => input('appid'), 'nostr' => $array['nostr'], 'data' => $data, ])); } @@ -258,13 +263,13 @@ class InterfaceService extends Service * @param string $uri 接口地址 * @param array $data 请求数据 * @return array - * @throws \think\admin\Exception + * @throws Exception */ public function doRequest(string $uri, array $data = []): array { $result = json_decode(HttpExtend::post($this->baseurl . $uri, $this->_buildSign($data)), true); - if (empty($result)) throw new \think\admin\Exception(lang('think_library_response_failed')); - if (empty($result['code'])) throw new \think\admin\Exception($result['info']); + if (empty($result)) throw new Exception(lang('think_library_response_failed')); + if (empty($result['code'])) throw new Exception($result['info']); return $result['data'] ?? []; } diff --git a/vendor/zoujingli/think-library/src/service/MenuService.php b/vendor/zoujingli/think-library/src/service/MenuService.php index 6f2594c66..069adff64 100644 --- a/vendor/zoujingli/think-library/src/service/MenuService.php +++ b/vendor/zoujingli/think-library/src/service/MenuService.php @@ -17,8 +17,12 @@ declare (strict_types=1); namespace think\admin\service; +use ReflectionException; use think\admin\extend\DataExtend; use think\admin\Service; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; /** * 系统菜单管理服务 @@ -31,7 +35,7 @@ class MenuService extends Service /** * 获取可选菜单节点 * @return array - * @throws \ReflectionException + * @throws ReflectionException */ public function getList(): array { @@ -46,10 +50,10 @@ class MenuService extends Service /** * 获取系统菜单树数据 * @return array - * @throws \ReflectionException - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws ReflectionException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function getTree(): array { @@ -62,7 +66,7 @@ class MenuService extends Service * 后台主菜单权限过滤 * @param array $menus 当前菜单列表 * @return array - * @throws \ReflectionException + * @throws ReflectionException */ private function _buildData(array $menus): array { diff --git a/vendor/zoujingli/think-library/src/service/MessageService.php b/vendor/zoujingli/think-library/src/service/MessageService.php index 66c207fdd..0cb235200 100644 --- a/vendor/zoujingli/think-library/src/service/MessageService.php +++ b/vendor/zoujingli/think-library/src/service/MessageService.php @@ -19,6 +19,9 @@ namespace think\admin\service; use think\admin\extend\HttpExtend; use think\admin\Service; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; /** * 旧助通短信接口服务 @@ -64,9 +67,9 @@ class MessageService extends Service /** * @return $this - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ protected function initialize(): MessageService { @@ -160,9 +163,9 @@ class MessageService extends Service * @param integer $wait 等待时间 * @param string $type 短信模板 * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function sendChinaSmsByCode($phone, int $wait = 120, string $type = 'sms_reg_template'): array { @@ -171,7 +174,7 @@ class MessageService extends Service $dtime = ($cache['time'] + $wait < time()) ? 0 : ($wait - time() + $cache['time']); return [1, '短信验证码已经发送!', ['time' => $dtime]]; } - [$code, $content] = [rand(1000, 9999), sysconf($type)]; + [$code, $content] = [rand(1000, 9999) . '', sysconf($type)]; if (empty($content) || stripos($content, '{code}') === false) { $content = '您的验证码为{code},请在十分钟内完成操作!'; } @@ -216,6 +219,8 @@ class MessageService extends Service return ['code' => 0, 'num' => '0', 'msg' => 'tkey不正确!']; } elseif ($result > -4) { return ['code' => 0, 'num' => '0', 'msg' => '用户不存在或用户停用!']; + } else { + return ['code' => 0, 'num' => '0', 'msg' => '未知错误原因!']; } } @@ -241,9 +246,9 @@ class MessageService extends Service * @param integer|string $mobile 手机号码 * @param string $content 发送内容 * @return boolean - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function sendGlobeSms($code, $mobile, string $content): bool { diff --git a/vendor/zoujingli/think-library/src/service/ModuleService.php b/vendor/zoujingli/think-library/src/service/ModuleService.php index 2af888a7e..a9d48b4b2 100644 --- a/vendor/zoujingli/think-library/src/service/ModuleService.php +++ b/vendor/zoujingli/think-library/src/service/ModuleService.php @@ -251,6 +251,8 @@ class ModuleService extends Service } else { return [false, $file['type'], $file['name']]; } + } else { + return [false, 'non', '未知操作']; } } diff --git a/vendor/zoujingli/think-library/src/service/NodeService.php b/vendor/zoujingli/think-library/src/service/NodeService.php index 2ac6cab9f..791f1795b 100644 --- a/vendor/zoujingli/think-library/src/service/NodeService.php +++ b/vendor/zoujingli/think-library/src/service/NodeService.php @@ -17,6 +17,9 @@ declare (strict_types=1); namespace think\admin\service; +use ReflectionClass; +use ReflectionException; +use ReflectionMethod; use think\admin\Service; /** @@ -101,7 +104,7 @@ class NodeService extends Service * 获取所有控制器入口 * @param boolean $force * @return array - * @throws \ReflectionException + * @throws ReflectionException */ public function getMethods(bool $force = false): array { @@ -121,10 +124,10 @@ class NodeService extends Service if (preg_match("|^([\w/]+)/(\w+)/controller/(.+)\.php$|i", $name, $matches)) { [, $namespace, $appname, $classname] = $matches; $addons = preg_match('|/addons$|', $namespace) ? 'addons-' : ''; - $class = new \ReflectionClass(strtr("{$namespace}/{$appname}/controller/{$classname}", '/', '\\')); + $class = new ReflectionClass(strtr("{$namespace}/{$appname}/controller/{$classname}", '/', '\\')); $prefix = strtolower(strtr("{$addons}{$appname}/{$this->nameTolower($classname)}", '\\', '/')); $data[$prefix] = $this->_parseComment($class->getDocComment() ?: '', $classname); - foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { + foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { if (in_array($metname = $method->getName(), $ignores)) continue; $data[strtolower("{$prefix}/{$metname}")] = $this->_parseComment($method->getDocComment() ?: '', $metname); } diff --git a/vendor/zoujingli/think-library/src/service/ProcessService.php b/vendor/zoujingli/think-library/src/service/ProcessService.php index fb550b9df..43220a2c1 100644 --- a/vendor/zoujingli/think-library/src/service/ProcessService.php +++ b/vendor/zoujingli/think-library/src/service/ProcessService.php @@ -18,6 +18,9 @@ declare (strict_types=1); namespace think\admin\service; use think\admin\Service; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; /** * 系统进程管理服务 @@ -32,11 +35,11 @@ class ProcessService extends Service * @param string $args 指定参数 * @param boolean $simple 指令内容 * @return string - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ - public function think(string $args = '', $simple = false): string + public function think(string $args = '', bool $simple = false): string { if ($simple) { return trim("{$this->app->getRootPath()}think {$args}"); @@ -50,9 +53,9 @@ class ProcessService extends Service * 检查 Think 运行进程 * @param string $args * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function thinkQuery(string $args): array { @@ -64,31 +67,22 @@ class ProcessService extends Service * @param string $args 执行参数 * @param integer $usleep 延时时间 * @return ProcessService - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ - public function thinkCreate(string $args, $usleep = 0): ProcessService + public function thinkCreate(string $args, int $usleep = 0): ProcessService { return $this->create($this->think($args), $usleep); } - /** - * 获取当前应用版本 - * @return string - */ - public function version(): string - { - return ModuleService::instance()->getVersion(); - } - /** * 创建异步进程 * @param string $command 任务指令 * @param integer $usleep 延时时间 * @return $this */ - public function create(string $command, $usleep = 0): ProcessService + public function create(string $command, int $usleep = 0): ProcessService { if ($this->iswin()) { $this->exec(__DIR__ . "/bin/console.exe {$command}"); @@ -103,22 +97,22 @@ class ProcessService extends Service /** * 查询相关进程列表 - * @param string $command 任务指令 - * @param string $name 执行名称 + * @param string $cmd 任务指令 + * @param string $name 程序名称 * @return array */ - public function query(string $command, string $name = 'php.exe'): array + public function query(string $cmd, string $name = 'php.exe'): array { $list = []; if ($this->iswin()) { $lines = $this->exec('wmic process where name="' . $name . '" get processid,CommandLine', true); - foreach ($lines as $line) if ($this->_issub($line, $command) !== false) { + foreach ($lines as $line) if ($this->_issub($line, $cmd) !== false) { $attr = explode(' ', $this->_space($line)); $list[] = ['pid' => array_pop($attr), 'cmd' => join(' ', $attr)]; } } else { - $lines = $this->exec("ps ax|grep -v grep|grep \"{$command}\"", true); - foreach ($lines as $line) if ($this->_issub($line, $command) !== false) { + $lines = $this->exec("ps ax|grep -v grep|grep \"{$cmd}\"", true); + foreach ($lines as $line) if ($this->_issub($line, $cmd) !== false) { $attr = explode(' ', $this->_space($line)); [$pid] = [array_shift($attr), array_shift($attr), array_shift($attr), array_shift($attr)]; $list[] = ['pid' => $pid, 'cmd' => join(' ', $attr)]; @@ -145,7 +139,7 @@ class ProcessService extends Service /** * 立即执行指令 * @param string $command 执行指令 - * @param array|boolean $outarr 返回类型 + * @param boolean|array $outarr 返回类型 * @return string|array */ public function exec(string $command, $outarr = false) @@ -166,12 +160,11 @@ class ProcessService extends Service /** * 清除空白字符过滤 * @param string $content - * @param string $tochar * @return string */ - private function _space(string $content, string $tochar = ' '): string + private function _space(string $content): string { - return preg_replace('|\s+|', $tochar, strtr(trim($content), '\\', '/')); + return preg_replace('|\s+|', ' ', strtr(trim($content), '\\', '/')); } /** diff --git a/vendor/zoujingli/think-library/src/service/QueueService.php b/vendor/zoujingli/think-library/src/service/QueueService.php index c9aa757a0..d9f9bcfeb 100644 --- a/vendor/zoujingli/think-library/src/service/QueueService.php +++ b/vendor/zoujingli/think-library/src/service/QueueService.php @@ -17,9 +17,13 @@ declare (strict_types=1); namespace think\admin\service; +use Error; use think\admin\Exception; use think\admin\extend\CodeExtend; use think\admin\Service; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; /** * 任务基础服务 @@ -55,21 +59,21 @@ class QueueService extends Service /** * 数据初始化 - * @param integer $code + * @param string $code * @return static - * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws Exception + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ - public function initialize($code = 0): QueueService + public function initialize(string $code = ''): QueueService { if (!empty($code)) { $this->code = $code; $this->record = $this->app->db->name('SystemQueue')->where(['code' => $this->code])->find(); if (empty($this->record)) { $this->app->log->error("Qeueu initialize failed, Queue {$code} not found."); - throw new \think\admin\Exception("Qeueu initialize failed, Queue {$code} not found."); + throw new Exception("Qeueu initialize failed, Queue {$code} not found."); } [$this->code, $this->title] = [$this->record['code'], $this->record['title']]; $this->data = json_decode($this->record['exec_data'], true) ?: []; @@ -81,16 +85,16 @@ class QueueService extends Service * 重发异步任务 * @param integer $wait 等待时间 * @return $this - * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws Exception + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ - public function reset($wait = 0): QueueService + public function reset(int $wait = 0): QueueService { if (empty($this->record)) { $this->app->log->error("Qeueu reset failed, Queue {$this->code} data cannot be empty!"); - throw new \think\admin\Exception("Qeueu reset failed, Queue {$this->code} data cannot be empty!"); + throw new Exception("Qeueu reset failed, Queue {$this->code} data cannot be empty!"); } $this->app->db->name('SystemQueue')->where(['code' => $this->code])->strict(false)->failException(true)->update([ 'exec_pid' => 0, 'exec_time' => time() + $wait, 'status' => 1, @@ -103,13 +107,13 @@ class QueueService extends Service * @param integer $loops 循环时间 * @return $this * @throws Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ - public function addCleanQueue($loops = 3600): QueueService + public function addCleanQueue(int $loops = 3600): QueueService { - return $this->register('定时清理系统任务数据', "xadmin:queue clean", 0, [], 0, $loops); + return $this->register('定时清理系统任务数据', "xadmin:service clean", 0, [], 0, $loops); } /** @@ -121,16 +125,16 @@ class QueueService extends Service * @param integer $rscript 任务类型(0单例,1多例) * @param integer $loops 循环等待时间 * @return $this - * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws Exception + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function register(string $title, string $command, int $later = 0, array $data = [], int $rscript = 0, int $loops = 0): QueueService { $map = [['title', '=', $title], ['status', 'in', [1, 2]]]; if (empty($rscript) && ($queue = $this->app->db->name('SystemQueue')->where($map)->find())) { - throw new \think\admin\Exception(lang('think_library_queue_exist'), 0, $queue['code']); + throw new Exception(lang('think_library_queue_exist'), 0, $queue['code']); } $this->code = CodeExtend::uniqidDate(16, 'Q'); $this->app->db->name('SystemQueue')->strict(false)->failException(true)->insert([ @@ -145,19 +149,19 @@ class QueueService extends Service 'outer_time' => 0, 'loops_time' => $loops, ]); - $this->progress(1, '>>> 任务创建成功 <<<', 0.00); + $this->progress(1, '>>> 任务创建成功 <<<', '0.00'); return $this->initialize($this->code); } /** * 设置任务进度信息 - * @param null|integer $status 任务状态 - * @param null|string $message 进度消息 - * @param null|float $progress 进度数值 + * @param ?integer $status 任务状态 + * @param ?string $message 进度消息 + * @param ?string $progress 进度数值 * @param integer $backline 回退信息行 * @return array */ - public function progress(?int $status = null, ?string $message = null, $progress = null, $backline = 0): array + public function progress(?int $status = null, ?string $message = null, ?string $progress = null, int $backline = 0): array { $ckey = "queue_{$this->code}_progress"; if (is_numeric($status) && intval($status) === 3) { @@ -172,12 +176,10 @@ class QueueService extends Service $data = $this->app->cache->get($ckey, [ 'code' => $this->code, 'status' => $status, 'message' => $message, 'progress' => $progress, 'history' => [], ]); - } catch (\Exception | \Error $exception) { + } catch (\Exception | Error $exception) { return $this->progress($status, $message, $progress, $backline); } - while ($backline > 0 && count($data['history']) > 0) { - [--$backline, array_pop($data['history'])]; - } + while (--$backline > -1 && count($data['history']) > 0) array_pop($data['history']); if (is_numeric($status)) $data['status'] = intval($status); if (is_numeric($progress)) $progress = str_pad(sprintf("%.2f", $progress), 6, '0', STR_PAD_LEFT); if (is_string($message) && is_null($progress)) { @@ -207,7 +209,7 @@ class QueueService extends Service * @param string $message 文字描述 * @param integer $backline 回退行数 */ - public function message(int $total, int $count, string $message = '', $backline = 0): void + public function message(int $total, int $count, string $message = '', int $backline = 0): void { $total = $total < 1 ? 1 : $total; $prefix = str_pad("{$count}", strlen("{$total}"), '0', STR_PAD_LEFT); @@ -242,7 +244,7 @@ class QueueService extends Service /** * 执行任务处理 * @param array $data 任务参数 - * @return mixed + * @return void */ public function execute(array $data = []) { diff --git a/vendor/zoujingli/think-library/src/service/SystemService.php b/vendor/zoujingli/think-library/src/service/SystemService.php index e088f6b3e..751ab9bd3 100644 --- a/vendor/zoujingli/think-library/src/service/SystemService.php +++ b/vendor/zoujingli/think-library/src/service/SystemService.php @@ -17,7 +17,12 @@ declare (strict_types=1); namespace think\admin\service; +use Exception; use think\admin\Service; +use think\App; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; use think\db\Query; use think\helper\Str; @@ -44,16 +49,16 @@ class SystemService extends Service /** * 设置配置数据 * @param string $name 配置名称 - * @param string $value 配置内容 - * @return integer - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @param mixed $value 配置内容 + * @return integer|string + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function set(string $name, $value = '') { $this->data = []; - [$type, $field] = $this->_parse($name, 'base'); + [$type, $field] = $this->_parse($name); if (is_array($value)) { $count = 0; foreach ($value as $kk => $vv) { @@ -74,9 +79,9 @@ class SystemService extends Service * @param string $name * @param string $default * @return array|mixed|string - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function get(string $name = '', string $default = '') { @@ -85,7 +90,7 @@ class SystemService extends Service $this->data[$item['type']][$item['name']] = $item['value']; }); } - [$type, $field, $outer] = $this->_parse($name, 'base'); + [$type, $field, $outer] = $this->_parse($name); if (empty($name)) { return $this->data; } elseif (isset($this->data[$type])) { @@ -101,31 +106,40 @@ class SystemService extends Service /** * 数据增量保存 - * @param Query|string $dbQuery 数据查询对象 + * @param Query|string $query 数据查询对象 * @param array $data 需要保存的数据 * @param string $key 更新条件查询主键 - * @param array $where 额外更新查询条件 + * @param array $map 额外更新查询条件 * @return boolean|integer 失败返回 false, 成功返回主键值或 true - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ - public function save($dbQuery, array $data, string $key = 'id', array $where = []) + public function save($query, array $data, string $key = 'id', array $map = []) { - $val = $data[$key] ?? null; - $query = (is_string($dbQuery) ? $this->app->db->name($dbQuery) : $dbQuery)->master()->strict(false)->where($where); - if (empty($where[$key])) is_string($val) && strpos($val, ',') !== false ? $query->whereIn($key, explode(',', $val)) : $query->where([$key => $val]); - return is_array($info = (clone $query)->find()) && !empty($info) ? ($query->update($data) !== false ? ($info[$key] ?? true) : false) : $query->insertGetId($data); + if (is_string($query)) $query = $this->app->db->name($query); + [$query, $value] = [$query->master()->strict(false)->where($map), $data[$key] ?? null]; + if (empty($map[$key])) if (is_string($value) && strpos($value, ',') !== false) { + $query->whereIn($key, str2arr($value)); + } else { + $query->where([$key => $value]); + } + if (($info = (clone $query)->find()) && !empty($info)) { + $query->update($data); + return $info[$key] ?? true; + } else { + return $query->insertGetId($data); + } } /** * 解析缓存名称 * @param string $rule 配置名称 - * @param string $type 配置类型 * @return array */ - private function _parse(string $rule, string $type = 'base'): array + private function _parse(string $rule): array { + $type = 'base'; if (stripos($rule, '.') !== false) { [$type, $rule] = explode('.', $rule, 2); } @@ -154,9 +168,9 @@ class SystemService extends Service * @param string $name * @param mixed $value * @return boolean - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function setData(string $name, $value) { @@ -185,9 +199,9 @@ class SystemService extends Service public function getData(string $name, $default = []) { try { - $value = $this->app->db->name('SystemData')->where(['name' => $name])->value('value', null); + $value = $this->app->db->name('SystemData')->where(['name' => $name])->value('value'); return is_null($value) ? $default : unserialize($value); - } catch (\Exception $exception) { + } catch (Exception $exception) { return $default; } } @@ -227,7 +241,7 @@ class SystemService extends Service * @param string|null $file 文件名称 * @return false|int */ - public function putDebug($data, $new = false, $file = null) + public function putDebug($data, bool $new = false, ?string $file = null) { if (is_null($file)) $file = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . date('Ymd') . '.log'; $str = (is_string($data) ? $data : ((is_array($data) || is_object($data)) ? print_r($data, true) : var_export($data, true))) . PHP_EOL; @@ -339,9 +353,9 @@ class SystemService extends Service /** * 初始化并运行主程序 - * @param null|\think\App $app + * @param null|App $app */ - public function doInit(?\think\App $app = null): void + public function doInit(?App $app = null): void { $this->app = $app ?: $this->app; $this->app->debug($this->isDebug()); diff --git a/vendor/zoujingli/think-library/src/service/TokenService.php b/vendor/zoujingli/think-library/src/service/TokenService.php index 005f1b1aa..74a8d1eff 100644 --- a/vendor/zoujingli/think-library/src/service/TokenService.php +++ b/vendor/zoujingli/think-library/src/service/TokenService.php @@ -89,7 +89,7 @@ class TokenService extends Service * @param null|string $node 授权节点 * @return boolean */ - public function checkFormToken($token = null, $node = null): bool + public function checkFormToken(?string $token = null, ?string $node = null): bool { $cache = $this->_getCacheItem($token ?: $this->getInputToken()); if (empty($cache['node']) || empty($cache['time'])) return false; @@ -101,7 +101,7 @@ class TokenService extends Service * @param null|string $token * @return $this */ - public function clearFormToken($token = null) + public function clearFormToken(?string $token = null): TokenService { $this->_delCacheItem($token ?: $this->getInputToken()); return $this; @@ -112,7 +112,7 @@ class TokenService extends Service * @param null|string $node * @return array */ - public function buildFormToken($node = null): array + public function buildFormToken(?string $node = null): array { $cnode = NodeService::instance()->fullnode($node); [$token, $time] = [uniqid() . rand(100000, 999999), time()]; @@ -132,12 +132,10 @@ class TokenService extends Service * 设置缓存数据 * @param string $token * @param array $value - * @return static */ private function _setCacheItem(string $token, array $value) { $this->cache[$token] = $value; - return $this; } /** @@ -152,13 +150,12 @@ class TokenService extends Service /** * 获取指定缓存 * @param string $token - * @param array $default * @return mixed */ - private function _getCacheItem(string $token, $default = []) + private function _getCacheItem(string $token) { $this->_clearTimeoutCache(); - return $this->cache[$token] ?? $default; + return $this->cache[$token] ?? []; } /** diff --git a/vendor/zoujingli/think-library/src/service/ZtSmsService.php b/vendor/zoujingli/think-library/src/service/ZtSmsService.php index c0b606464..c59d71cb7 100644 --- a/vendor/zoujingli/think-library/src/service/ZtSmsService.php +++ b/vendor/zoujingli/think-library/src/service/ZtSmsService.php @@ -19,6 +19,9 @@ namespace think\admin\service; use think\admin\extend\HttpExtend; use think\admin\Service; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; /** * 新助通短信接口服务 @@ -47,9 +50,9 @@ class ZtSmsService extends Service /** * 短信服务初始化 - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ protected function initialize() { @@ -94,9 +97,9 @@ class ZtSmsService extends Service * @param integer $wait 等待时间 * @param string $template 模板编码 * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function sendVerifyCode(string $phone, int $wait = 120, string $template = 'ztsms.register_verify'): array { @@ -108,7 +111,7 @@ class ZtSmsService extends Service return [1, '短信验证码已经发送!', ['time' => $dtime]]; } // 生成新的验证码 - $code = rand(100000, 999999); + $code = (string)rand(100000, 999999); $this->app->cache->set($ckey, ['code' => $code, 'time' => $time], 600); // 尝试发送短信内容 $content = sysconf($template) ?: '您的验证码为{code},请在十分钟内完成操作!'; diff --git a/vendor/zoujingli/think-library/src/storage/AliossStorage.php b/vendor/zoujingli/think-library/src/storage/AliossStorage.php index 0a8f052ff..4d422745e 100644 --- a/vendor/zoujingli/think-library/src/storage/AliossStorage.php +++ b/vendor/zoujingli/think-library/src/storage/AliossStorage.php @@ -17,8 +17,12 @@ declare (strict_types=1); namespace think\admin\storage; +use think\admin\Exception; use think\admin\extend\HttpExtend; use think\admin\Storage; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; /** * 阿里云OSS存储支持 @@ -53,10 +57,10 @@ class AliossStorage extends Storage /** * 初始化入口 - * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws Exception + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ protected function initialize() { @@ -71,17 +75,17 @@ class AliossStorage extends Storage if ($type === 'auto') $this->prefix = "//{$domain}"; elseif ($type === 'http') $this->prefix = "http://{$domain}"; elseif ($type === 'https') $this->prefix = "https://{$domain}"; - else throw new \think\admin\Exception('未配置阿里云URL域名哦'); + else throw new Exception('未配置阿里云URL域名哦'); } /** * 获取当前实例对象 * @param null|string $name * @return static - * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws Exception + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public static function instance(?string $name = null) { @@ -119,9 +123,9 @@ class AliossStorage extends Storage * 根据文件名读取文件内容 * @param string $name 文件名称 * @param boolean $safe 安全模式 - * @return false|string + * @return string */ - public function get(string $name, bool $safe = false) + public function get(string $name, bool $safe = false): string { return static::curlGet($this->url($name, $safe)); } diff --git a/vendor/zoujingli/think-library/src/storage/LocalStorage.php b/vendor/zoujingli/think-library/src/storage/LocalStorage.php index 31a2c0c87..fc684ebf7 100644 --- a/vendor/zoujingli/think-library/src/storage/LocalStorage.php +++ b/vendor/zoujingli/think-library/src/storage/LocalStorage.php @@ -17,7 +17,11 @@ declare (strict_types=1); namespace think\admin\storage; +use Exception; use think\admin\Storage; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; /** * 本地存储支持 @@ -29,9 +33,9 @@ class LocalStorage extends Storage /** * 初始化入口 - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ protected function initialize() { @@ -51,9 +55,9 @@ class LocalStorage extends Storage * @param null|string $name * @return static * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public static function instance(?string $name = null) { @@ -76,9 +80,9 @@ class LocalStorage extends Storage if (file_put_contents($path, $file)) { return $this->info($name, $safe, $attname); } - } catch (\Exception $exception) { - return []; + } catch (Exception $exception) { } + return []; } /** diff --git a/vendor/zoujingli/think-library/src/storage/QiniuStorage.php b/vendor/zoujingli/think-library/src/storage/QiniuStorage.php index bc1f40f77..8a0311208 100644 --- a/vendor/zoujingli/think-library/src/storage/QiniuStorage.php +++ b/vendor/zoujingli/think-library/src/storage/QiniuStorage.php @@ -17,8 +17,12 @@ declare (strict_types=1); namespace think\admin\storage; +use think\admin\Exception; use think\admin\extend\HttpExtend; use think\admin\Storage; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; /** * 七牛云存储支持 @@ -34,10 +38,10 @@ class QiniuStorage extends Storage /** * 初始化入口 - * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws Exception + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ protected function initialize() { @@ -51,17 +55,17 @@ class QiniuStorage extends Storage if ($type === 'auto') $this->prefix = "//{$domain}"; elseif ($type === 'http') $this->prefix = "http://{$domain}"; elseif ($type === 'https') $this->prefix = "https://{$domain}"; - else throw new \think\admin\Exception('未配置七牛云URL域名哦'); + else throw new Exception('未配置七牛云URL域名哦'); } /** * 获取当前实例对象 * @param null|string $name * @return static - * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws Exception + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public static function instance(?string $name = null) { @@ -75,10 +79,10 @@ class QiniuStorage extends Storage * @param boolean $safe 安全模式 * @param null|string $attname 下载名称 * @return array - * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws Exception + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function set(string $name, string $file, bool $safe = false, ?string $attname = null): array { @@ -169,10 +173,10 @@ class QiniuStorage extends Storage /** * 获取文件上传地址 * @return string - * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws Exception + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function upload(): string { @@ -189,7 +193,7 @@ class QiniuStorage extends Storage case '东南亚': return "{$protocol}://up-as0.qiniup.com"; default: - throw new \think\admin\Exception('未配置七牛云空间区域哦'); + throw new Exception('未配置七牛云空间区域哦'); } } diff --git a/vendor/zoujingli/think-library/src/storage/TxcosStorage.php b/vendor/zoujingli/think-library/src/storage/TxcosStorage.php index 1d4b75abf..8b866bee4 100644 --- a/vendor/zoujingli/think-library/src/storage/TxcosStorage.php +++ b/vendor/zoujingli/think-library/src/storage/TxcosStorage.php @@ -4,8 +4,12 @@ declare (strict_types=1); namespace think\admin\storage; +use think\admin\Exception; use think\admin\extend\HttpExtend; use think\admin\Storage; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; /** * 腾讯云COS存储支持 @@ -40,10 +44,10 @@ class TxcosStorage extends Storage /** * 初始化入口 - * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws Exception + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ protected function initialize() { @@ -58,17 +62,17 @@ class TxcosStorage extends Storage if ($type === 'auto') $this->prefix = "//{$domain}"; elseif ($type === 'http') $this->prefix = "http://{$domain}"; elseif ($type === 'https') $this->prefix = "https://{$domain}"; - else throw new \think\admin\Exception('未配置腾讯云COS访问域名哦'); + else throw new Exception('未配置腾讯云COS访问域名哦'); } /** * 获取当前实例对象 * @param null|string $name * @return TxcosStorage - * @throws \think\admin\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws Exception + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public static function instance(?string $name = null) { @@ -102,9 +106,9 @@ class TxcosStorage extends Storage * 根据文件名读取文件内容 * @param string $name 文件名称 * @param boolean $safe 安全模式 - * @return false|string + * @return string */ - public function get(string $name, bool $safe = false) + public function get(string $name, bool $safe = false): string { return static::curlGet($this->url($name, $safe)); }