package com.goldenchart.controller;

import com.goldenchart.dto.BacktestSettingsDto;
import com.goldenchart.service.BacktestSettingsService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/backtest-settings")
@RequiredArgsConstructor
@CrossOrigin(origins = "*")
public class BacktestSettingsController {

    private final BacktestSettingsService service;

    @GetMapping
    public ResponseEntity<BacktestSettingsDto> get(
            @RequestHeader(value = "X-Device-Id", defaultValue = "default") String deviceId) {
        return ResponseEntity.ok(service.get(deviceId));
    }

    @PostMapping
    public ResponseEntity<BacktestSettingsDto> save(
            @RequestHeader(value = "X-Device-Id", defaultValue = "default") String deviceId,
            @RequestBody BacktestSettingsDto dto) {
        return ResponseEntity.ok(service.save(deviceId, dto));
    }
}
