From 64ff7652bfc7b76c9710dc9c9583561874d968f5 Mon Sep 17 00:00:00 2001 From: Devil Date: Wed, 23 Jun 2021 19:35:01 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=84=E4=BB=B6=E6=A0=B9=E6=8D=AE=E6=A0=87?= =?UTF-8?q?=E8=AF=86=E5=88=A0=E9=99=A4=E6=96=B0=E5=A2=9E=E9=92=A9=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/service/ResourcesService.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/application/service/ResourcesService.php b/application/service/ResourcesService.php index 4a01d20e0..c881d1390 100755 --- a/application/service/ResourcesService.php +++ b/application/service/ResourcesService.php @@ -425,7 +425,7 @@ class ResourcesService { // 获取附件数据 $where = ['path_type'=>$path_type]; - $data = DB::name('Attachment')->where($where)->column('url'); + $data = DB::name('Attachment')->where($where)->select(); if(!empty($data)) { // 删除数据库数据 @@ -438,13 +438,22 @@ class ResourcesService $path = substr(ROOT_PATH, 0, -1); foreach($data as $v) { - $file = $path.$v; + $file = $path.$v['url']; if(file_exists($file) && is_writable($file)) { \base\FileUtil::UnlinkFile($file); } } } + + // 附件删除成功后处理钩子 + $hook_name = 'plugins_service_attachment_path_type_delete_success'; + Hook::listen($hook_name, [ + 'hook_name' => $hook_name, + 'is_backend' => true, + 'data' => $data, + ]); + return DataReturn('删除成功', 0); }