From bec782fd37e6ce3da4682b02ccd87e42b7e292d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Tue, 22 Jun 2021 15:30:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5Library=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=20Model=20=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vendor/composer/installed.json | 24 +++++---- vendor/composer/installed.php | 12 ++--- vendor/services.php | 2 +- .../topthink/think-helper/src/Collection.php | 20 ++++--- vendor/zoujingli/think-library/.gitignore | 5 +- .../think-library/src/Controller.php | 11 ++-- .../zoujingli/think-library/src/Exception.php | 18 +++---- vendor/zoujingli/think-library/src/Helper.php | 26 ++++++--- .../zoujingli/think-library/src/Service.php | 4 +- vendor/zoujingli/think-library/src/common.php | 3 +- .../src/extend/JsonRpcServer.php | 2 +- .../think-library/src/helper/DeleteHelper.php | 6 +-- .../think-library/src/helper/FormHelper.php | 6 +-- .../think-library/src/helper/PageHelper.php | 54 +++++-------------- .../think-library/src/helper/QueryHelper.php | 8 +-- .../think-library/src/helper/SaveHelper.php | 3 +- .../think-library/src/service/MenuService.php | 2 +- .../src/service/SystemService.php | 5 +- 18 files changed, 105 insertions(+), 106 deletions(-) diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 9086b7f48..3e726fa3e 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -594,17 +594,17 @@ }, { "name": "topthink/think-helper", - "version": "v3.1.4", - "version_normalized": "3.1.4.0", + "version": "v3.1.5", + "version_normalized": "3.1.5.0", "source": { "type": "git", "url": "https://github.com/top-think/think-helper.git", - "reference": "c28d37743bda4a0455286ca85b17b5791d626e10" + "reference": "f98e3ad44acd27ae85a4d923b1bdfd16c6d8d905" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-helper/zipball/c28d37743bda4a0455286ca85b17b5791d626e10", - "reference": "c28d37743bda4a0455286ca85b17b5791d626e10", + "url": "https://api.github.com/repos/top-think/think-helper/zipball/f98e3ad44acd27ae85a4d923b1bdfd16c6d8d905", + "reference": "f98e3ad44acd27ae85a4d923b1bdfd16c6d8d905", "shasum": "", "mirrors": [ { @@ -616,7 +616,7 @@ "require": { "php": ">=7.1.0" }, - "time": "2019-11-08T08:01:10+00:00", + "time": "2021-06-21T06:17:31+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -638,6 +638,10 @@ } ], "description": "The ThinkPHP6 Helper Package", + "support": { + "issues": "https://github.com/top-think/think-helper/issues", + "source": "https://github.com/top-think/think-helper/tree/v3.1.5" + }, "install-path": "../topthink/think-helper" }, { @@ -849,12 +853,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "283b25735511092a6c1c48e4d55b919cf1e09e30" + "reference": "611043ad1974ab0926868bb44b1b2491fee13114" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/283b25735511092a6c1c48e4d55b919cf1e09e30", - "reference": "283b25735511092a6c1c48e4d55b919cf1e09e30", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/611043ad1974ab0926868bb44b1b2491fee13114", + "reference": "611043ad1974ab0926868bb44b1b2491fee13114", "shasum": "", "mirrors": [ { @@ -871,7 +875,7 @@ "ext-mbstring": "*", "topthink/framework": "^6.0" }, - "time": "2021-06-18T08:57:57+00:00", + "time": "2021-06-22T07:23:58+00:00", "default-branch": true, "type": "library", "extra": { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 2e44dd24a..999dedad4 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '43a8afea8902a5269d27519ebb31caa0705e2c82', + 'reference' => '9b4e299239c063b71f431d974c0754fadb9a6624', 'name' => 'zoujingli/thinkadmin', 'dev' => false, ), @@ -92,12 +92,12 @@ 'dev_requirement' => false, ), 'topthink/think-helper' => array( - 'pretty_version' => 'v3.1.4', - 'version' => '3.1.4.0', + 'pretty_version' => 'v3.1.5', + 'version' => '3.1.5.0', 'type' => 'library', 'install_path' => __DIR__ . '/../topthink/think-helper', 'aliases' => array(), - 'reference' => 'c28d37743bda4a0455286ca85b17b5791d626e10', + 'reference' => 'f98e3ad44acd27ae85a4d923b1bdfd16c6d8d905', 'dev_requirement' => false, ), 'topthink/think-orm' => array( @@ -144,7 +144,7 @@ 'aliases' => array( 0 => '9999999-dev', ), - 'reference' => '283b25735511092a6c1c48e4d55b919cf1e09e30', + 'reference' => '611043ad1974ab0926868bb44b1b2491fee13114', 'dev_requirement' => false, ), 'zoujingli/thinkadmin' => array( @@ -153,7 +153,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '43a8afea8902a5269d27519ebb31caa0705e2c82', + 'reference' => '9b4e299239c063b71f431d974c0754fadb9a6624', 'dev_requirement' => false, ), 'zoujingli/wechat-developer' => array( diff --git a/vendor/services.php b/vendor/services.php index e7c75c8b9..3c48bc2a4 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\admin\\Library', diff --git a/vendor/topthink/think-helper/src/Collection.php b/vendor/topthink/think-helper/src/Collection.php index 905f3f86b..fa408c25a 100644 --- a/vendor/topthink/think-helper/src/Collection.php +++ b/vendor/topthink/think-helper/src/Collection.php @@ -242,15 +242,17 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria * @access public * @param mixed $value 元素 * @param string $key KEY - * @return void + * @return $this */ - public function push($value, string $key = null): void + public function push($value, string $key = null) { if (is_null($key)) { $this->items[] = $value; } else { $this->items[$key] = $value; } + + return $this; } /** @@ -277,15 +279,17 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria * @access public * @param mixed $value 元素 * @param string $key KEY - * @return void + * @return $this */ - public function unshift($value, string $key = null): void + public function unshift($value, string $key = null) { if (is_null($key)) { array_unshift($this->items, $value); } else { $this->items = [$key => $value] + $this->items; } + + return $this; } /** @@ -477,7 +481,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria * @param string|null $indexKey 作为索引值的列 * @return array */ - public function column(?string $columnKey, string $indexKey = null) + public function column( ? string $columnKey, string $indexKey = null) { return array_column($this->items, $columnKey, $indexKey); } @@ -515,7 +519,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria $fieldA = $a[$field] ?? null; $fieldB = $b[$field] ?? null; - return 'desc' == strtolower($order) ? $fieldB > $fieldA : $fieldA > $fieldB; + return 'desc' == strtolower($order) ? intval($fieldB > $fieldA) : intval($fieldA > $fieldB); }); } @@ -535,7 +539,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria } /** - * 获取最第一个单元数据 + * 获取第一个单元数据 * * @access public * @param callable|null $callback @@ -623,7 +627,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria * @param integer $options json参数 * @return string */ - public function toJson(int $options = JSON_UNESCAPED_UNICODE): string + public function toJson(int $options = JSON_UNESCAPED_UNICODE) : string { return json_encode($this->toArray(), $options); } diff --git a/vendor/zoujingli/think-library/.gitignore b/vendor/zoujingli/think-library/.gitignore index b7f883d2c..821c524b0 100644 --- a/vendor/zoujingli/think-library/.gitignore +++ b/vendor/zoujingli/think-library/.gitignore @@ -1,8 +1,7 @@ .git .svn .idea -!.gitignore -!composer.json /composer.lock /vendor -/test.php \ No newline at end of file +!.gitignore +!composer.json diff --git a/vendor/zoujingli/think-library/src/Controller.php b/vendor/zoujingli/think-library/src/Controller.php index f815f80dd..5b1736131 100644 --- a/vendor/zoujingli/think-library/src/Controller.php +++ b/vendor/zoujingli/think-library/src/Controller.php @@ -32,6 +32,7 @@ use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; use think\db\Query; use think\exception\HttpResponseException; +use think\Model; use think\Request; /** @@ -183,7 +184,7 @@ abstract class Controller extends stdClass /** * 快捷查询逻辑器 - * @param string|Query $dbQuery + * @param Model|Query|string $dbQuery * @param array|string|null $input * @return QueryHelper */ @@ -194,7 +195,7 @@ abstract class Controller extends stdClass /** * 快捷分页逻辑器 - * @param string|Query $dbQuery + * @param Model|Query|string $dbQuery * @param boolean $page 是否启用分页 * @param boolean $display 是否渲染模板 * @param boolean|integer $total 集合分页记录数 @@ -212,7 +213,7 @@ abstract class Controller extends stdClass /** * 快捷表单逻辑器 - * @param string|Query $dbQuery + * @param Model|Query|string $dbQuery * @param string $template 模板名称 * @param string $field 指定数据对象主键 * @param array $where 额外更新条件 @@ -240,7 +241,7 @@ abstract class Controller extends stdClass /** * 快捷更新逻辑器 - * @param string|Query $dbQuery + * @param Model|Query|string $dbQuery * @param array $data 表单扩展数据 * @param string $field 数据对象主键 * @param array $where 额外更新条件 @@ -254,7 +255,7 @@ abstract class Controller extends stdClass /** * 快捷删除逻辑器 - * @param string|Query $dbQuery + * @param Model|Query|string $dbQuery * @param string $field 数据对象主键 * @param array $where 额外更新条件 * @return boolean|null diff --git a/vendor/zoujingli/think-library/src/Exception.php b/vendor/zoujingli/think-library/src/Exception.php index fcd90b41d..737d1669e 100644 --- a/vendor/zoujingli/think-library/src/Exception.php +++ b/vendor/zoujingli/think-library/src/Exception.php @@ -42,15 +42,6 @@ class Exception extends \Exception parent::__construct($message, $code); } - /** - * 设置异常停止数据 - * @param mixed $data - */ - public function setData($data) - { - $this->data = $data; - } - /** * 获取异常停止数据 * @return mixed @@ -60,4 +51,13 @@ class Exception extends \Exception return $this->data; } + /** + * 设置异常停止数据 + * @param mixed $data + */ + public function setData($data) + { + $this->data = $data; + } + } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/Helper.php b/vendor/zoujingli/think-library/src/Helper.php index ca368fda0..10eec34ff 100644 --- a/vendor/zoujingli/think-library/src/Helper.php +++ b/vendor/zoujingli/think-library/src/Helper.php @@ -19,8 +19,9 @@ namespace think\admin; use think\App; use think\Container; -use think\Db; +use think\db\BaseQuery; use think\db\Query; +use think\Model; /** * 控制器挂件 @@ -36,8 +37,14 @@ abstract class Helper public $app; /** - * 数据库实例 - * @var Db|Query + * 数据模型实例 + * @var Model + */ + public $model; + + /** + * 数据查询实例 + * @var Query */ public $query; @@ -60,12 +67,19 @@ abstract class Helper /** * 获取数据库对象 - * @param string|Db|Query $dbQuery - * @return Db|Query + * @param Model|Query|string $dbQuery + * @return Query|mixed */ protected function buildQuery($dbQuery) { - return is_string($dbQuery) ? $this->app->db->name($dbQuery) : $dbQuery; + if (is_string($dbQuery)) { + $this->query = $this->app->db->name($dbQuery); + } elseif ($dbQuery instanceof \think\Model) { + $this->query = $dbQuery->db(); + } elseif ($dbQuery instanceof BaseQuery) { + $this->query = $dbQuery; + } + return $this->query; } /** diff --git a/vendor/zoujingli/think-library/src/Service.php b/vendor/zoujingli/think-library/src/Service.php index 33f192757..502f01f3c 100644 --- a/vendor/zoujingli/think-library/src/Service.php +++ b/vendor/zoujingli/think-library/src/Service.php @@ -45,18 +45,16 @@ abstract class Service /** * 初始化服务 - * @return static */ protected function initialize() { - return $this; } /** * 静态实例对象 * @param array $var 实例参数 * @param boolean $new 创建新实例 - * @return static + * @return static|mixed */ public static function instance(array $var = [], bool $new = false) { diff --git a/vendor/zoujingli/think-library/src/common.php b/vendor/zoujingli/think-library/src/common.php index 00105133d..29e494786 100644 --- a/vendor/zoujingli/think-library/src/common.php +++ b/vendor/zoujingli/think-library/src/common.php @@ -23,6 +23,7 @@ use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; use think\db\Query; +use think\Model; if (!function_exists('p')) { /** @@ -264,7 +265,7 @@ if (!function_exists('http_post')) { if (!function_exists('data_save')) { /** * 数据增量保存 - * @param Query|string $dbQuery + * @param Model|Query|string $dbQuery * @param array $data 需要保存或更新的数据 * @param string $key 条件主键限制 * @param array $where 其它的where条件 diff --git a/vendor/zoujingli/think-library/src/extend/JsonRpcServer.php b/vendor/zoujingli/think-library/src/extend/JsonRpcServer.php index be799519b..a0802379d 100644 --- a/vendor/zoujingli/think-library/src/extend/JsonRpcServer.php +++ b/vendor/zoujingli/think-library/src/extend/JsonRpcServer.php @@ -73,7 +73,7 @@ class JsonRpcServer $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]; + $response = ['jsonrpc' => '2.0', 'id' => $request['id'] ?? '0', 'result' => null, 'error' => $error]; } else try { // Executes the task on local object if (method_exists($object, $request['method'])) { diff --git a/vendor/zoujingli/think-library/src/helper/DeleteHelper.php b/vendor/zoujingli/think-library/src/helper/DeleteHelper.php index 5ae0498bd..5164ca5f5 100644 --- a/vendor/zoujingli/think-library/src/helper/DeleteHelper.php +++ b/vendor/zoujingli/think-library/src/helper/DeleteHelper.php @@ -18,9 +18,9 @@ declare (strict_types=1); namespace think\admin\helper; use think\admin\Helper; -use think\Db; use think\db\exception\DbException; use think\db\Query; +use think\Model; /** * 通用删除管理器 @@ -31,7 +31,7 @@ class DeleteHelper extends Helper { /** * 逻辑器初始化 - * @param string|Db|Query $dbQuery + * @param Model|Query|string $dbQuery * @param string $field 操作数据主键 * @param array $where 额外更新条件 * @return boolean|null @@ -45,7 +45,7 @@ class DeleteHelper extends Helper // 查询限制处理 if (!empty($where)) $query->where($where); if (!isset($where[$field]) && is_string($value)) { - $query->whereIn($field, explode(',', $value)); + $query->whereIn($field, str2arr($value)); } // 前置回调处理 if (false === $this->class->callback('_delete_filter', $query, $where)) { diff --git a/vendor/zoujingli/think-library/src/helper/FormHelper.php b/vendor/zoujingli/think-library/src/helper/FormHelper.php index 0d1139c60..cec90171a 100644 --- a/vendor/zoujingli/think-library/src/helper/FormHelper.php +++ b/vendor/zoujingli/think-library/src/helper/FormHelper.php @@ -18,11 +18,11 @@ 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; +use think\Model; /** * 表单视图管理器 @@ -34,7 +34,7 @@ class FormHelper extends Helper /** * 逻辑器初始化 - * @param string|Db|Query $dbQuery + * @param Model|Query|string $dbQuery * @param string $template 模板名称 * @param string $field 指定数据主键 * @param array $where 额外更新条件 @@ -48,7 +48,7 @@ class FormHelper extends Helper { $query = $this->buildQuery($dbQuery); $field = $field ?: ($query->getPk() ?: 'id'); - $value = input($field, $data[$field] ?? null); + $value = $data[$field] ?? input($field); if ($this->app->request->isGet()) { if ($value !== null) { $find = $query->where([$field => $value])->where($where)->find(); diff --git a/vendor/zoujingli/think-library/src/helper/PageHelper.php b/vendor/zoujingli/think-library/src/helper/PageHelper.php index ad90d75b3..b3128db08 100644 --- a/vendor/zoujingli/think-library/src/helper/PageHelper.php +++ b/vendor/zoujingli/think-library/src/helper/PageHelper.php @@ -22,6 +22,7 @@ use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; use think\db\Query; +use think\Model; /** * 列表处理管理器 @@ -33,7 +34,7 @@ class PageHelper extends Helper /** * 逻辑器初始化 - * @param string|Query $dbQuery + * @param Model|Query|string $dbQuery * @param boolean $page 是否启用分页 * @param boolean $display 是否渲染模板 * @param boolean|integer $total 集合分页记录数 @@ -48,9 +49,18 @@ class PageHelper extends Helper { $this->query = $this->buildQuery($dbQuery); // 数据列表排序自动处理 - if ($this->app->request->isPost()) $this->_sortAction(); - // 列表设置默认排序处理 - if (!$this->query->getOptions('order')) $this->_orderAction(); + if ($this->app->request->isPost() && $this->app->request->post('action') === 'sort') { + if (in_array('sort', $this->query->getTableFields())) { + if ($this->app->request->has($pk = $this->query->getPk() ?: 'id', 'post')) { + $map = [$pk => $this->app->request->post($pk, 0)]; + $data = ['sort' => intval($this->app->request->post('sort', 0))]; + if ($this->app->db->table($this->query->getTable())->where($map)->update($data) !== false) { + $this->class->success(lang('think_library_sort_success'), ''); + } + } + } + $this->class->error(lang('think_library_sort_error')); + } // 列表分页及结果集处理 if ($page) { if (empty($limit)) { @@ -92,40 +102,4 @@ class PageHelper extends Helper } return $result; } - - /** - * 执行列表排序操作 - * POST 提交 {action:sort,PK:$PK,SORT:$SORT} - * @throws DbException - */ - private function _sortAction() - { - if ($this->app->request->post('action') === 'sort') { - if (method_exists($this->query, 'getTableFields') && in_array('sort', $this->query->getTableFields())) { - $pk = $this->query->getPk() ?: 'id'; - if ($this->app->request->has($pk, 'post')) { - $map = [$pk => $this->app->request->post($pk, 0)]; - $data = ['sort' => intval($this->app->request->post('sort', 0))]; - if ($this->app->db->table($this->query->getTable())->where($map)->update($data) !== false) { - $this->class->success(lang('think_library_sort_success'), ''); - } - } - } - $this->class->error(lang('think_library_sort_error')); - } - } - - /** - * 列表默认排序处理 - * 未配置排序规则时自动按SORT排序 - */ - private function _orderAction() - { - if (method_exists($this->query, 'getTableFields')) { - if (in_array('sort', $this->query->getTableFields())) { - $this->query->order('sort desc'); - } - } - } - } diff --git a/vendor/zoujingli/think-library/src/helper/QueryHelper.php b/vendor/zoujingli/think-library/src/helper/QueryHelper.php index 523979821..2dbd9d928 100644 --- a/vendor/zoujingli/think-library/src/helper/QueryHelper.php +++ b/vendor/zoujingli/think-library/src/helper/QueryHelper.php @@ -18,11 +18,11 @@ 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; +use think\Model; /** * 搜索条件处理器 @@ -41,16 +41,16 @@ class QueryHelper extends Helper /** * 获取当前Db操作对象 - * @return Db|Query + * @return Query */ - public function db() + public function db(): Query { return $this->query; } /** * 逻辑器初始化 - * @param string|Query|Db $dbQuery + * @param Model|Query|string $dbQuery * @param array|string|null $input 输入数据 * @return $this */ diff --git a/vendor/zoujingli/think-library/src/helper/SaveHelper.php b/vendor/zoujingli/think-library/src/helper/SaveHelper.php index f797bc148..ce83196e0 100644 --- a/vendor/zoujingli/think-library/src/helper/SaveHelper.php +++ b/vendor/zoujingli/think-library/src/helper/SaveHelper.php @@ -20,6 +20,7 @@ namespace think\admin\helper; use think\admin\Helper; use think\db\exception\DbException; use think\db\Query; +use think\Model; /** * 数据更新管理器 @@ -31,7 +32,7 @@ class SaveHelper extends Helper /** * 逻辑器初始化 - * @param Query|string $dbQuery + * @param Model|Query|string $dbQuery * @param array $data 表单扩展数据 * @param string $field 数据对象主键 * @param array $where 额外更新条件 diff --git a/vendor/zoujingli/think-library/src/service/MenuService.php b/vendor/zoujingli/think-library/src/service/MenuService.php index 069adff64..440356fb6 100644 --- a/vendor/zoujingli/think-library/src/service/MenuService.php +++ b/vendor/zoujingli/think-library/src/service/MenuService.php @@ -58,7 +58,7 @@ class MenuService extends Service public function getTree(): array { $query = $this->app->db->name('SystemMenu'); - $query->where(['status' => '1'])->order('sort desc,id asc'); + $query->where(['status' => 1])->order('sort desc,id asc'); return $this->_buildData(DataExtend::arr2tree($query->select()->toArray())); } diff --git a/vendor/zoujingli/think-library/src/service/SystemService.php b/vendor/zoujingli/think-library/src/service/SystemService.php index 2c2d12001..31ebe567b 100644 --- a/vendor/zoujingli/think-library/src/service/SystemService.php +++ b/vendor/zoujingli/think-library/src/service/SystemService.php @@ -25,6 +25,7 @@ use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; use think\db\Query; use think\helper\Str; +use think\Model; /** * 系统参数管理服务 @@ -106,7 +107,7 @@ class SystemService extends Service /** * 数据增量保存 - * @param Query|string $query 数据查询对象 + * @param Model|Query|string $query 数据查询对象 * @param array $data 需要保存的数据 * @param string $key 更新条件查询主键 * @param array $map 额外更新查询条件 @@ -117,6 +118,7 @@ class SystemService extends Service */ public function save($query, array $data, string $key = 'id', array $map = []) { + if ($query instanceof Model) $query = $query->db(); 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) { @@ -125,6 +127,7 @@ class SystemService extends Service $query->where([$key => $value]); } if (($info = (clone $query)->find()) && !empty($info)) { + if ($info instanceof Model) $info = $info->toArray(); $query->update($data); return $info[$key] ?? true; } else {