fix: 修复redis密码 优化权限
This commit is contained in:
@@ -57,6 +57,11 @@ class ExceptionHandle extends ExceptionHandler
|
||||
{
|
||||
switch (true) {
|
||||
case $exception instanceof OperateException:
|
||||
return json([
|
||||
'code' => $exception->getCode() ?? 101,
|
||||
'msg' => $exception->getMessage(),
|
||||
'data' => $exception->getData()
|
||||
]);
|
||||
case $exception instanceof ValidateException:
|
||||
return json(['code' => $exception->getCode() ?? 101, 'msg' => $exception->getMessage()]);
|
||||
case $exception instanceof DumpException:
|
||||
|
||||
@@ -24,4 +24,13 @@ class OperateException extends \Exception
|
||||
$this->message = $message ?: ResultCode::UNKNOWN['msg'];
|
||||
parent::__construct($this->message, $this->code, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取附加数据
|
||||
* @return array
|
||||
*/
|
||||
public function getData(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
@@ -405,9 +405,22 @@ class Upload
|
||||
*/
|
||||
public function fileFilter($file): bool
|
||||
{
|
||||
$this->fileClass = null;
|
||||
$mineType = $file->getUploadMineType();
|
||||
if (in_array($mineType, ['text/x-php', 'text/html'])) {
|
||||
$this->_error = '禁止上传的文件类型';
|
||||
return false;
|
||||
}
|
||||
|
||||
$validate = new UploadFile();
|
||||
$rules = get_object_vars($validate)['rule'];
|
||||
$fileExt = $this->getFileExt($file);
|
||||
$fileExt = $file->getUploadExtension() ?: input('fileExt');
|
||||
|
||||
if (empty($fileExt)) {
|
||||
$this->fileClass = 'file';
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ($rules as $key => $value) {
|
||||
$fileExtArr = explode(',', $value['fileExt']);
|
||||
if (in_array(strtolower($fileExt), $fileExtArr)) {
|
||||
@@ -419,15 +432,13 @@ class Upload
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (in_array($file->getUploadMineType(), ['text/x-php', 'text/html'])) {
|
||||
$this->fileClass = null;
|
||||
}
|
||||
|
||||
if (is_empty($this->fileClass)) {
|
||||
$this->_error = '禁止上传的文件类型';
|
||||
return false;
|
||||
}
|
||||
// 未找到类型或验证文件失败
|
||||
return !empty($this->fileClass);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -447,7 +458,10 @@ class Upload
|
||||
* @param string $filePath
|
||||
* @param array $extend
|
||||
* @return array
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function success(string $msg, string $filePath, array $extend = []): array
|
||||
{
|
||||
|
||||
@@ -9,30 +9,30 @@ class UploadFile extends Validate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
* 格式:'字段名' => ['规则1','规则2'...]
|
||||
* 格式:'字段名' => ['规则1','规则2'...]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $rule = [
|
||||
'images'=>[
|
||||
'fileSize' => 419430400,
|
||||
'fileExt' => 'jpg,jpeg,png,bmp,gif,svg,webp',
|
||||
'fileMime' => 'image/jpeg,image/png,image/gif,image/svg+xml'],
|
||||
'video'=>[
|
||||
'fileSize' => 419430400,
|
||||
'fileExt' => 'flv,swf,mkv,avi,rm,rmvb,mpeg,mpg,ogg,ogv,mov,wmv,mp4,webm,mp3,wav,mid'],
|
||||
'document'=>[
|
||||
'fileSize' => 419430400,
|
||||
'fileExt' => 'txt,doc,xls,ppt,docx,xlsx,pptx'],
|
||||
'files'=>[
|
||||
'fileSize' => 419430400,
|
||||
'fileExt' => 'exe,dll,sys,so,dmg,iso,zip,rar,7z,sql,pem,pdf,psd']
|
||||
];
|
||||
*/
|
||||
public $rule = [
|
||||
'images' => [
|
||||
'fileSize' => 419430400,
|
||||
'fileExt' => 'jpg,jpeg,png,bmp,gif,svg,webp',
|
||||
'fileMime' => 'image/jpeg,image/png,image/gif,image/svg+xml'],
|
||||
'video' => [
|
||||
'fileSize' => 419430400,
|
||||
'fileExt' => 'flv,swf,mkv,avi,rm,rmvb,mpeg,mpg,ogg,ogv,mov,wmv,mp4,webm,mp3,wav,mid'],
|
||||
'document' => [
|
||||
'fileSize' => 419430400,
|
||||
'fileExt' => 'txt,doc,xls,ppt,docx,xlsx,pptx'],
|
||||
'files' => [
|
||||
'fileSize' => 419430400,
|
||||
'fileExt' => 'exe,dll,sys,so,dmg,iso,zip,rar,7z,sql,pem,pdf,psd']
|
||||
];
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
*/
|
||||
protected $message = [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user