Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dev.codehouse.backend.game.dto.OddEvenRequestDto;
import dev.codehouse.backend.game.service.OddEvenService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;

@RestController
Expand All @@ -14,19 +15,16 @@ public class OddEvenController {

private final OddEvenService oddEvenService;

@PostMapping("/bet/{username}")
public void bet(@PathVariable String username, @RequestBody OddEvenRequestDto dto) {
oddEvenService.bet(username, dto);
@PostMapping("/bet")
public void bet(Authentication authentication, @RequestBody OddEvenRequestDto dto) {
oddEvenService.bet(authentication.getName(), dto);
}



@GetMapping("/roundSummary/{username}")
public BetSummaryResponseDto getCurrentRoundSummary(@PathVariable String username) {
return oddEvenService.getCurrentRoundResult(username);
@GetMapping("/roundSummary")
public BetSummaryResponseDto getCurrentRoundSummary(Authentication authentication) {
return oddEvenService.getCurrentRoundResult(authentication.getName());
}


@PostMapping("/calculate")
public void calculate() {
oddEvenService.calculateResult();
Expand Down