ComposerUpdate

This commit is contained in:
Anyon 2020-08-26 14:10:07 +08:00
parent 1d38ec30fe
commit f8b3c1ed69
10 changed files with 137 additions and 120 deletions

View File

@ -17,6 +17,7 @@ namespace app\admin\controller;
use think\admin\Controller; use think\admin\Controller;
use think\admin\service\AdminService; use think\admin\service\AdminService;
use think\admin\service\ModuleService;
use think\admin\service\SystemService; use think\admin\service\SystemService;
/** /**
@ -69,6 +70,7 @@ class Config extends Controller
{ {
$this->title = '系统参数配置'; $this->title = '系统参数配置';
$this->isSuper = AdminService::instance()->isSuper(); $this->isSuper = AdminService::instance()->isSuper();
$this->version = ModuleService::instance()->getVersion();
$this->fetch(); $this->fetch();
} }

View File

@ -114,7 +114,7 @@
</tr> </tr>
<tr> <tr>
<td>管理程序</td> <td>管理程序</td>
<td><a target="_blank" href="https://thinkadmin.top">ThinkAdmin Version {$app->config->get('app.thinkadmin_ver','v6')}</a></td> <td><a target="_blank" href="https://thinkadmin.top">ThinkAdmin Version {$version|default='6.0.0'}</a></td>
</tr> </tr>
<tr> <tr>
<td>服务器信息</td> <td>服务器信息</td>

8
composer.lock generated
View File

@ -937,12 +937,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "47525f4cb63fb97937d44b45405a3c348a309cd2" "reference": "1c194b947fb85bd79adc1f821ef06f2f77a35147"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/47525f4cb63fb97937d44b45405a3c348a309cd2", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/1c194b947fb85bd79adc1f821ef06f2f77a35147",
"reference": "47525f4cb63fb97937d44b45405a3c348a309cd2", "reference": "1c194b947fb85bd79adc1f821ef06f2f77a35147",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -987,7 +987,7 @@
], ],
"description": "ThinkPHP v6.0 Development Library", "description": "ThinkPHP v6.0 Development Library",
"homepage": "http://thinkadmin.top", "homepage": "http://thinkadmin.top",
"time": "2020-08-25T05:34:07+00:00" "time": "2020-08-26T03:59:59+00:00"
}, },
{ {
"name": "zoujingli/wechat-developer", "name": "zoujingli/wechat-developer",

View File

@ -963,12 +963,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "47525f4cb63fb97937d44b45405a3c348a309cd2" "reference": "1c194b947fb85bd79adc1f821ef06f2f77a35147"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/47525f4cb63fb97937d44b45405a3c348a309cd2", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/1c194b947fb85bd79adc1f821ef06f2f77a35147",
"reference": "47525f4cb63fb97937d44b45405a3c348a309cd2", "reference": "1c194b947fb85bd79adc1f821ef06f2f77a35147",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -985,7 +985,7 @@
"ext-mbstring": "*", "ext-mbstring": "*",
"topthink/framework": "^6.0" "topthink/framework": "^6.0"
}, },
"time": "2020-08-25T05:34:07+00:00", "time": "2020-08-26T03:59:59+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"think": { "think": {

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php <?php
// This file is automatically generated at:2020-08-25 13:48:22 // This file is automatically generated at:2020-08-26 14:09:52
declare (strict_types = 1); declare (strict_types = 1);
return array ( return array (
0 => 'think\\admin\\Library', 0 => 'think\\admin\\Library',

View File

@ -51,6 +51,12 @@ abstract class Controller extends \stdClass
*/ */
public $request; public $request;
/**
* 控制器中间键
* @var array
*/
protected $middleware = [];
/** /**
* 表单CSRF验证状态 * 表单CSRF验证状态
* @var boolean * @var boolean
@ -63,12 +69,6 @@ abstract class Controller extends \stdClass
*/ */
public $csrf_message; public $csrf_message;
/**
* 控制器中间键
* @var array
*/
protected $middleware = [];
/** /**
* Controller constructor. * Controller constructor.
* @param App $app * @param App $app
@ -188,11 +188,12 @@ abstract class Controller extends \stdClass
/** /**
* 快捷查询逻辑器 * 快捷查询逻辑器
* @param string|Query $dbQuery * @param string|Query $dbQuery
* @param array|string|null $input
* @return QueryHelper * @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);
} }
/** /**

View File

@ -52,11 +52,12 @@ abstract class Service
/** /**
* 静态实例对象 * 静态实例对象
* @param array $args * @param array $var 实例参数
* @param boolean $new 创建新实例
* @return static * @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);
} }
} }

View File

@ -27,31 +27,11 @@ use think\db\Query;
*/ */
class QueryHelper extends Helper class QueryHelper extends Helper
{ {
/** /**
* QueryHelper call. * 初始化默认数据
* @param string $name 调用方法名称 * @var array
* @param array $args 调用参数内容
* @return $this
*/ */
public function __call($name, $args) protected $input;
{
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;
}
/** /**
* 获取当前Db操作对象 * 获取当前Db操作对象
@ -62,16 +42,29 @@ class QueryHelper extends Helper
return $this->query; 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查询条件 * 设置Like查询条件
* @param string|array $fields 查询字段 * @param string|array $fields 查询字段
* @param string $input 输入类型 get|post * @param array|string|null $input 输入数据
* @param string $alias 别名分割符 * @param string $alias 别名分割符
* @return $this * @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) { foreach (is_array($fields) ? $fields : explode(',', $fields) as $field) {
[$dk, $qk] = [$field, $field]; [$dk, $qk] = [$field, $field];
if (stripos($field, $alias) !== false) { if (stripos($field, $alias) !== false) {
@ -85,15 +78,15 @@ class QueryHelper extends Helper
} }
/** /**
* 设置Equal查询条件 * 设置 Equal 查询条件
* @param string|array $fields 查询字段 * @param string|array $fields 查询字段
* @param string $input 输入类型 get|post * @param array|string|null $input 输入类型
* @param string $alias 别名分割符 * @param string $alias 别名分割符
* @return $this * @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) { foreach (is_array($fields) ? $fields : explode(',', $fields) as $field) {
[$dk, $qk] = [$field, $field]; [$dk, $qk] = [$field, $field];
if (stripos($field, $alias) !== false) { if (stripos($field, $alias) !== false) {
@ -110,13 +103,13 @@ class QueryHelper extends Helper
* 设置IN区间查询 * 设置IN区间查询
* @param string $fields 查询字段 * @param string $fields 查询字段
* @param string $split 输入分隔符 * @param string $split 输入分隔符
* @param string $input 输入类型 get|post * @param array|string|null $input 输入数据
* @param string $alias 别名分割符 * @param string $alias 别名分割符
* @return $this * @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) { foreach (is_array($fields) ? $fields : explode(',', $fields) as $field) {
[$dk, $qk] = [$field, $field]; [$dk, $qk] = [$field, $field];
if (stripos($field, $alias) !== false) { if (stripos($field, $alias) !== false) {
@ -133,26 +126,26 @@ class QueryHelper extends Helper
* 设置内容区间查询 * 设置内容区间查询
* @param string|array $fields 查询字段 * @param string|array $fields 查询字段
* @param string $split 输入分隔符 * @param string $split 输入分隔符
* @param string $input 输入类型 get|post * @param array|string|null $input 输入数据
* @param string $alias 别名分割符 * @param string $alias 别名分割符
* @return $this * @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|array $fields 查询字段
* @param string $split 输入分隔符 * @param string $split 输入分隔符
* @param string $input 输入类型 * @param array|string|null $input 输入数据
* @param string $alias 别名分割符 * @param string $alias 别名分割符
* @return $this * @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"; 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|array $fields 查询字段
* @param string $split 输入分隔符 * @param string $split 输入分隔符
* @param string $input 输入类型 * @param array|string|null $input 输入数据
* @param string $alias 别名分割符 * @param string $alias 别名分割符
* @return $this * @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"); 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 是否启用分页 * @param boolean $page 是否启用分页
@ -217,4 +181,62 @@ class QueryHelper extends Helper
{ {
return PageHelper::instance()->init($this->query, $page, $display, $total, $limit, $template); 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();
}
}
} }

View File

@ -68,7 +68,7 @@ class ExpressService extends Service
public function express($code, $number, $list = []) public function express($code, $number, $list = [])
{ {
// 1-新订单,2-在途中,3-签收,4-问题件 // 1-新订单,2-在途中,3-签收,4-问题件
// 0在途1揽收2疑难3签收4退签5派件6退回 // 0-在途1-揽收2-疑难3-签收4-退签5-派件6-退回
$ckey = md5("{$code}{$number}"); $ckey = md5("{$code}{$number}");
$cache = $this->app->cache->get($ckey, []); $cache = $this->app->cache->get($ckey, []);
if (!empty($cache)) return $cache; if (!empty($cache)) return $cache;

View File

@ -34,18 +34,18 @@ class InterfaceService extends Service
*/ */
private $debug; private $debug;
/**
* 接口认证账号
* @var string
*/
private $appid;
/** /**
* 请求数据 * 请求数据
* @var array * @var array
*/ */
private $input; private $input;
/**
* 接口认证账号
* @var string
*/
private $appid;
/** /**
* 接口认证密钥 * 接口认证密钥
* @var string * @var string
@ -56,25 +56,22 @@ class InterfaceService extends Service
* 接口请求地址 * 接口请求地址
* @var string * @var string
*/ */
private $baseapi; private $baseurl;
/** /**
* 接口服务初始化 * 接口服务初始化
* OpenService constructor. * InterfaceService constructor.
* @param App $app * @param App $app
* @param string $appid 接口账号
* @param string $appkey 接口密钥
* @param string $baseapi 接口地址
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
*/ */
public function __construct(App $app, $appid = '', $appkey = '', $baseapi = '') public function __construct(App $app)
{ {
parent::__construct($app); parent::__construct($app);
$this->appid = $appid ?: sysconf('data.interface_appid'); $this->appid = sysconf('data.interface_appid') ?: '';
$this->appkey = $appkey ?: sysconf('data.interface_appkey'); $this->appkey = sysconf('data.interface_appkey') ?: '';
$this->baseapi = $baseapi ?: sysconf('data.interface_baseapi'); $this->baseurl = sysconf('data.interface_baseapi') ?: '';
} }
/** /**
@ -103,7 +100,7 @@ class InterfaceService extends Service
*/ */
public function getBaseUrl() public function getBaseUrl()
{ {
return $this->baseapi; return $this->baseurl;
} }
/** /**
@ -147,6 +144,7 @@ class InterfaceService extends Service
*/ */
public function checkInput() public function checkInput()
{ {
if ($this->debug) return true;
if (empty($this->input)) $this->getInput(false); if (empty($this->input)) $this->getInput(false);
if ($this->input['appid'] !== $this->appid) return null; 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']; 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() public function showCheck()
{ {
if ($this->debug) return $this;
if (is_null($check = $this->checkInput())) { if (is_null($check = $this->checkInput())) {
$this->baseError(lang('think_library_params_failed_auth')); $this->baseError(lang('think_library_params_failed_auth'));
} elseif ($check === false) { } elseif ($check === false) {
@ -189,12 +188,8 @@ class InterfaceService extends Service
public function error($info, $data = '{-null-}', $code = 0) public function error($info, $data = '{-null-}', $code = 0)
{ {
if ($data === '{-null-}') $data = new \stdClass(); 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,12 +200,8 @@ class InterfaceService extends Service
public function success($info, $data = '{-null-}', $code = 1) public function success($info, $data = '{-null-}', $code = 1)
{ {
if ($data === '{-null-}') $data = new \stdClass(); 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 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)) throw new \think\admin\Exception(lang('think_library_response_failed'));
if (empty($result['code'])) throw new \think\admin\Exception($result['info']); if (empty($result['code'])) throw new \think\admin\Exception($result['info']);
return $result['data'] ?? []; return $result['data'] ?? [];