no message

This commit is contained in:
kuaifan
2022-06-11 22:55:47 +08:00
parent 2dbdc3b780
commit 0150b41e17
6 changed files with 81 additions and 47 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Api;
use App\Models\File;
use App\Models\FileContent;
use App\Models\ProjectTask;
use App\Models\ProjectTaskFile;
use App\Models\User;
@@ -13,6 +14,7 @@ use App\Models\WebSocketDialogUser;
use App\Module\Base;
use Carbon\Carbon;
use DB;
use Redirect;
use Request;
use Response;
@@ -531,7 +533,10 @@ class DialogController extends AbstractController
* @apiGroup dialog
* @apiName msg__download
*
* @apiParam {Number} msg_id 消息ID
* @apiParam {Number} msg_id 消息ID
* @apiParam {String} down 直接下载
* - yes: 下载(默认)
* - preview: 转预览地址
*
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
* @apiSuccess {String} msg 返回信息(错误描述)
@@ -542,6 +547,7 @@ class DialogController extends AbstractController
User::auth();
//
$msg_id = intval(Request::input('msg_id'));
$down = Request::input('down', 'yes');
//
$msg = WebSocketDialogMsg::whereId($msg_id)->first();
if (empty($msg)) {
@@ -552,6 +558,10 @@ class DialogController extends AbstractController
}
$array = Base::json2array($msg->getRawOriginal('msg'));
//
if ($down === 'preview') {
return Redirect::to(FileContent::toPreviewUrl($array));
}
//
return Response::download(public_path($array['path']), $array['name']);
}

View File

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
use App\Exceptions\ApiException;
use App\Models\AbstractModel;
use App\Models\File;
use App\Models\FileContent;
use App\Models\Project;
use App\Models\ProjectColumn;
use App\Models\ProjectFlow;
@@ -22,6 +23,7 @@ use App\Module\BillExport;
use Carbon\Carbon;
use Illuminate\Support\Arr;
use Madzipper;
use Redirect;
use Request;
use Response;
use Session;
@@ -1306,6 +1308,9 @@ class ProjectController extends AbstractController
* @apiName task__filedown
*
* @apiParam {Number} file_id 文件ID
* @apiParam {String} down 直接下载
* - yes: 下载(默认)
* - preview: 转预览地址
*
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
* @apiSuccess {String} msg 返回信息(错误描述)
@@ -1316,6 +1321,7 @@ class ProjectController extends AbstractController
User::auth();
//
$file_id = intval(Request::input('file_id'));
$down = Request::input('down', 'yes');
//
$file = ProjectTaskFile::find($file_id);
if (empty($file)) {
@@ -1328,6 +1334,14 @@ class ProjectController extends AbstractController
abort(403, $e->getMessage() ?: "This file not support download.");
}
//
if ($down === 'preview') {
return Redirect::to(FileContent::toPreviewUrl([
'ext' => $file->ext,
'name' => $file->name,
'path' => $file->getRawOriginal('path'),
]));
}
//
return Response::download(public_path($file->getRawOriginal('path')), $file->name);
}