package de.avatic.lcc.controller.calculation;

import de.avatic.lcc.dto.calculation.execution.CalculationProcessingOverviewDTO;
import de.avatic.lcc.service.calculation.execution.CalculationJobProcessorManagementService;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/dashboard")
public class DashboardController {

    private final CalculationJobProcessorManagementService calculationJobProcessorManagementService;

    public DashboardController(CalculationJobProcessorManagementService calculationJobProcessorManagementService) {
        this.calculationJobProcessorManagementService = calculationJobProcessorManagementService;
    }

    @GetMapping({"/", ""})
    @PreAuthorize("hasAnyRole('SUPER', 'CALCULATION')")
    public ResponseEntity<CalculationProcessingOverviewDTO> getDashboardData() {
        return ResponseEntity.ok(calculationJobProcessorManagementService.getCalculationOverview());
    }
}
