package com.arms.api.admin.backup.controller;

import com.arms.api.admin.backup.model.dto.BackupRequestDTO;
import com.arms.api.admin.backup.model.vo.BackupResponseVO;
import com.arms.api.admin.backup.service.IndexBackupService;
import com.arms.api.util.response.CommonResponse;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import static com.arms.api.util.response.CommonResponse.success;

@RequestMapping("/engine/index/backup")
@AllArgsConstructor
@RestController
public class IndexBackupController {

    private final IndexBackupService indexBackupService;

    @PostMapping("/start")
    public ResponseEntity<CommonResponse.ApiResult<BackupResponseVO>> startBackup(
            @Valid @RequestBody BackupRequestDTO request) {
        BackupResponseVO response = indexBackupService.startBackup(request);
        return ResponseEntity.ok(success(response));
    }

}