From f8b3c1ed69bf55df98719999115b30a68a861b21 Mon Sep 17 00:00:00 2001 From: Anyon Date: Wed, 26 Aug 2020 14:10:07 +0800 Subject: [PATCH] ComposerUpdate --- app/admin/controller/Config.php | 2 + app/admin/view/config/index.html | 2 +- composer.lock | 8 +- vendor/composer/installed.json | 8 +- vendor/services.php | 2 +- .../think-library/src/Controller.php | 17 +- .../zoujingli/think-library/src/Service.php | 7 +- .../think-library/src/helper/QueryHelper.php | 164 ++++++++++-------- .../src/service/ExpressService.php | 2 +- .../src/service/InterfaceService.php | 45 ++--- 10 files changed, 137 insertions(+), 120 deletions(-) diff --git a/app/admin/controller/Config.php b/app/admin/controller/Config.php index 7341b0da2..69e468609 100644 --- a/app/admin/controller/Config.php +++ b/app/admin/controller/Config.php @@ -17,6 +17,7 @@ namespace app\admin\controller; use think\admin\Controller; use think\admin\service\AdminService; +use think\admin\service\ModuleService; use think\admin\service\SystemService; /** @@ -69,6 +70,7 @@ class Config extends Controller { $this->title = '系统参数配置'; $this->isSuper = AdminService::instance()->isSuper(); + $this->version = ModuleService::instance()->getVersion(); $this->fetch(); } diff --git a/app/admin/view/config/index.html b/app/admin/view/config/index.html index 1650e3501..f1ee06785 100644 --- a/app/admin/view/config/index.html +++ b/app/admin/view/config/index.html @@ -114,7 +114,7 @@ 管理程序 - ThinkAdmin Version {$app->config->get('app.thinkadmin_ver','v6')} + ThinkAdmin Version {$version|default='6.0.0'} 服务器信息 diff --git a/composer.lock b/composer.lock index 445636a43..173c59cf8 100644 --- a/composer.lock +++ b/composer.lock @@ -937,12 +937,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "47525f4cb63fb97937d44b45405a3c348a309cd2" + "reference": "1c194b947fb85bd79adc1f821ef06f2f77a35147" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/47525f4cb63fb97937d44b45405a3c348a309cd2", - "reference": "47525f4cb63fb97937d44b45405a3c348a309cd2", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/1c194b947fb85bd79adc1f821ef06f2f77a35147", + "reference": "1c194b947fb85bd79adc1f821ef06f2f77a35147", "shasum": "", "mirrors": [ { @@ -987,7 +987,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://thinkadmin.top", - "time": "2020-08-25T05:34:07+00:00" + "time": "2020-08-26T03:59:59+00:00" }, { "name": "zoujingli/wechat-developer", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 5b8c470f4..cf0202e28 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -963,12 +963,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "47525f4cb63fb97937d44b45405a3c348a309cd2" + "reference": "1c194b947fb85bd79adc1f821ef06f2f77a35147" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/47525f4cb63fb97937d44b45405a3c348a309cd2", - "reference": "47525f4cb63fb97937d44b45405a3c348a309cd2", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/1c194b947fb85bd79adc1f821ef06f2f77a35147", + "reference": "1c194b947fb85bd79adc1f821ef06f2f77a35147", "shasum": "", "mirrors": [ { @@ -985,7 +985,7 @@ "ext-mbstring": "*", "topthink/framework": "^6.0" }, - "time": "2020-08-25T05:34:07+00:00", + "time": "2020-08-26T03:59:59+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index dc042cd84..1e6e8f656 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\admin\\Library', diff --git a/vendor/zoujingli/think-library/src/Controller.php b/vendor/zoujingli/think-library/src/Controller.php index c6ba60dbe..c1e7cdf0b 100644 --- a/vendor/zoujingli/think-library/src/Controller.php +++ b/vendor/zoujingli/think-library/src/Controller.php @@ -51,6 +51,12 @@ abstract class Controller extends \stdClass */ public $request; + /** + * 控制器中间键 + * @var array + */ + protected $middleware = []; + /** * 表单CSRF验证状态 * @var boolean @@ -63,12 +69,6 @@ abstract class Controller extends \stdClass */ public $csrf_message; - /** - * 控制器中间键 - * @var array - */ - protected $middleware = []; - /** * Controller constructor. * @param App $app @@ -188,11 +188,12 @@ abstract class Controller extends \stdClass /** * 快捷查询逻辑器 * @param string|Query $dbQuery + * @param array|string|null $input * @return QueryHelper */ - protected function _query($dbQuery): QueryHelper + protected function _query($dbQuery, $input = null): QueryHelper { - return QueryHelper::instance()->init($dbQuery); + return QueryHelper::instance()->init($dbQuery, $input); } /** diff --git a/vendor/zoujingli/think-library/src/Service.php b/vendor/zoujingli/think-library/src/Service.php index c42058d97..0cc723a0a 100644 --- a/vendor/zoujingli/think-library/src/Service.php +++ b/vendor/zoujingli/think-library/src/Service.php @@ -52,11 +52,12 @@ abstract class Service /** * 静态实例对象 - * @param array $args + * @param array $var 实例参数 + * @param boolean $new 创建新实例 * @return static */ - public static function instance(...$args) + public static function instance($var = [], $new = false) { - return Container::getInstance()->make(static::class, $args); + return Container::getInstance()->make(static::class, $var, $new); } } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/helper/QueryHelper.php b/vendor/zoujingli/think-library/src/helper/QueryHelper.php index 54272ad57..1b72d0cd4 100644 --- a/vendor/zoujingli/think-library/src/helper/QueryHelper.php +++ b/vendor/zoujingli/think-library/src/helper/QueryHelper.php @@ -27,31 +27,11 @@ use think\db\Query; */ class QueryHelper extends Helper { - /** - * QueryHelper call. - * @param string $name 调用方法名称 - * @param array $args 调用参数内容 - * @return $this + * 初始化默认数据 + * @var array */ - public function __call($name, $args) - { - if (is_callable($callable = [$this->query, $name])) { - call_user_func_array($callable, $args); - } - return $this; - } - - /** - * 逻辑器初始化 - * @param string|Query $dbQuery - * @return $this - */ - public function init($dbQuery) - { - $this->query = $this->buildQuery($dbQuery); - return $this; - } + protected $input; /** * 获取当前Db操作对象 @@ -62,16 +42,29 @@ class QueryHelper extends Helper return $this->query; } + /** + * 逻辑器初始化 + * @param string|Query $dbQuery + * @param array|string|null $input 输入数据 + * @return $this + */ + public function init($dbQuery, $input = null) + { + $this->query = $this->buildQuery($dbQuery); + $this->input = $this->_getInputData($input); + return $this; + } + /** * 设置Like查询条件 * @param string|array $fields 查询字段 - * @param string $input 输入类型 get|post + * @param array|string|null $input 输入数据 * @param string $alias 别名分割符 * @return $this */ - public function like($fields, $input = 'request', $alias = '#') + public function like($fields, $input = null, $alias = '#') { - $data = $this->app->request->$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) { @@ -85,15 +78,15 @@ class QueryHelper extends Helper } /** - * 设置Equal查询条件 + * 设置 Equal 查询条件 * @param string|array $fields 查询字段 - * @param string $input 输入类型 get|post + * @param array|string|null $input 输入类型 * @param string $alias 别名分割符 * @return $this */ - public function equal($fields, $input = 'request', $alias = '#') + public function equal($fields, $input = null, $alias = '#') { - $data = $this->app->request->$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) { @@ -110,13 +103,13 @@ class QueryHelper extends Helper * 设置IN区间查询 * @param string $fields 查询字段 * @param string $split 输入分隔符 - * @param string $input 输入类型 get|post + * @param array|string|null $input 输入数据 * @param string $alias 别名分割符 * @return $this */ - public function in($fields, $split = ',', $input = 'request', $alias = '#') + public function in($fields, $split = ',', $input = null, $alias = '#') { - $data = $this->app->request->$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) { @@ -133,26 +126,26 @@ class QueryHelper extends Helper * 设置内容区间查询 * @param string|array $fields 查询字段 * @param string $split 输入分隔符 - * @param string $input 输入类型 get|post + * @param array|string|null $input 输入数据 * @param string $alias 别名分割符 * @return $this */ - public function valueBetween($fields, $split = ' ', $input = 'request', $alias = '#') + public function valueBetween($fields, $split = ' ', $input = null, $alias = '#') { - return $this->setBetweenWhere($fields, $split, $input, $alias); + return $this->_setBetweenWhere($fields, $split, $input, $alias); } /** * 设置日期时间区间查询 * @param string|array $fields 查询字段 * @param string $split 输入分隔符 - * @param string $input 输入类型 + * @param array|string|null $input 输入数据 * @param string $alias 别名分割符 * @return $this */ - public function dateBetween($fields, $split = ' - ', $input = 'request', $alias = '#') + public function dateBetween($fields, $split = ' - ', $input = null, $alias = '#') { - return $this->setBetweenWhere($fields, $split, $input, $alias, function ($value, $type) { + return $this->_setBetweenWhere($fields, $split, $input, $alias, function ($value, $type) { return $type === 'after' ? "{$value} 23:59:59" : "{$value} 00:00:00"; }); } @@ -161,46 +154,17 @@ class QueryHelper extends Helper * 设置时间戳区间查询 * @param string|array $fields 查询字段 * @param string $split 输入分隔符 - * @param string $input 输入类型 + * @param array|string|null $input 输入数据 * @param string $alias 别名分割符 * @return $this */ - public function timeBetween($fields, $split = ' - ', $input = 'request', $alias = '#') + public function timeBetween($fields, $split = ' - ', $input = null, $alias = '#') { - return $this->setBetweenWhere($fields, $split, $input, $alias, function ($value, $type) { + return $this->_setBetweenWhere($fields, $split, $input, $alias, function ($value, $type) { return $type === 'after' ? strtotime("{$value} 23:59:59") : strtotime("{$value} 00:00:00"); }); } - /** - * 设置区域查询条件 - * @param string|array $fields 查询字段 - * @param string $split 输入分隔符 - * @param string $input 输入类型 - * @param string $alias 别名分割符 - * @param callable $callback - * @return $this - */ - private function setBetweenWhere($fields, $split = ' ', $input = 'request', $alias = '#', $callback = null) - { - $data = $this->app->request->$input(); - foreach (is_array($fields) ? $fields : explode(',', $fields) as $field) { - [$dk, $qk] = [$field, $field]; - if (stripos($field, $alias) !== false) { - [$dk, $qk] = explode($alias, $field); - } - if (isset($data[$qk]) && $data[$qk] !== '') { - [$begin, $after] = explode($split, $data[$qk]); - if (is_callable($callback)) { - $after = call_user_func($callback, $after, 'after'); - $begin = call_user_func($callback, $begin, 'begin'); - } - $this->query->whereBetween($dk, [$begin, $after]); - } - } - return $this; - } - /** * 实例化分页管理器 * @param boolean $page 是否启用分页 @@ -217,4 +181,62 @@ class QueryHelper extends Helper { return PageHelper::instance()->init($this->query, $page, $display, $total, $limit, $template); } + + /** + * QueryHelper call. + * @param string $name 调用方法名称 + * @param array $args 调用参数内容 + * @return $this + */ + public function __call($name, $args) + { + if (is_callable($callable = [$this->query, $name])) { + call_user_func_array($callable, $args); + } + return $this; + } + + /** + * 设置区域查询条件 + * @param string|array $fields 查询字段 + * @param string $split 输入分隔符 + * @param array|string|null $input 输入数据 + * @param string $alias 别名分割符 + * @param callable $callback + * @return $this + */ + private function _setBetweenWhere($fields, $split = ' ', $input = null, $alias = '#', $callback = null) + { + $data = $this->_getInputData($input ?: $this->input); + foreach (is_array($fields) ? $fields : explode(',', $fields) as $field) { + [$dk, $qk] = [$field, $field]; + if (stripos($field, $alias) !== false) { + [$dk, $qk] = explode($alias, $field); + } + if (isset($data[$qk]) && $data[$qk] !== '') { + [$begin, $after] = explode($split, $data[$qk]); + if (is_callable($callback)) { + $after = call_user_func($callback, $after, 'after'); + $begin = call_user_func($callback, $begin, 'begin'); + } + $this->query->whereBetween($dk, [$begin, $after]); + } + } + return $this; + } + + /** + * 获取输入数据 + * @param array|string|null $input + * @return array + */ + private function _getInputData($input): array + { + if (is_array($input)) { + return $input; + } else { + $input = $input ?: 'request'; + return $this->app->request->$input(); + } + } } diff --git a/vendor/zoujingli/think-library/src/service/ExpressService.php b/vendor/zoujingli/think-library/src/service/ExpressService.php index 05be97636..d433a2b81 100644 --- a/vendor/zoujingli/think-library/src/service/ExpressService.php +++ b/vendor/zoujingli/think-library/src/service/ExpressService.php @@ -68,7 +68,7 @@ class ExpressService extends Service public function express($code, $number, $list = []) { // 1-新订单,2-在途中,3-签收,4-问题件 - // 0在途,1揽收,2疑难,3签收,4退签,5派件,6退回 + // 0-在途,1-揽收,2-疑难,3-签收,4-退签,5-派件,6-退回 $ckey = md5("{$code}{$number}"); $cache = $this->app->cache->get($ckey, []); if (!empty($cache)) return $cache; diff --git a/vendor/zoujingli/think-library/src/service/InterfaceService.php b/vendor/zoujingli/think-library/src/service/InterfaceService.php index 8636291c9..ee78c7917 100644 --- a/vendor/zoujingli/think-library/src/service/InterfaceService.php +++ b/vendor/zoujingli/think-library/src/service/InterfaceService.php @@ -34,18 +34,18 @@ class InterfaceService extends Service */ private $debug; - /** - * 接口认证账号 - * @var string - */ - private $appid; - /** * 请求数据 * @var array */ private $input; + /** + * 接口认证账号 + * @var string + */ + private $appid; + /** * 接口认证密钥 * @var string @@ -56,25 +56,22 @@ class InterfaceService extends Service * 接口请求地址 * @var string */ - private $baseapi; + private $baseurl; /** * 接口服务初始化 - * OpenService constructor. + * InterfaceService constructor. * @param App $app - * @param string $appid 接口账号 - * @param string $appkey 接口密钥 - * @param string $baseapi 接口地址 * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function __construct(App $app, $appid = '', $appkey = '', $baseapi = '') + public function __construct(App $app) { parent::__construct($app); - $this->appid = $appid ?: sysconf('data.interface_appid'); - $this->appkey = $appkey ?: sysconf('data.interface_appkey'); - $this->baseapi = $baseapi ?: sysconf('data.interface_baseapi'); + $this->appid = sysconf('data.interface_appid') ?: ''; + $this->appkey = sysconf('data.interface_appkey') ?: ''; + $this->baseurl = sysconf('data.interface_baseapi') ?: ''; } /** @@ -103,7 +100,7 @@ class InterfaceService extends Service */ public function getBaseUrl() { - return $this->baseapi; + return $this->baseurl; } /** @@ -147,6 +144,7 @@ class InterfaceService extends Service */ public function checkInput() { + if ($this->debug) return true; if (empty($this->input)) $this->getInput(false); if ($this->input['appid'] !== $this->appid) return null; return md5("{$this->appid}#{$this->input['data']}#{$this->input['time']}#{$this->appkey}#{$this->input['nostr']}") === $this->input['sign']; @@ -158,6 +156,7 @@ class InterfaceService extends Service */ public function showCheck() { + if ($this->debug) return $this; if (is_null($check = $this->checkInput())) { $this->baseError(lang('think_library_params_failed_auth')); } elseif ($check === false) { @@ -189,11 +188,7 @@ class InterfaceService extends Service public function error($info, $data = '{-null-}', $code = 0) { if ($data === '{-null-}') $data = new \stdClass(); - if ($this->debug) { - $this->baseError($info, $data, $code); - } else { - $this->baseResponse(lang('think_library_response_success'), ['code' => $code, 'info' => $info, 'data' => $data], 1); - } + $this->baseResponse(lang('think_library_response_success'), ['code' => $code, 'info' => $info, 'data' => $data], 1); } /** @@ -205,11 +200,7 @@ class InterfaceService extends Service public function success($info, $data = '{-null-}', $code = 1) { if ($data === '{-null-}') $data = new \stdClass(); - if ($this->debug) { - $this->baseSuccess($info, $data, $code); - } else { - $this->baseResponse(lang('think_library_response_success'), ['code' => $code, 'info' => $info, 'data' => $data], 1); - } + $this->baseResponse(lang('think_library_response_success'), ['code' => $code, 'info' => $info, 'data' => $data], 1); } /** @@ -258,7 +249,7 @@ class InterfaceService extends Service */ public function doRequest(string $uri, array $data = []): array { - $result = json_decode(HttpExtend::post($this->baseapi . $uri, $this->_buildSign($data)), true); + $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']); return $result['data'] ?? [];