diff options
| author | leo <azuminha1@gmail.com> | 2025-09-27 14:31:52 -0300 | 
|---|---|---|
| committer | leo <azuminha1@gmail.com> | 2025-09-27 14:31:52 -0300 | 
| commit | 1a3a6f83cc9ef2af8fed16775dce209feb8391ab (patch) | |
| tree | b31220eeaa0f6519ab3c5e51eebe394a425cf06c /src/main/java/com/rinha/backend/controller | |
Diffstat (limited to 'src/main/java/com/rinha/backend/controller')
| -rw-r--r-- | src/main/java/com/rinha/backend/controller/PaymentController.java | 24 | ||||
| -rw-r--r-- | src/main/java/com/rinha/backend/controller/SummaryController.java | 36 | 
2 files changed, 60 insertions, 0 deletions
| diff --git a/src/main/java/com/rinha/backend/controller/PaymentController.java b/src/main/java/com/rinha/backend/controller/PaymentController.java new file mode 100644 index 0000000..bb0ce70 --- /dev/null +++ b/src/main/java/com/rinha/backend/controller/PaymentController.java @@ -0,0 +1,24 @@ +package com.rinha.backend.controller; + +import com.rinha.backend.model.PaymentModel; +import com.rinha.backend.service.PaymentService; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/payments") +public class PaymentController { + +    private final PaymentService paymentService; + +    public PaymentController(PaymentService paymentService) { +        this.paymentService = paymentService; +    } + +    @PostMapping +    public ResponseEntity<String> post(@RequestBody PaymentModel paymentModel){ +        //System.out.println(paymentModel.getCorrelationId()); +        paymentService.addQueue(paymentModel); +        return ResponseEntity.ok().build(); +    } +} diff --git a/src/main/java/com/rinha/backend/controller/SummaryController.java b/src/main/java/com/rinha/backend/controller/SummaryController.java new file mode 100644 index 0000000..73a6d7c --- /dev/null +++ b/src/main/java/com/rinha/backend/controller/SummaryController.java @@ -0,0 +1,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); +    } +} | 
