|
@@ -5,8 +5,10 @@ namespace App\Services\File;
|
|
|
use App\Http\Resources\API\FileDownloadResource;
|
|
|
use App\Models\Enums\FileObjectType;
|
|
|
use App\Models\Enums\FolderObjectType;
|
|
|
+use App\Models\Enums\ShareFileObjectType;
|
|
|
use App\Models\File;
|
|
|
use App\Models\Folder;
|
|
|
+use App\Models\ShareFile;
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
|
|
class DownloadService
|
|
@@ -18,6 +20,25 @@ class DownloadService
|
|
|
return $this->filesFormat($files);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 下载分享文件
|
|
|
+ *
|
|
|
+ * @param string $uuid
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function downloadShareFile(string $uuid)
|
|
|
+ {
|
|
|
+ $shareFile = ShareFile::query()->where("uuid", $uuid)->firstOrFail();
|
|
|
+
|
|
|
+ $objectType = ShareFileObjectType::from($shareFile->object_type);
|
|
|
+
|
|
|
+ $objectType->modelBuilderAllowed($shareFile->object_id)->findOrFail($shareFile->object_id);
|
|
|
+
|
|
|
+ $files = File::query()->with(['folder'])->whereIn("id", $shareFile->files)->get();
|
|
|
+
|
|
|
+ return $this->filesFormat($files);
|
|
|
+ }
|
|
|
+
|
|
|
public function downloadAllLatest(string $objectType, string $objectId)
|
|
|
{
|
|
|
$folderObjectType = FolderObjectType::from($objectType);
|