mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-29 14:01:07 +00:00
更新扫码上传图片
This commit is contained in:
parent
7286d15209
commit
fbe9a80577
@ -12,6 +12,8 @@
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\system\attachment\SystemAttachmentServices;
|
||||
use crmeb\services\CacheService;
|
||||
use think\Response;
|
||||
|
||||
@ -44,4 +46,30 @@ class PublicController
|
||||
{
|
||||
return app('json')->success(getWorkerManUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码上传
|
||||
* @param Request $request
|
||||
* @param int $upload_type
|
||||
* @param int $type
|
||||
* @return Response
|
||||
* @author 吴汐
|
||||
* @email 442384644@qq.com
|
||||
* @date 2023/06/13
|
||||
*/
|
||||
public function scanUpload(Request $request, $upload_type = 0, $type = 0)
|
||||
{
|
||||
[$pid, $file, $menuName, $uploadToken] = $request->postMore([
|
||||
['pid', 0],
|
||||
['file', 'file'],
|
||||
['menu_name', ''],
|
||||
['uploadToken', '']
|
||||
], true);
|
||||
$service = app()->make(SystemAttachmentServices::class);
|
||||
if ($service->cacheDriver()->get('scan_upload') != $uploadToken) {
|
||||
return app('json')->fail(410086);
|
||||
}
|
||||
$service->upload((int)$pid, $file, $upload_type, $type, $menuName);
|
||||
return app('json')->success(100032);
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,4 +135,19 @@ class SystemAttachment extends AuthController
|
||||
$res = $this->service->videoUpload($data, $_FILES['file']);
|
||||
return app('json')->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扫码上传页面链接以及参数
|
||||
* @return \think\Response
|
||||
* @author 吴汐
|
||||
* @email 442384644@qq.com
|
||||
* @date 2023/06/13
|
||||
*/
|
||||
public function scanUploadQrcode()
|
||||
{
|
||||
$uploadToken = md5(time());
|
||||
$this->service->cacheDriver()->set('scan_upload', $uploadToken, 600);
|
||||
$url = sys_config('site_url') . '/app/upload?token=' . $uploadToken;
|
||||
return app('json')->success(['url' => $url]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +42,9 @@ Route::group('file', function () {
|
||||
Route::get('upload_type', 'v1.file.SystemAttachment/uploadType')->option(['real_name' => '上传类型']);
|
||||
//分片上传本地视频
|
||||
Route::post('video_upload', 'v1.file.SystemAttachment/videoUpload')->option(['real_name' => '分片上传本地视频']);
|
||||
|
||||
//获取扫码上传页面链接以及参数
|
||||
Route::get('scan_upload/qrcode', 'v1.file.SystemAttachment/scanUploadQrcode')->option(['real_name' => '扫码上传页面链接']);
|
||||
})->middleware([
|
||||
\app\http\middleware\AllowOriginMiddleware::class,
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
|
||||
@ -36,6 +36,10 @@ Route::group(function () {
|
||||
Route::get('get_workerman_url', 'PublicController/getWorkerManUrl')->option(['real_name' => '获取客服数据']);
|
||||
//测试
|
||||
Route::get('index', 'Test/index')->option(['real_name' => '测试地址']);
|
||||
|
||||
//扫码上传图片
|
||||
Route::post('image/scan_upload', 'PublicController/scanUpload')->name('ajcheck')->option(['real_name' => '一次验证']);
|
||||
|
||||
})->middleware(AllowOriginMiddleware::class)->option(['mark' => 'login', 'mark_name' => '登录相关']);
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user