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

import com.arms.api.admin.restore.model.dto.RestoreRequestDTO;
import com.arms.api.admin.restore.model.vo.RestoreResponseVO;
import com.arms.api.admin.restore.service.IndexRestoreService;
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/restore")
@AllArgsConstructor
@RestController
public class IndexRestoreController {

    private final IndexRestoreService indexRestoreService;

    @PostMapping("/start")
    public ResponseEntity<CommonResponse.ApiResult<RestoreResponseVO>> startRestore(
            @Valid @RequestBody RestoreRequestDTO request) {
        RestoreResponseVO response = indexRestoreService.startRestore(request);
        return ResponseEntity.ok(success(response));
    }

}