Compare commits

...

2 Commits

Author SHA1 Message Date
liuyuhang 944365827d QA 上传文件接口修改为 /admin/upload/index 2024-07-09 16:18:30 +08:00
liuyuhang 347c90afb2 增加上传文件模块 2024-07-09 16:15:32 +08:00
10 changed files with 87 additions and 9 deletions

View File

@ -78,7 +78,7 @@
<el-form-item label="上传图片">
<el-upload
class="avatar-uploader"
action="admin/index/avatar"
action="admin/upload/index"
:show-file-list="false"
:on-success="handleAvatarSuccess"
>
@ -95,7 +95,7 @@
<el-form-item label="上传行程">
<el-upload
class="avatar-uploader"
action="admin/index/avatar"
action="admin/upload/index"
:show-file-list="false"
:on-success="handleSuccess"
>
@ -160,7 +160,7 @@
<el-form-item label="上传图片">
<el-upload
class="avatar-uploader"
action="admin/index/avatar"
action="admin/upload/index"
:show-file-list="false"
:on-success="handleAvatarSuccess"
>
@ -177,7 +177,7 @@
<el-form-item label="上传行程">
<el-upload
class="avatar-uploader"
action="admin/index/avatar"
action="admin/upload/index"
:show-file-list="false"
:on-success="handleSuccess"
>

View File

@ -0,0 +1,41 @@
<?php
namespace app\admin\controller;
use app\model\Admins;
use app\model\Uploads;
use app\model\Backs;
use app\model\Finances;
use app\model\Onlines;
use app\model\Orders;
use DateTime;
use Qiniu\Auth;
use support\Log;
use support\Redis;
use support\Request;
class UploadController extends base
{
public function index(Request $request)
{
$file = $request->file("file");
if (!$file->isValid()) {
return $this->error(400, 'upload fail, code=' . $file->getUploadErrorCode());
}
$now = date_create();
$savepath = sprintf("/uploads/%d/%s/%s", $request->admin->id, $now->format("YmdHisu"), $file->getUploadName());
$file->move(public_path(). $savepath);
$item = new Uploads();
$item->admin_id = $request->admin->id;
$item->filesize = $file->getSize();
$item->filepath = $savepath;
$item->mime = $file->getUploadMimeType();
$item->create_at = $now->getTimestamp();
$item->save();
return $this->success($savepath);
}
}

View File

@ -21,7 +21,8 @@ class adminAuth implements MiddlewareInterface
//白名单
$url = [
'/admin/login',
'admin/index/avatar'
'admin/index/avatar',
'admin/upload/index',
];
if(in_array($path, $url)) {
return $next($request);

View File

@ -0,0 +1,36 @@
<?php
namespace app\model;
/**
* uploads 上传文件
* @property integer $id (主键)
* @property integer $admin_id 谁上传的
* @property integer $filesize 文件大小
* @property string $filepath 存储路径
* @property string $mime mime 类型
* @property integer $create_at 上传时间
*/
class Uploads extends base
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'uploads';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $pk = 'id';
}

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
.pagination-container[data-v-28fdfbeb]{padding:32px 16px;position:fixed;bottom:0;left:0;width:100%;background:#fff;padding:40px 280px;-webkit-box-shadow:0 -2px 10px rgba(0,0,0,.1);box-shadow:0 -2px 10px rgba(0,0,0,.1);z-index:100}.pagination-container.hidden[data-v-28fdfbeb]{display:none}.disable-layer[data-v-25113710]{width:100%;height:100%;background:#f5f7fa;position:absolute;top:0;left:0;z-index:99;opacity:.5}.img-box[data-v-4cd5f696]{position:relative}.el-icon-folder[data-v-4cd5f696]{color:#409eff!important;font-size:100px}.close[data-v-4cd5f696]{position:absolute;top:-10px;right:-8px;font-size:18px;color:#409eff}.mistake-content[data-v-4cd5f696],.qa-desc[data-v-4cd5f696]{display:-webkit-box;display:-ms-flexbox;display:flex}.mistake-left[data-v-4cd5f696]{width:90%}.mistake-right[data-v-4cd5f696]{padding-left:20px;height:auto;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.app-container[data-v-4cd5f696]{position:relative;padding-bottom:60px}[data-v-4cd5f696].el-table--fit{padding-bottom:0!important}.el-table[data-v-4cd5f696],.filter-container[data-v-4cd5f696]{padding-bottom:52px}.mistake-btn[data-v-4cd5f696]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:reverse;-ms-flex-direction:row-reverse;flex-direction:row-reverse;margin-top:10px}.search[data-v-4cd5f696]{margin-left:10px}.avatar-uploader .el-upload[data-v-4cd5f696]{border:1px solid #131313;border-radius:6px;cursor:pointer;position:relative;overflow:hidden}.avatar-uploader .el-upload[data-v-4cd5f696]:hover{border-color:#409eff}.avatar-uploader-icon[data-v-4cd5f696]{border:1px solid #979797;border-radius:15px;font-size:28px;color:#8c939d;width:100px;height:100px;line-height:100px;text-align:center;position:relative}

View File

@ -0,0 +1 @@
.pagination-container[data-v-28fdfbeb]{padding:32px 16px;position:fixed;bottom:0;left:0;width:100%;background:#fff;padding:40px 280px;-webkit-box-shadow:0 -2px 10px rgba(0,0,0,.1);box-shadow:0 -2px 10px rgba(0,0,0,.1);z-index:100}.pagination-container.hidden[data-v-28fdfbeb]{display:none}.disable-layer[data-v-25113710]{width:100%;height:100%;background:#f5f7fa;position:absolute;top:0;left:0;z-index:99;opacity:.5}.img-box[data-v-bc20ec64]{position:relative}.el-icon-folder[data-v-bc20ec64]{color:#409eff!important;font-size:100px}.close[data-v-bc20ec64]{position:absolute;top:-10px;right:-8px;font-size:18px;color:#409eff}.mistake-content[data-v-bc20ec64],.qa-desc[data-v-bc20ec64]{display:-webkit-box;display:-ms-flexbox;display:flex}.mistake-left[data-v-bc20ec64]{width:90%}.mistake-right[data-v-bc20ec64]{padding-left:20px;height:auto;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.app-container[data-v-bc20ec64]{position:relative;padding-bottom:60px}[data-v-bc20ec64].el-table--fit{padding-bottom:0!important}.el-table[data-v-bc20ec64],.filter-container[data-v-bc20ec64]{padding-bottom:52px}.mistake-btn[data-v-bc20ec64]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:reverse;-ms-flex-direction:row-reverse;flex-direction:row-reverse;margin-top:10px}.search[data-v-bc20ec64]{margin-left:10px}.avatar-uploader .el-upload[data-v-bc20ec64]{border:1px solid #131313;border-radius:6px;cursor:pointer;position:relative;overflow:hidden}.avatar-uploader .el-upload[data-v-bc20ec64]:hover{border-color:#409eff}.avatar-uploader-icon[data-v-bc20ec64]{border:1px solid #979797;border-radius:15px;font-size:28px;color:#8c939d;width:100px;height:100px;line-height:100px;text-align:center;position:relative}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long