diff --git a/crmeb/app/adminapi/controller/PublicController.php b/crmeb/app/adminapi/controller/PublicController.php index 854fec012..bfeacc487 100644 --- a/crmeb/app/adminapi/controller/PublicController.php +++ b/crmeb/app/adminapi/controller/PublicController.php @@ -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); } } diff --git a/crmeb/app/adminapi/controller/v1/file/SystemAttachment.php b/crmeb/app/adminapi/controller/v1/file/SystemAttachment.php index ff95bf1b2..7ff5ef86b 100644 --- a/crmeb/app/adminapi/controller/v1/file/SystemAttachment.php +++ b/crmeb/app/adminapi/controller/v1/file/SystemAttachment.php @@ -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)); + } } diff --git a/crmeb/app/adminapi/route/file.php b/crmeb/app/adminapi/route/file.php index 71779227b..f68a1b120 100644 --- a/crmeb/app/adminapi/route/file.php +++ b/crmeb/app/adminapi/route/file.php @@ -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, diff --git a/crmeb/app/dao/system/attachment/SystemAttachmentDao.php b/crmeb/app/dao/system/attachment/SystemAttachmentDao.php index b648d0bba..cfed3adfc 100644 --- a/crmeb/app/dao/system/attachment/SystemAttachmentDao.php +++ b/crmeb/app/dao/system/attachment/SystemAttachmentDao.php @@ -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(); + } } diff --git a/crmeb/app/services/system/attachment/SystemAttachmentServices.php b/crmeb/app/services/system/attachment/SystemAttachmentServices.php index 2b1cb6ef7..affeae8c2 100644 --- a/crmeb/app/services/system/attachment/SystemAttachmentServices.php +++ b/crmeb/app/services/system/attachment/SystemAttachmentServices.php @@ -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; diff --git a/crmeb/public/install/crmeb.sql b/crmeb/public/install/crmeb.sql index 9428e5060..13fb23d75 100755 --- a/crmeb/public/install/crmeb.sql +++ b/crmeb/public/install/crmeb.sql @@ -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='附件管理表';