From 2941eeac1ef0bea20dec6065ae7a18914536625d Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Thu, 3 Sep 2020 18:55:25 +0800 Subject: [PATCH] update --- catch/permissions/controller/User.php | 2 +- catch/permissions/model/Permissions.php | 2 +- catch/system/controller/Attachments.php | 12 ++++++-- catch/system/model/Attachments.php | 18 ++---------- .../system/model/search/AttachmentsSearch.php | 29 +++++++++++++++++++ .../request/sensitiveWord/CreateRequest.php | 2 +- 6 files changed, 45 insertions(+), 20 deletions(-) create mode 100644 catch/system/model/search/AttachmentsSearch.php diff --git a/catch/permissions/controller/User.php b/catch/permissions/controller/User.php index f797fad..77fec8a 100644 --- a/catch/permissions/controller/User.php +++ b/catch/permissions/controller/User.php @@ -49,7 +49,7 @@ class User extends CatchController { $user = $auth->user(); - $roles = $user->getRoles(); + $roles = $user->getRoles()->column('identify'); $permissionIds = $user->getPermissionsBy($user->id); // 缓存用户权限 diff --git a/catch/permissions/model/Permissions.php b/catch/permissions/model/Permissions.php index edd7834..e6cfa1f 100644 --- a/catch/permissions/model/Permissions.php +++ b/catch/permissions/model/Permissions.php @@ -69,7 +69,7 @@ class Permissions extends CatchModel return parent::whereIn('id', $permissionIds) ->field(['permission_name as title', 'id', 'parent_id', 'route', 'icon', 'component', 'redirect', 'module', - 'keepalive as keepAlive', 'hide_children_in_menu', 'type', 'permission_mark', 'status' + 'keepalive as keepAlive', 'type', 'permission_mark', 'status' ]) ->catchOrder() ->select(); diff --git a/catch/system/controller/Attachments.php b/catch/system/controller/Attachments.php index a6ad952..60234a4 100644 --- a/catch/system/controller/Attachments.php +++ b/catch/system/controller/Attachments.php @@ -5,7 +5,7 @@ use catcher\base\CatchController; use catcher\CatchResponse; use catchAdmin\system\model\Attachments as AttachmentsModel; use catcher\Utils; -use think\facade\Filesystem; +use catcher\facade\FileSystem; class Attachments extends CatchController { @@ -39,7 +39,15 @@ class Attachments extends CatchController if ($model->deleteBy($id)) { foreach ($attachments as $attachment) { - Filesystem::delete($attachment->path); + if ($attachment->driver == 'local') { + $localPath = config('filesystem.disks.local.root') . DIRECTORY_SEPARATOR; + $path = $localPath . str_replace('\\','\/', $attachment->path); + if (!FileSystem::exists($path)) { + Filesystem::delete($path); + } + } else { + Filesystem::delete($attachment->path); + } } } diff --git a/catch/system/model/Attachments.php b/catch/system/model/Attachments.php index 8120c74..104ba31 100644 --- a/catch/system/model/Attachments.php +++ b/catch/system/model/Attachments.php @@ -1,12 +1,15 @@ paginate(); } - public function searchFileExtAttr($query, $value, $data) - { - return $query->where('file_ext', $value); - } - - public function searchMimeTypesAttr($query, $value, $data) - { - return $query->where('mime_type', $value); - } - - public function searchDriver($query, $value, $data) - { - return $query->where('driver', $value); - } - /** * * diff --git a/catch/system/model/search/AttachmentsSearch.php b/catch/system/model/search/AttachmentsSearch.php new file mode 100644 index 0000000..b1f0400 --- /dev/null +++ b/catch/system/model/search/AttachmentsSearch.php @@ -0,0 +1,29 @@ +where('file_ext', $value); + } + + public function searchMimeTypesAttr($query, $value, $data) + { + return $query->where('mime_type', $value); + } + + public function searchDriver($query, $value, $data) + { + return $query->where('driver', $value); + } +} \ No newline at end of file diff --git a/catch/system/request/sensitiveWord/CreateRequest.php b/catch/system/request/sensitiveWord/CreateRequest.php index fa9f4c7..8e32b64 100644 --- a/catch/system/request/sensitiveWord/CreateRequest.php +++ b/catch/system/request/sensitiveWord/CreateRequest.php @@ -10,7 +10,7 @@ class CreateRequest extends CatchRequest { // TODO: Implement rules() method. return [ - 'word|词汇' => 'sensitive_word|unique:'.SensitiveWord::class.',word', + 'word|词汇' => 'unique:'.SensitiveWord::class.',word', ]; } }