Ver código fonte

remove set-latest api

peterguo 1 dia atrás
pai
commit
2c238d797e

+ 0 - 10
app/Http/Controllers/API/FileController.php

@@ -394,14 +394,4 @@ class FileController extends Controller
     }
 
 
-    // 设置为最新版本
-    public function setLatestVersion(
-        Request $request,
-        FileService $fileService,
-        string $id
-    ): Response
-    {
-        $fileService->setLatestVersion($id);
-        return $this->noContent();
-    }
 }

+ 0 - 27
app/Services/File/FileService.php

@@ -29,31 +29,4 @@ class FileService
 
         $file->save();
     }
-
-    public function setLatestVersion(string $id): void
-    {
-        $file = File::query()->findOrFail($id);
-        if ($file->is_latest_version) {
-            return;
-        }
-        $file->is_latest_version = true;
-
-        $oldLatestVersionFile = File::query()
-            ->where(fn($query) => $file->source_file_id ? $query->where('id', $file->source_file_id) : $query->where('source_file_id', $file->id))
-            ->where('is_latest_version', true)
-            ->first();
-
-        if ($oldLatestVersionFile) {
-            $oldLatestVersionFile->is_latest_version = false;
-            $changes = ModelChangeDetector::detector(ActionObjectType::CONTAINER_FILE, $oldLatestVersionFile);
-            ActionRepository::create($oldLatestVersionFile->id, ActionObjectType::CONTAINER_FILE, ObjectAction::EDITED_FILE, null, null, [], $changes);
-
-            $oldLatestVersionFile->save();
-        }
-
-        $changes = ModelChangeDetector::detector(ActionObjectType::CONTAINER_FILE, $file);
-        ActionRepository::create($id, ActionObjectType::CONTAINER_FILE, ObjectAction::EDITED_FILE, null, null, [], $changes);
-
-        $file->save();
-    }
 }

+ 0 - 1
routes/api.php

@@ -310,7 +310,6 @@ Route::middleware((function() {
             Route::apiResource("file", API\FileController::class)->only([
                 'update'
             ]);
-            Route::patch("file/{fileId}/set-latest", [API\FileController::class, "setLatestVersion"])->name("file.set-latest");