package gc.mda.kcg.domain.analysis;

import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/vessel-analysis")
@RequiredArgsConstructor
public class VesselAnalysisController {

    private final VesselAnalysisService vesselAnalysisService;

    /**
     * 최근 선박 분석 결과 조회
     * @param region 지역 필터 (향후 확장용, 현재 미사용)
     */
    @GetMapping
    public ResponseEntity<Map<String, Object>> getVesselAnalysis(
            @RequestParam(required = false) String region) {

        List<VesselAnalysisDto> results = vesselAnalysisService.getLatestResults();

        return ResponseEntity.ok(Map.of(
                "count", results.size(),
                "items", results
        ));
    }
}
