feat: Add user relation to black jack game entity
This commit is contained in:
parent
64e41b663e
commit
85d2b218aa
4 changed files with 10 additions and 6 deletions
|
@ -57,6 +57,7 @@ public class BlackJackGameController {
|
|||
}
|
||||
|
||||
BlackJackGameEntity game = new BlackJackGameEntity();
|
||||
game.setUser(user);
|
||||
game.setBet(betAmount);
|
||||
|
||||
user.setBalance(user.getBalance().subtract(betAmount));
|
||||
|
@ -64,5 +65,6 @@ public class BlackJackGameController {
|
|||
userRepository.save(user);
|
||||
blackJackGameRepository.save(game);
|
||||
|
||||
return ResponseEntity.ok(game); }
|
||||
return ResponseEntity.ok(game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package de.szut.casino.blackjack;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import de.szut.casino.user.UserEntity;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -20,6 +19,9 @@ public class BlackJackGameEntity {
|
|||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user_id", nullable = false)
|
||||
private UserEntity user;
|
||||
private String state;
|
||||
private BigDecimal bet;
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@ package de.szut.casino.blackjack;
|
|||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class Card {
|
||||
public class CardEntity {
|
||||
private final Suit suit;
|
||||
private final Rank rank;
|
||||
|
||||
public Card(Suit suit, Rank rank) {
|
||||
public CardEntity(Suit suit, Rank rank) {
|
||||
this.suit = suit;
|
||||
this.rank = rank;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue