refactor: rename getter properly
All checks were successful
CI / Get Changed Files (pull_request) Successful in 11s
CI / eslint (pull_request) Has been skipped
CI / oxlint (pull_request) Has been skipped
CI / Docker frontend validation (pull_request) Has been skipped
CI / prettier (pull_request) Has been skipped
CI / test-build (pull_request) Has been skipped
CI / Checkstyle Main (pull_request) Successful in 3m45s
CI / Docker backend validation (pull_request) Successful in 4m16s

This commit is contained in:
Phan Huy Tran 2025-05-22 12:48:31 +02:00
commit 9101e2f5db

View file

@ -31,35 +31,35 @@ public class BlackJackGameController {
@GetMapping("/blackjack/{id}") @GetMapping("/blackjack/{id}")
public ResponseEntity<Object> getGame(@PathVariable Long id) { public ResponseEntity<Object> getGame(@PathVariable Long id) {
BlackJackGameEntity game = getUserGame(id); BlackJackGameEntity game = getBlackJackGame(id);
return ResponseEntity.ok(game); return ResponseEntity.ok(game);
} }
@PostMapping("/blackjack/{id}/hit") @PostMapping("/blackjack/{id}/hit")
public ResponseEntity<Object> hit(@PathVariable Long id) { public ResponseEntity<Object> hit(@PathVariable Long id) {
BlackJackGameEntity game = getUserGame(id); BlackJackGameEntity game = getBlackJackGame(id);
return ResponseEntity.ok(blackJackService.hit(game)); return ResponseEntity.ok(blackJackService.hit(game));
} }
@PostMapping("/blackjack/{id}/stand") @PostMapping("/blackjack/{id}/stand")
public ResponseEntity<Object> stand(@PathVariable Long id) { public ResponseEntity<Object> stand(@PathVariable Long id) {
BlackJackGameEntity game = getUserGame(id); BlackJackGameEntity game = getBlackJackGame(id);
return ResponseEntity.ok(blackJackService.stand(game)); return ResponseEntity.ok(blackJackService.stand(game));
} }
@PostMapping("/blackjack/{id}/doubleDown") @PostMapping("/blackjack/{id}/doubleDown")
public ResponseEntity<Object> doubleDown(@PathVariable Long id) { public ResponseEntity<Object> doubleDown(@PathVariable Long id) {
BlackJackGameEntity game = getUserGame(id); BlackJackGameEntity game = getBlackJackGame(id);
return ResponseEntity.ok(blackJackService.doubleDown(game)); return ResponseEntity.ok(blackJackService.doubleDown(game));
} }
@PostMapping("/blackjack/{id}/split") @PostMapping("/blackjack/{id}/split")
public ResponseEntity<Object> split(@PathVariable Long id) { public ResponseEntity<Object> split(@PathVariable Long id) {
BlackJackGameEntity game = getUserGame(id); BlackJackGameEntity game = getBlackJackGame(id);
return ResponseEntity.ok(blackJackService.split(game)); return ResponseEntity.ok(blackJackService.split(game));
} }
@ -81,7 +81,7 @@ public class BlackJackGameController {
return ResponseEntity.ok(blackJackService.createBlackJackGame(user, betDto.getBetAmount())); return ResponseEntity.ok(blackJackService.createBlackJackGame(user, betDto.getBetAmount()));
} }
private BlackJackGameEntity getUserGame(Long gameId) { private BlackJackGameEntity getBlackJackGame(Long gameId) {
Optional<UserEntity> optionalUser = userService.getCurrentUser(); Optional<UserEntity> optionalUser = userService.getCurrentUser();
if (optionalUser.isEmpty()) { if (optionalUser.isEmpty()) {