up.
This commit is contained in:
parent
e2c86c0c6d
commit
f9631ff92f
@ -6,6 +6,8 @@ use app\BaseController;
|
|||||||
use app\entity\SysFileRecord;
|
use app\entity\SysFileRecord;
|
||||||
use app\service\CurdService;
|
use app\service\CurdService;
|
||||||
use think\db\exception\DbException;
|
use think\db\exception\DbException;
|
||||||
|
use think\exception\FileException;
|
||||||
|
use think\exception\ValidateException;
|
||||||
use think\response\Json;
|
use think\response\Json;
|
||||||
|
|
||||||
class FileController extends BaseController
|
class FileController extends BaseController
|
||||||
@ -42,6 +44,15 @@ class FileController extends BaseController
|
|||||||
public function upload()
|
public function upload()
|
||||||
{
|
{
|
||||||
$file = $this->request->file('file');
|
$file = $this->request->file('file');
|
||||||
|
if (empty($file)) {
|
||||||
|
return $this->writeError('文件不存在');
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$result = filesystem()->upload($file, 0, $this->auth->userId);
|
||||||
|
} catch (ValidateException|FileException $e) {
|
||||||
|
return $this->writeError($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->writeSuccess('ok', $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -13,7 +13,7 @@ class ClientMiddleware extends Middleware
|
|||||||
{
|
{
|
||||||
$clientName = $request->header('client', '');
|
$clientName = $request->header('client', '');
|
||||||
if(empty($clientName)) {
|
if(empty($clientName)) {
|
||||||
return response('设备未授权',200);
|
return \json('设备未授权');
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* 客户端信息
|
* 客户端信息
|
||||||
|
|||||||
@ -1,15 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use app\AppService;
|
use app\AppService;
|
||||||
use app\service\ConfigService;
|
use app\service\{ConfigService, DictionaryService, FileService, SecurityService};
|
||||||
use app\service\DictionaryService;
|
|
||||||
use app\service\SecurityService;
|
|
||||||
|
|
||||||
// 系统服务定义文件
|
// 系统服务定义文件
|
||||||
// 服务在完成全局初始化之后执行
|
// 服务在完成全局初始化之后执行
|
||||||
return [
|
return [
|
||||||
|
/*
|
||||||
|
* 应用服务
|
||||||
|
*/
|
||||||
AppService::class,
|
AppService::class,
|
||||||
|
/*
|
||||||
|
* 配置服务
|
||||||
|
*/
|
||||||
ConfigService::class,
|
ConfigService::class,
|
||||||
|
/*
|
||||||
|
* 字典服务
|
||||||
|
*/
|
||||||
DictionaryService::class,
|
DictionaryService::class,
|
||||||
|
/*
|
||||||
|
* 系统安全服务
|
||||||
|
*/
|
||||||
SecurityService::class,
|
SecurityService::class,
|
||||||
|
/*
|
||||||
|
* 文件管理服务
|
||||||
|
*/
|
||||||
|
FileService::class,
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user