42 lines
1.2 KiB
Java
42 lines
1.2 KiB
Java
package ru.soune.nocopy.controller;
|
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import ru.soune.nocopy.migration.S3MigrationTool;
|
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
@RestController
|
|
@RequestMapping("/api/admin/migration")
|
|
@RequiredArgsConstructor
|
|
@Slf4j
|
|
public class MigrationController {
|
|
|
|
private final S3MigrationTool migrationTool;
|
|
|
|
@PostMapping("/start")
|
|
public ResponseEntity<String> startMigration() {
|
|
log.info("Migration triggered via API");
|
|
|
|
CompletableFuture.runAsync(() -> {
|
|
try {
|
|
migrationTool.migrationFilesToS3();
|
|
} catch (Exception e) {
|
|
log.error("Migration failed", e);
|
|
}
|
|
});
|
|
|
|
return ResponseEntity.ok("Migration started. Check logs for progress.");
|
|
}
|
|
|
|
@PostMapping("/status")
|
|
public ResponseEntity<String> getStatus() {
|
|
return ResponseEntity.ok("Check application logs and migration_failed.txt for details");
|
|
}
|
|
}
|