package com.rinha.backend.controller; import com.rinha.backend.model.SummaryModel; import com.rinha.backend.service.SummaryService; import org.springframework.format.annotation.DateTimeFormat; 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.time.OffsetDateTime; @RestController @RequestMapping("/payments-summary") public class SummaryController { private final SummaryService summaryService; public SummaryController(SummaryService summaryService) { this.summaryService = summaryService; } @GetMapping public ResponseEntity getSummary( @RequestParam(value = "from", required = true) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) OffsetDateTime from, @RequestParam(value = "to", required = true) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) OffsetDateTime to ) { SummaryModel summary = summaryService.getSummary(from, to); return ResponseEntity.ok(summary); } }