mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-08 19:12:48 +08:00
去除大多数文件的外部功能依赖;
This commit is contained in:
@@ -7,10 +7,9 @@ use app\admin\model\SystemUploadfile;
|
||||
use app\common\controller\AdminController;
|
||||
use app\common\service\MenuService;
|
||||
use app\common\service\UploadService;
|
||||
use EasyAdmin\upload\Uploadfile;
|
||||
use think\db\Query;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Filesystem;
|
||||
|
||||
|
||||
class Ajax extends AdminController
|
||||
{
|
||||
@@ -61,7 +60,7 @@ class Ajax extends AdminController
|
||||
'upload_type' => $this->request->post('upload_type'),
|
||||
'file' => $this->request->file('file'),
|
||||
];
|
||||
|
||||
|
||||
try {
|
||||
|
||||
$upload_service = new UploadService($data['upload_type']);
|
||||
@@ -69,7 +68,6 @@ class Ajax extends AdminController
|
||||
$upload_service->validateException($data['file']);
|
||||
|
||||
$result = $upload_service->save($data['file']);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
@@ -88,35 +86,26 @@ class Ajax extends AdminController
|
||||
'upload_type' => $this->request->post('upload_type'),
|
||||
'file' => $this->request->file('upload'),
|
||||
];
|
||||
$uploadConfig = sysconfig('upload');
|
||||
empty($data['upload_type']) && $data['upload_type'] = $uploadConfig['upload_type'];
|
||||
$rule = [
|
||||
'upload_type|指定上传类型有误' => "in:{$uploadConfig['upload_allow_type']}",
|
||||
'file|文件' => "require|file|fileExt:{$uploadConfig['upload_allow_ext']}|fileSize:{$uploadConfig['upload_allow_size']}",
|
||||
];
|
||||
$this->validate($data, $rule);
|
||||
|
||||
try {
|
||||
$upload = Uploadfile::instance()
|
||||
->setUploadType($data['upload_type'])
|
||||
->setUploadConfig($uploadConfig)
|
||||
->setFile($data['file'])
|
||||
->save();
|
||||
$upload_service = new UploadService($data['upload_type']);
|
||||
|
||||
$upload_service->validateException($data['file']);
|
||||
|
||||
$result = $upload_service->save($data['file']);
|
||||
} catch (\Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($upload['save'] == true) {
|
||||
return json([
|
||||
'error' => [
|
||||
'message' => '上传成功',
|
||||
'number' => 201,
|
||||
],
|
||||
'fileName' => '',
|
||||
'uploaded' => 1,
|
||||
'url' => $upload['url'],
|
||||
]);
|
||||
} else {
|
||||
$this->error($upload['msg']);
|
||||
}
|
||||
|
||||
return json([
|
||||
'error' => [
|
||||
'message' => '上传成功',
|
||||
'number' => 201,
|
||||
],
|
||||
'fileName' => '',
|
||||
'uploaded' => 1,
|
||||
'url' => $result['url'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
namespace app\admin\middleware;
|
||||
|
||||
use app\Request;
|
||||
use EasyAdmin\tool\CommonTool;
|
||||
use think\facade\Log;
|
||||
use think\facade\Request as FacadeRequest;
|
||||
|
||||
/**
|
||||
* 系统操作日志中间件
|
||||
@@ -40,7 +40,7 @@ class SystemLog
|
||||
|
||||
if ($request->isAjax()) {
|
||||
if (in_array($method, ['post', 'put', 'delete'])) {
|
||||
$ip = CommonTool::getRealIp();
|
||||
$ip = FacadeRequest::ip();
|
||||
$data = [
|
||||
'admin_id' => session('admin.id'),
|
||||
'url' => $url,
|
||||
|
||||
@@ -11,7 +11,6 @@ use think\helper\Str;
|
||||
/**
|
||||
* 快速构建系统CURD
|
||||
* Class BuildCurd
|
||||
* @package EasyAdmin\curd
|
||||
*/
|
||||
class BuildCurdService
|
||||
{
|
||||
|
||||
@@ -22,7 +22,6 @@ use think\helper\Str;
|
||||
/**
|
||||
* 节点处理类
|
||||
* Class Node
|
||||
* @package EasyAdmin\auth
|
||||
*/
|
||||
class Node
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user