获取扫码上传的图片数据

获取扫码上传页面链接以及参数
This commit is contained in:
evoxwht 2023-06-13 17:27:02 +08:00
parent 0fd959d9b5
commit 34b7ad1b92
6 changed files with 36 additions and 2 deletions

View File

@ -69,7 +69,7 @@ class PublicController
if ($service->cacheDriver()->get('scan_upload') != $uploadToken) {
return app('json')->fail(410086);
}
$service->upload((int)$pid, $file, $upload_type, $type, $menuName);
$service->upload((int)$pid, $file, $upload_type, $type, $menuName, $uploadToken);
return app('json')->success(100032);
}
}

View File

@ -150,4 +150,17 @@ class SystemAttachment extends AuthController
$url = sys_config('site_url') . '/app/upload?token=' . $uploadToken;
return app('json')->success(['url' => $url]);
}
/**
* 获取扫码上传的图片数据
* @param $scan_token
* @return \think\Response
* @author 吴汐
* @email 442384644@qq.com
* @date 2023/06/13
*/
public function scanUploadImage($scan_token)
{
return app('json')->success($this->service->scanUploadImage($scan_token));
}
}

View File

@ -45,6 +45,8 @@ Route::group('file', function () {
//获取扫码上传页面链接以及参数
Route::get('scan_upload/qrcode', 'v1.file.SystemAttachment/scanUploadQrcode')->option(['real_name' => '扫码上传页面链接']);
//获取扫码上传的图片数据
Route::get('scan_upload/image/:scan_token', 'v1.file.SystemAttachment/scanUploadImage')->option(['real_name' => '获取扫码上传的图片数据']);
})->middleware([
\app\http\middleware\AllowOriginMiddleware::class,
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,

View File

@ -92,4 +92,20 @@ class SystemAttachmentDao extends BaseDao
{
$this->getModel()->whereTime('time', 'yesterday')->where('module_type', 2)->delete();
}
/**
* 获取扫码上传的图片数据
* @param $scan_token
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 吴汐
* @email 442384644@qq.com
* @date 2023/06/13
*/
public function scanUploadImage($scan_token)
{
return $this->getModel()->where('scan_token', $scan_token)->select()->toArray();
}
}

View File

@ -25,6 +25,7 @@ use app\services\other\UploadService;
* @package app\services\attachment
* @method getYesterday() 获取昨日生成数据
* @method delYesterday() 删除昨日生成数据
* @method scanUploadImage($scan_token) 获取扫码上传的图片数据
*/
class SystemAttachmentServices extends BaseServices
{
@ -109,7 +110,7 @@ class SystemAttachmentServices extends BaseServices
* @param int $type
* @return mixed
*/
public function upload(int $pid, string $file, int $upload_type, int $type, $menuName)
public function upload(int $pid, string $file, int $upload_type, int $type, $menuName, $uploadToken = '')
{
$realName = false;
if ($upload_type == 0) {
@ -139,6 +140,7 @@ class SystemAttachmentServices extends BaseServices
$data['module_type'] = 1;
$data['time'] = $fileInfo['time'] ?? time();
$data['pid'] = $pid;
$data['scan_token'] = $uploadToken;
$this->dao->save($data);
}
return $res->filePath;

View File

@ -29451,6 +29451,7 @@ CREATE TABLE IF NOT EXISTS `eb_system_attachment` (
`image_type` tinyint(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT '图片上传类型 1本地 2七牛云 3OSS 4COS ',
`module_type` tinyint(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT '图片上传模块类型 1 后台上传 2 用户生成',
`real_name` varchar(255) NOT NULL DEFAULT '' COMMENT '原始文件名',
`scan_token` varchar(32) NOT NULL DEFAULT '' COMMENT '扫码上传的token',
PRIMARY KEY (`att_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=92 DEFAULT CHARSET=utf8 COMMENT='附件管理表';