From 525834a40d98a08da08d9c9ce335c8d98c4802c2 Mon Sep 17 00:00:00 2001 From: Anyon Date: Tue, 12 Jul 2022 11:22:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=87=E4=BB=B6=E6=B8=85?= =?UTF-8?q?=E7=90=86=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/File.php | 14 ++++++++++++++ app/admin/view/file/index.html | 3 +++ 2 files changed, 17 insertions(+) diff --git a/app/admin/controller/File.php b/app/admin/controller/File.php index dd41ff147..c9a675e20 100644 --- a/app/admin/controller/File.php +++ b/app/admin/controller/File.php @@ -80,4 +80,18 @@ class File extends Controller { SystemFile::mDelete(); } + + /** + * 清理重复文件 + * @auth true + * @return void + */ + public function distinct() + { + $map = ['uuid' => AdminService::getUserId()]; + $db1 = SystemFile::mk()->fieldRaw('max(id) id')->where($map)->group('hash'); + $db2 = $this->app->db->table($db1->buildSql())->alias('dt')->field('id'); + SystemFile::mk()->whereRaw("id not in {$db2->buildSql()}")->delete(); + $this->success('清理重复文件记录'); + } } \ No newline at end of file diff --git a/app/admin/view/file/index.html b/app/admin/view/file/index.html index 3e1584d7f..bf975b95e 100644 --- a/app/admin/view/file/index.html +++ b/app/admin/view/file/index.html @@ -1,6 +1,9 @@ {extend name='table'} {block name="button"} + +清理重复 + 批量删除