package com.zioinfo.signage.controller;

import com.zioinfo.signage.common.ApiResponse;
import com.zioinfo.signage.domain.BackupVo;
import com.zioinfo.signage.service.BackupService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/backups")
@RequiredArgsConstructor
public class BackupController {
    private final BackupService service;

    @GetMapping
    public ApiResponse<List<BackupVo>> list(
            @RequestParam(required = false) String tenantCode,
            @RequestParam(required = false) String status,
            @RequestParam(required = false) String keyword) {
        return ApiResponse.ok(service.list(tenantCode, status, keyword));
    }

    @GetMapping("/{id}")
    public ApiResponse<BackupVo> get(@PathVariable Long id) {
        return ApiResponse.ok(service.get(id));
    }

    @PostMapping
    public ApiResponse<BackupVo> create(@RequestBody BackupVo v) {
        return ApiResponse.ok("백업/복구 생성 완료", service.create(v));
    }

    @PutMapping("/{id}")
    public ApiResponse<BackupVo> update(@PathVariable Long id, @RequestBody BackupVo v) {
        return ApiResponse.ok("백업/복구 수정 완료", service.update(id, v));
    }

    @DeleteMapping("/{id}")
    public ApiResponse<Void> delete(@PathVariable Long id) {
        service.delete(id);
        return ApiResponse.ok("백업/복구 삭제 완료", null);
    }
}
