From 0f95e38167cd68365cfa61f681f2afca875b8ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Fri, 19 Mar 2021 14:38:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E6=B8=85?= =?UTF-8?q?=E7=A9=BA=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/api/Plugs.php | 14 ++++---------- vendor/composer/installed.json | 8 ++++---- vendor/services.php | 2 +- .../think-library/src/helper/QueryHelper.php | 11 +++++++++++ 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/app/admin/controller/api/Plugs.php b/app/admin/controller/api/Plugs.php index dccb4380b..da13da5cb 100644 --- a/app/admin/controller/api/Plugs.php +++ b/app/admin/controller/api/Plugs.php @@ -81,19 +81,13 @@ class Plugs extends Controller if (AdminService::instance()->isSuper()) try { $this->app->db->transaction(function () { [$tmpdata, $newdata] = [[], []]; - foreach ($this->app->db->name('SystemConfig')->cursor() as $item) { + foreach ($this->app->db->name('SystemConfig')->order('type,name asc')->cursor() as $item) { $tmpdata[$item['type']][$item['name']] = $item['value']; } - ksort($tmpdata); - foreach ($tmpdata as $type => $items) { - ksort($items); - foreach ($items as $name => $value) { - $newdata[] = ['type' => $type, 'name' => $name, 'value' => $value]; - } + foreach ($tmpdata as $type => $items) foreach ($items as $name => $value) { + $newdata[] = ['type' => $type, 'name' => $name, 'value' => $value]; } - $sql = "truncate table {$this->app->db->name('SystemConfig')->getTable()}"; - $this->app->db->execute($sql); - $this->app->db->name('SystemConfig')->insertAll($newdata); + $this->_query('SystemConfig')->empty()->insertAll($newdata); }); $this->app->cache->delete('SystemConfig'); sysoplog('系统运维管理', '清理系统参数配置成功'); diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 33c2e9d4d..858a3ddbc 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -834,12 +834,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "fdd8a98cc3538fecdea82378615ac65774100c62" + "reference": "9aa8249ae2efa2b5e3fa3cf76c4a7b3c1f61122d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/fdd8a98cc3538fecdea82378615ac65774100c62", - "reference": "fdd8a98cc3538fecdea82378615ac65774100c62", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/9aa8249ae2efa2b5e3fa3cf76c4a7b3c1f61122d", + "reference": "9aa8249ae2efa2b5e3fa3cf76c4a7b3c1f61122d", "shasum": "", "mirrors": [ { @@ -856,7 +856,7 @@ "ext-mbstring": "*", "topthink/framework": "^6.0" }, - "time": "2021-03-19T02:16:27+00:00", + "time": "2021-03-19T06:30:50+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index 5ba5d6b19..3ab35735c 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\admin\\Library', diff --git a/vendor/zoujingli/think-library/src/helper/QueryHelper.php b/vendor/zoujingli/think-library/src/helper/QueryHelper.php index 6b36c763d..8a52e981b 100644 --- a/vendor/zoujingli/think-library/src/helper/QueryHelper.php +++ b/vendor/zoujingli/think-library/src/helper/QueryHelper.php @@ -186,6 +186,17 @@ class QueryHelper extends Helper return PageHelper::instance()->init($this->query, $page, $display, $total, $limit, $template); } + /** + * 清空数据并保留表结构 + * @return $this + */ + public function empty(): QueryHelper + { + $table = $this->query->getTable(); + $this->app->db->execute("truncate table `{$table}`"); + return $this; + } + /** * QueryHelper call. * @param string $name 调用方法名称