blob: 73a6d7c785fbd47cb75314c094c4ee743cd3db75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
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<SummaryModel> 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);
}
}
|