package com.eactive.eai.rms.onl.dashboard.modern.backup;

import com.eactive.eai.rms.common.interceptor.InterceptorSkipController;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Slf4j
@Controller
@RequiredArgsConstructor
public class BackupController implements InterceptorSkipController {

    private final RepositoryBackupService repositoryBackupService;

    @GetMapping("/removeBackupFile.do")
    public ResponseEntity<String> removeBackupFile() {
        try {
            repositoryBackupService.removeBackupFile();
            return ResponseEntity.ok("OK");
        } catch (Exception e) {
            log.error("FILE REMOVE FAIL", e);
            return ResponseEntity.internalServerError().body(e.getMessage());
        }
    }

}
