This commit is contained in:
JaguarJack 2020-09-03 18:55:25 +08:00
parent e0007d4150
commit 2941eeac1e
6 changed files with 45 additions and 20 deletions

View File

@ -49,7 +49,7 @@ class User extends CatchController
{
$user = $auth->user();
$roles = $user->getRoles();
$roles = $user->getRoles()->column('identify');
$permissionIds = $user->getPermissionsBy($user->id);
// 缓存用户权限

View File

@ -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();

View File

@ -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);
}
}
}

View File

@ -1,12 +1,15 @@
<?php
namespace catchAdmin\system\model;
use catchAdmin\system\model\search\AttachmentsSearch;
use catcher\base\CatchModel;
use think\file\UploadedFile;
use think\Model;
class Attachments extends CatchModel
{
use AttachmentsSearch;
protected $name = 'attachments';
protected $field = [
@ -30,21 +33,6 @@ class Attachments extends CatchModel
->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);
}
/**
*
*

View File

@ -0,0 +1,29 @@
<?php
// +----------------------------------------------------------------------
// | CatchAdmin [Just Like ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
// +----------------------------------------------------------------------
// | Author: JaguarJack [ njphper@gmail.com ]
// +----------------------------------------------------------------------
namespace catchAdmin\system\model\search;
trait AttachmentsSearch
{
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);
}
}

View File

@ -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',
];
}
}