ProgressController.java
1,053 bytes
| 1 | package com.tasteprint.progress; |
|---|---|
| 2 | |
| 3 | import org.springframework.security.core.annotation.AuthenticationPrincipal; |
| 4 | import org.springframework.web.bind.annotation.GetMapping; |
| 5 | import org.springframework.web.bind.annotation.PathVariable; |
| 6 | import org.springframework.web.bind.annotation.RequestMapping; |
| 7 | import org.springframework.web.bind.annotation.RestController; |
| 8 | |
| 9 | import com.tasteprint.account.AuthenticatedUser; |
| 10 | |
| 11 | @RestController |
| 12 | @RequestMapping("/api/v1/progress") |
| 13 | class ProgressController { |
| 14 | |
| 15 | private final ProgressService progress; |
| 16 | |
| 17 | ProgressController(ProgressService progress) { |
| 18 | this.progress = progress; |
| 19 | } |
| 20 | |
| 21 | @GetMapping("/dashboard") |
| 22 | DashboardView dashboard(@AuthenticationPrincipal AuthenticatedUser user) { |
| 23 | return progress.dashboard(user.id()); |
| 24 | } |
| 25 | |
| 26 | @GetMapping("/destinations/{code}") |
| 27 | DestinationProgressDetails destination(@AuthenticationPrincipal AuthenticatedUser user, |
| 28 | @PathVariable String code) { |
| 29 | return progress.destination(user.id(), code); |
| 30 | } |
| 31 | } |
| 32 | |