Compare commits
26 commits
Author | SHA1 | Date | |
---|---|---|---|
69b0289ce4 | |||
|
27473ef5b5 | ||
|
40e1ae5f87 | ||
|
36237874f7 | ||
676473cfad | |||
d2560c6049 | |||
d9324ee7f0 | |||
0f96b284db | |||
ef069d7d18 | |||
|
f01f6f6477 | ||
|
c93c386469 | ||
|
29732e63b9 | ||
|
a26aeab86a | ||
|
7a0dd0593b | ||
934e60e80d | |||
|
41124af20e | ||
|
af005ce019 | ||
|
3b2ce7e772 | ||
|
44b68528e3 | ||
|
1c58db60d3 | ||
|
25b7e90517 | ||
|
4f377e1e87 | ||
b07a3a935a | |||
|
0cc8ff50aa | ||
|
6f3f3791c3 | ||
|
66e5d730dd |
43 changed files with 520 additions and 166 deletions
|
@ -31,3 +31,64 @@ jobs:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
|
||||||
|
build-backend-image:
|
||||||
|
needs: release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Build Backend Image
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Ensure full history is available
|
||||||
|
- name: Extract tag
|
||||||
|
run: |
|
||||||
|
TAG=$(git describe --tags --abbrev=0)
|
||||||
|
echo "TAG=$TAG" >> $GITHUB_ENV
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Login
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: git.kjan.de
|
||||||
|
username: ${{ secrets.DOCKER_USER }}
|
||||||
|
password: ${{ secrets.DOCKER_PASS }}
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: backend/
|
||||||
|
file: backend/.docker/Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
git.kjan.de/szut/casino-backend:latest
|
||||||
|
git.kjan.de/szut/casino-backend:${{ env.TAG }}
|
||||||
|
|
||||||
|
build-frontend-image:
|
||||||
|
needs: release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Build Frontend Image
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Ensure full history is available
|
||||||
|
- name: Extract tag
|
||||||
|
run: |
|
||||||
|
TAG=$(git describe --tags --abbrev=0)
|
||||||
|
echo "TAG=$TAG" >> $GITHUB_ENV
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Login
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: git.kjan.de
|
||||||
|
username: ${{ secrets.DOCKER_USER }}
|
||||||
|
password: ${{ secrets.DOCKER_PASS }}
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: frontend/
|
||||||
|
file: frontend/.docker/Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
git.kjan.de/szut/casino-frontend:latest
|
||||||
|
git.kjan.de/szut/casino-frontend:${{ env.TAG }}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
FROM gradle:jdk22 AS builder
|
FROM gradle:jdk23 AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY gradlew build.gradle.kts settings.gradle.kts ./
|
COPY gradlew build.gradle.kts settings.gradle.kts config ./
|
||||||
COPY gradle gradle
|
COPY gradle gradle
|
||||||
|
|
||||||
RUN chmod +x gradlew
|
RUN chmod +x gradlew
|
||||||
RUN ./gradlew dependencies
|
RUN gradle dependencies
|
||||||
|
|
||||||
COPY src src
|
COPY src src
|
||||||
|
|
||||||
RUN ./gradlew clean build -x test
|
RUN gradle clean build -x test -x checkstyleMain -x checkstyleTest -x compileTestJava
|
||||||
|
|
||||||
FROM openjdk:22-jdk-slim
|
FROM openjdk:23-jdk-slim AS runtime
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY --from=builder /app/build/libs/*.jar app.jar
|
COPY --from=builder /app/build/libs/*.jar app.jar
|
||||||
|
|
|
@ -1,20 +1,10 @@
|
||||||
package de.szut.casino;
|
package de.szut.casino;
|
||||||
|
|
||||||
import de.szut.casino.lootboxes.LootBoxEntity;
|
|
||||||
import de.szut.casino.lootboxes.LootBoxRepository;
|
|
||||||
import de.szut.casino.lootboxes.RewardEntity;
|
|
||||||
import de.szut.casino.lootboxes.RewardRepository;
|
|
||||||
import org.springframework.boot.CommandLineRunner;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class CasinoApplication {
|
public class CasinoApplication {
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package de.szut.casino.blackjack;
|
package de.szut.casino.blackjack;
|
||||||
|
|
||||||
import de.szut.casino.blackjack.dto.CreateBlackJackGameDto;
|
import de.szut.casino.shared.dto.BetDto;
|
||||||
|
import de.szut.casino.shared.service.BalanceService;
|
||||||
import de.szut.casino.user.UserEntity;
|
import de.szut.casino.user.UserEntity;
|
||||||
import de.szut.casino.user.UserService;
|
import de.szut.casino.user.UserService;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
@ -9,19 +10,18 @@ import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
public class BlackJackGameController {
|
public class BlackJackGameController {
|
||||||
|
|
||||||
|
private final BalanceService balanceService;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final BlackJackService blackJackService;
|
private final BlackJackService blackJackService;
|
||||||
|
|
||||||
public BlackJackGameController(UserService userService, BlackJackService blackJackService) {
|
public BlackJackGameController(BalanceService balanceService, UserService userService, BlackJackService blackJackService) {
|
||||||
|
this.balanceService = balanceService;
|
||||||
this.blackJackService = blackJackService;
|
this.blackJackService = blackJackService;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ public class BlackJackGameController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/blackjack/start")
|
@PostMapping("/blackjack/start")
|
||||||
public ResponseEntity<Object> createBlackJackGame(@RequestBody @Valid CreateBlackJackGameDto createBlackJackGameDto, @RequestHeader("Authorization") String token) {
|
public ResponseEntity<Object> createBlackJackGame(@RequestBody @Valid BetDto betDto, @RequestHeader("Authorization") String token) {
|
||||||
Optional<UserEntity> optionalUser = userService.getCurrentUser(token);
|
Optional<UserEntity> optionalUser = userService.getCurrentUser(token);
|
||||||
|
|
||||||
if (optionalUser.isEmpty()) {
|
if (optionalUser.isEmpty()) {
|
||||||
|
@ -120,21 +120,11 @@ public class BlackJackGameController {
|
||||||
}
|
}
|
||||||
|
|
||||||
UserEntity user = optionalUser.get();
|
UserEntity user = optionalUser.get();
|
||||||
BigDecimal balance = user.getBalance();
|
|
||||||
BigDecimal betAmount = createBlackJackGameDto.getBetAmount();
|
|
||||||
|
|
||||||
if (betAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
if (!this.balanceService.hasFunds(user, betDto)) {
|
||||||
Map<String, String> errorResponse = new HashMap<>();
|
return ResponseEntity.badRequest().body(Collections.singletonMap("error", "Insufficient funds"));
|
||||||
errorResponse.put("error", "Invalid bet amount");
|
|
||||||
return ResponseEntity.badRequest().body(errorResponse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (betAmount.compareTo(balance) > 0) {
|
return ResponseEntity.ok(blackJackService.createBlackJackGame(user, betDto.getBetAmount()));
|
||||||
Map<String, String> errorResponse = new HashMap<>();
|
|
||||||
errorResponse.put("error", "Insufficient funds");
|
|
||||||
return ResponseEntity.badRequest().body(errorResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResponseEntity.ok(blackJackService.createBlackJackGame(user, betAmount));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
package de.szut.casino.blackjack;
|
package de.szut.casino.blackjack;
|
||||||
|
|
||||||
import de.szut.casino.user.UserEntity;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public interface BlackJackGameRepository extends JpaRepository<BlackJackGameEntity, Long> {
|
public interface BlackJackGameRepository extends JpaRepository<BlackJackGameEntity, Long> {
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package de.szut.casino.blackjack.dto;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class CreateBlackJackGameDto {
|
|
||||||
private BigDecimal betAmount;
|
|
||||||
}
|
|
|
@ -8,7 +8,6 @@ import de.szut.casino.deposit.dto.AmountDto;
|
||||||
import de.szut.casino.deposit.dto.SessionIdDto;
|
import de.szut.casino.deposit.dto.SessionIdDto;
|
||||||
import de.szut.casino.user.UserEntity;
|
import de.szut.casino.user.UserEntity;
|
||||||
import de.szut.casino.user.UserRepository;
|
import de.szut.casino.user.UserRepository;
|
||||||
import de.szut.casino.user.UserService;
|
|
||||||
import de.szut.casino.user.dto.KeycloakUserDto;
|
import de.szut.casino.user.dto.KeycloakUserDto;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
@ -16,7 +15,10 @@ import org.springframework.http.HttpEntity;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
|
@ -5,7 +5,6 @@ import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
|
|
|
@ -7,7 +7,7 @@ import de.szut.casino.user.UserEntity;
|
||||||
import de.szut.casino.user.UserRepository;
|
import de.szut.casino.user.UserRepository;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.math.BigDecimal;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -55,7 +55,7 @@ public class TransactionService {
|
||||||
UserEntity user = transaction.getUser();
|
UserEntity user = transaction.getUser();
|
||||||
Long amountTotal = checkoutSession.getAmountTotal();
|
Long amountTotal = checkoutSession.getAmountTotal();
|
||||||
if (amountTotal != null) {
|
if (amountTotal != null) {
|
||||||
user.addBalance(amountTotal);
|
user.addBalance(BigDecimal.valueOf(amountTotal).movePointLeft(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
userRepository.save(user);
|
userRepository.save(user);
|
||||||
|
|
|
@ -1,26 +1,21 @@
|
||||||
package de.szut.casino.deposit;
|
package de.szut.casino.deposit;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
|
|
||||||
import com.stripe.Stripe;
|
import com.stripe.Stripe;
|
||||||
import com.stripe.exception.SignatureVerificationException;
|
|
||||||
import com.stripe.exception.StripeException;
|
import com.stripe.exception.StripeException;
|
||||||
import com.stripe.model.*;
|
import com.stripe.model.Event;
|
||||||
import com.stripe.model.checkout.Session;
|
import com.stripe.model.checkout.Session;
|
||||||
import com.stripe.net.Webhook;
|
import com.stripe.net.Webhook;
|
||||||
import com.stripe.param.checkout.SessionRetrieveParams;
|
|
||||||
import de.szut.casino.user.UserEntity;
|
|
||||||
import de.szut.casino.user.UserRepository;
|
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class WebhookController {
|
public class WebhookController {
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
package de.szut.casino.lootboxes;
|
package de.szut.casino.lootboxes;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
|
||||||
import de.szut.casino.blackjack.CardEntity;
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.hibernate.annotations.SQLRestriction;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package de.szut.casino.lootboxes;
|
package de.szut.casino.lootboxes;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
18
backend/src/main/java/de/szut/casino/shared/dto/BetDto.java
Normal file
18
backend/src/main/java/de/szut/casino/shared/dto/BetDto.java
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package de.szut.casino.shared.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import jakarta.validation.constraints.Positive;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BetDto {
|
||||||
|
@NotNull(message = "Bet amount cannot be null")
|
||||||
|
@Positive(message = "Bet amount must be positive")
|
||||||
|
private BigDecimal betAmount;
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package de.szut.casino.shared.service;
|
||||||
|
|
||||||
|
import de.szut.casino.shared.dto.BetDto;
|
||||||
|
import de.szut.casino.user.UserEntity;
|
||||||
|
import de.szut.casino.user.UserRepository;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class BalanceService {
|
||||||
|
private UserRepository userRepository;
|
||||||
|
|
||||||
|
public BalanceService(UserRepository userRepository) {
|
||||||
|
this.userRepository = userRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasFunds(UserEntity user, BetDto betDto) {
|
||||||
|
BigDecimal balance = user.getBalance();
|
||||||
|
BigDecimal betAmount = betDto.getBetAmount();
|
||||||
|
|
||||||
|
return betAmount.compareTo(balance) <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFunds(UserEntity user, BigDecimal amount) {
|
||||||
|
user.addBalance(amount);
|
||||||
|
|
||||||
|
this.userRepository.save(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void subtractFunds(UserEntity user, BigDecimal amount) {
|
||||||
|
user.subtractBalance(amount);
|
||||||
|
|
||||||
|
this.userRepository.save(user);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package de.szut.casino.slots;
|
||||||
|
|
||||||
|
import de.szut.casino.shared.dto.BetDto;
|
||||||
|
import de.szut.casino.shared.service.BalanceService;
|
||||||
|
import de.szut.casino.user.UserEntity;
|
||||||
|
import de.szut.casino.user.UserService;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class SlotController {
|
||||||
|
private final UserService userService;
|
||||||
|
private final BalanceService balanceService;
|
||||||
|
private final SlotService slotService;
|
||||||
|
|
||||||
|
public SlotController(UserService userService, BalanceService balanceService, SlotService slotService) {
|
||||||
|
this.userService = userService;
|
||||||
|
this.balanceService = balanceService;
|
||||||
|
this.slotService = slotService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/slots/spin")
|
||||||
|
public ResponseEntity<Object> spinSlots(@RequestBody @Valid BetDto betDto, @RequestHeader("Authorization") String token) {
|
||||||
|
Optional<UserEntity> optionalUser = userService.getCurrentUser(token);
|
||||||
|
|
||||||
|
if (optionalUser.isEmpty()) {
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
UserEntity user = optionalUser.get();
|
||||||
|
|
||||||
|
if (!this.balanceService.hasFunds(user, betDto)) {
|
||||||
|
return ResponseEntity.badRequest().body(Collections.singletonMap("error", "Insufficient funds"));
|
||||||
|
}
|
||||||
|
|
||||||
|
SpinResult spinResult = this.slotService.spin(
|
||||||
|
betDto.getBetAmount(),
|
||||||
|
user
|
||||||
|
);
|
||||||
|
|
||||||
|
return ResponseEntity.ok(spinResult);
|
||||||
|
}
|
||||||
|
}
|
139
backend/src/main/java/de/szut/casino/slots/SlotService.java
Normal file
139
backend/src/main/java/de/szut/casino/slots/SlotService.java
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
package de.szut.casino.slots;
|
||||||
|
|
||||||
|
import de.szut.casino.shared.service.BalanceService;
|
||||||
|
import de.szut.casino.user.UserEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SlotService {
|
||||||
|
private final int REEL_LENGTH = 32;
|
||||||
|
|
||||||
|
// 98% RTP
|
||||||
|
private final int SEVEN_COUNT = 1;
|
||||||
|
private final int BAR_COUNT = 4;
|
||||||
|
private final int BELL_COUNT = 7;
|
||||||
|
private final int CHERRY_COUNT = 10;
|
||||||
|
private final int BLANK_COUNT = 10;
|
||||||
|
|
||||||
|
private final Symbol SEVEN = new Symbol("seven", new BigDecimal("1000"));
|
||||||
|
private final Symbol BAR = new Symbol("bar", new BigDecimal("85"));
|
||||||
|
private final Symbol BELL = new Symbol("bell", new BigDecimal("40"));
|
||||||
|
private final Symbol CHERRY = new Symbol("cherry", new BigDecimal("10"));
|
||||||
|
private final Symbol BLANK = new Symbol("blank", new BigDecimal("0"));
|
||||||
|
|
||||||
|
private final List<Symbol> firstReel;
|
||||||
|
private final List<Symbol> secondReel;
|
||||||
|
private final List<Symbol> thirdReel;
|
||||||
|
|
||||||
|
private final Random random;
|
||||||
|
private final BalanceService balanceService;
|
||||||
|
|
||||||
|
public SlotService(BalanceService balanceService) {
|
||||||
|
this.random = new Random();
|
||||||
|
this.balanceService = balanceService;
|
||||||
|
|
||||||
|
List<Symbol> reelStrip = createReelStrip();
|
||||||
|
this.firstReel = shuffleReel(reelStrip);
|
||||||
|
this.secondReel = shuffleReel(reelStrip);
|
||||||
|
this.thirdReel = shuffleReel(reelStrip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SpinResult spin(BigDecimal betAmount, UserEntity user) {
|
||||||
|
int index1 = this.random.nextInt(REEL_LENGTH);
|
||||||
|
int index2 = this.random.nextInt(REEL_LENGTH);
|
||||||
|
int index3 = this.random.nextInt(REEL_LENGTH);
|
||||||
|
|
||||||
|
Symbol symbol1 = getSymbolAt(this.firstReel, index1);
|
||||||
|
Symbol symbol2 = getSymbolAt(this.secondReel, index2);
|
||||||
|
Symbol symbol3 = getSymbolAt(this.thirdReel, index3);
|
||||||
|
|
||||||
|
boolean isWin = symbol1.equals(symbol2) && symbol1.equals(symbol3);
|
||||||
|
|
||||||
|
SpinResult spinResult = processResult(betAmount, user, isWin, symbol1);
|
||||||
|
buildResultMatrix(spinResult, index1, index2, index3);
|
||||||
|
|
||||||
|
return spinResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SpinResult processResult(BigDecimal betAmount, UserEntity user, boolean isWin, Symbol winSymbol) {
|
||||||
|
BigDecimal resultAmount;
|
||||||
|
String status;
|
||||||
|
|
||||||
|
if (isWin) {
|
||||||
|
resultAmount = betAmount.multiply(winSymbol.getPayoutMultiplier());
|
||||||
|
status = "win";
|
||||||
|
this.balanceService.addFunds(user, resultAmount);
|
||||||
|
} else {
|
||||||
|
resultAmount = betAmount;
|
||||||
|
status = "lose";
|
||||||
|
this.balanceService.subtractFunds(user, betAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
SpinResult spinResult = new SpinResult();
|
||||||
|
spinResult.setStatus(status);
|
||||||
|
spinResult.setAmount(resultAmount);
|
||||||
|
spinResult.setWin(isWin);
|
||||||
|
|
||||||
|
return spinResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildResultMatrix(SpinResult spinResult, int index1, int index2, int index3) {
|
||||||
|
List<List<Symbol>> resultMatrix = new ArrayList<>(3);
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
resultMatrix.add(new ArrayList<>(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
resultMatrix.getFirst().add(getSymbolAt(this.firstReel, index1 - 1));
|
||||||
|
resultMatrix.getFirst().add(getSymbolAt(this.secondReel, index2 - 1));
|
||||||
|
resultMatrix.getFirst().add(getSymbolAt(this.thirdReel, index3 - 1));
|
||||||
|
|
||||||
|
resultMatrix.get(1).add(getSymbolAt(this.firstReel, index1));
|
||||||
|
resultMatrix.get(1).add(getSymbolAt(this.secondReel, index2));
|
||||||
|
resultMatrix.get(1).add(getSymbolAt(this.thirdReel, index3));
|
||||||
|
|
||||||
|
resultMatrix.getLast().add(getSymbolAt(this.firstReel, index1 + 1));
|
||||||
|
resultMatrix.getLast().add(getSymbolAt(this.secondReel, index2 + 1));
|
||||||
|
resultMatrix.getLast().add(getSymbolAt(this.thirdReel, index3 + 1));
|
||||||
|
|
||||||
|
spinResult.setResultMatrix(resultMatrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Symbol> shuffleReel(List<Symbol> reelStrip) {
|
||||||
|
Collections.shuffle(reelStrip, this.random);
|
||||||
|
|
||||||
|
return reelStrip;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Symbol> createReelStrip() {
|
||||||
|
List<Symbol> reelStrip = new ArrayList<>(REEL_LENGTH);
|
||||||
|
addSymbolsToStrip(reelStrip, CHERRY, CHERRY_COUNT);
|
||||||
|
addSymbolsToStrip(reelStrip, BELL, BELL_COUNT);
|
||||||
|
addSymbolsToStrip(reelStrip, BAR, BAR_COUNT);
|
||||||
|
addSymbolsToStrip(reelStrip, SEVEN, SEVEN_COUNT);
|
||||||
|
addSymbolsToStrip(reelStrip, BLANK, BLANK_COUNT);
|
||||||
|
return reelStrip;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addSymbolsToStrip(List<Symbol> strip, Symbol symbol, int count) {
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
strip.add(symbol);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Symbol getSymbolAt(List<Symbol> reel, int index) {
|
||||||
|
int effectiveIndex = index % REEL_LENGTH;
|
||||||
|
|
||||||
|
if (effectiveIndex < 0) {
|
||||||
|
effectiveIndex += REEL_LENGTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
return reel.get(effectiveIndex);
|
||||||
|
}
|
||||||
|
}
|
24
backend/src/main/java/de/szut/casino/slots/SpinResult.java
Normal file
24
backend/src/main/java/de/szut/casino/slots/SpinResult.java
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
package de.szut.casino.slots;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SpinResult {
|
||||||
|
public SpinResult(String status, BigDecimal amount, boolean isWin) {
|
||||||
|
this.status = status;
|
||||||
|
this.amount = amount;
|
||||||
|
this.isWin = isWin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String status;
|
||||||
|
private BigDecimal amount;
|
||||||
|
private boolean isWin;
|
||||||
|
private List<List<Symbol>> resultMatrix;
|
||||||
|
}
|
35
backend/src/main/java/de/szut/casino/slots/Symbol.java
Normal file
35
backend/src/main/java/de/szut/casino/slots/Symbol.java
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package de.szut.casino.slots;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Symbol {
|
||||||
|
private String name;
|
||||||
|
private BigDecimal payoutMultiplier;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
if (!(other instanceof Symbol that)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.name.equals(that.name) && this.payoutMultiplier.equals(that.payoutMultiplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hashCode = 1;
|
||||||
|
|
||||||
|
hashCode = hashCode * 37 + this.name.hashCode();
|
||||||
|
hashCode = hashCode * 37 + this.payoutMultiplier.hashCode();
|
||||||
|
|
||||||
|
return hashCode;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +1,14 @@
|
||||||
package de.szut.casino.user;
|
package de.szut.casino.user;
|
||||||
|
|
||||||
|
import de.szut.casino.user.dto.CreateUserDto;
|
||||||
|
import de.szut.casino.user.dto.GetUserDto;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import de.szut.casino.user.dto.CreateUserDto;
|
|
||||||
import de.szut.casino.user.dto.GetUserDto;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
|
|
|
@ -31,13 +31,31 @@ public class UserEntity {
|
||||||
this.balance = balance;
|
this.balance = balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBalance(long amountInCents) {
|
public void addBalance(BigDecimal amountToAdd) {
|
||||||
BigDecimal amountToAdd = BigDecimal.valueOf(amountInCents).movePointLeft(2);
|
if (amountToAdd == null || amountToAdd.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.balance == null) {
|
if (this.balance == null) {
|
||||||
this.balance = amountToAdd;
|
this.balance = BigDecimal.ZERO;
|
||||||
} else {
|
|
||||||
this.balance = this.balance.add(amountToAdd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.balance = this.balance.add(amountToAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void subtractBalance(BigDecimal amountToSubtract) {
|
||||||
|
if (amountToSubtract == null || amountToSubtract.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
throw new IllegalArgumentException("Amount to subtract must be positive.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.balance == null) {
|
||||||
|
this.balance = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.balance.compareTo(amountToSubtract) < 0) {
|
||||||
|
throw new IllegalStateException("Insufficient funds to subtract " + amountToSubtract);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.balance = this.balance.subtract(amountToSubtract);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package de.szut.casino.user.transaction;
|
package de.szut.casino.user.transaction;
|
||||||
|
|
||||||
import de.szut.casino.deposit.TransactionEntity;
|
|
||||||
import de.szut.casino.user.transaction.dto.GetTransactionDto;
|
|
||||||
import de.szut.casino.user.transaction.dto.UserTransactionsDto;
|
import de.szut.casino.user.transaction.dto.UserTransactionsDto;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -10,8 +8,6 @@ import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class TransactionController {
|
public class TransactionController {
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
spring.datasource.url=jdbc:postgresql://${DB_HOST:localhost}:5432/postgresdb
|
spring.datasource.url=jdbc:postgresql://${DB_HOST:localhost}:${DB_PORT:5432}/${DB_NAME:postgresdb}
|
||||||
spring.datasource.username=postgres_user
|
spring.datasource.username=${DB_USER:postgres_user}
|
||||||
spring.datasource.password=postgres_pass
|
spring.datasource.password=${DB_PASS:postgres_pass}
|
||||||
server.port=8080
|
server.port=${HTTP_PORT:8080}
|
||||||
spring.jpa.hibernate.ddl-auto=update
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
stripe.secret.key=${STRIPE_SECRET_KEY:sk_test_51QrePYIvCfqz7ANgqam8rEwWcMeKiLOof3j6SCMgu2sl4sESP45DJxca16mWcYo1sQaiBv32CMR6Z4AAAGQPCJo300ubuZKO8I}
|
stripe.secret.key=${STRIPE_SECRET_KEY:sk_test_51QrePYIvCfqz7ANgqam8rEwWcMeKiLOof3j6SCMgu2sl4sESP45DJxca16mWcYo1sQaiBv32CMR6Z4AAAGQPCJo300ubuZKO8I}
|
||||||
stripe.webhook.secret=whsec_746b6a488665f6057118bdb4a2b32f4916f16c277109eeaed5e8f8e8b81b8c15
|
stripe.webhook.secret=${STRIPE_WEBHOOK_SECRET:whsec_746b6a488665f6057118bdb4a2b32f4916f16c277109eeaed5e8f8e8b81b8c15}
|
||||||
app.frontend-host=http://localhost:4200
|
app.frontend-host=${FE_URL:http://localhost:4200}
|
||||||
|
|
||||||
spring.application.name=lf12_starter
|
spring.application.name=casino
|
||||||
#client registration configuration
|
#client registration configuration
|
||||||
|
|
||||||
spring.security.oauth2.client.registration.authentik.client-id=MDqjm1kcWKuZfqHJXjxwAV20i44aT7m4VhhTL3Nm
|
spring.security.oauth2.client.registration.authentik.client-id=${AUTH_CLIENT_ID:MDqjm1kcWKuZfqHJXjxwAV20i44aT7m4VhhTL3Nm}
|
||||||
spring.security.oauth2.client.registration.authentik.client-secret=GY2F8te6iAVYt1TNAUVLzWZEXb6JoMNp6chbjqaXNq4gS5xTDL54HqBiAlV1jFKarN28LQ7FUsYX4SbwjfEhZhgeoKuBnZKjR9eiu7RawnGgxIK9ffvUfMkjRxnmiGI5
|
spring.security.oauth2.client.registration.authentik.client-secret=${AUTH_CLIENT_SECRET:GY2F8te6iAVYt1TNAUVLzWZEXb6JoMNp6chbjqaXNq4gS5xTDL54HqBiAlV1jFKarN28LQ7FUsYX4SbwjfEhZhgeoKuBnZKjR9eiu7RawnGgxIK9ffvUfMkjRxnmiGI5}
|
||||||
spring.security.oauth2.client.registration.authentik.provider=authentik
|
spring.security.oauth2.client.registration.authentik.provider=authentik
|
||||||
spring.security.oauth2.client.registration.authentik.client-name=Authentik
|
spring.security.oauth2.client.registration.authentik.client-name=Authentik
|
||||||
spring.security.oauth2.client.registration.authentik.scope=openid,email,profile
|
spring.security.oauth2.client.registration.authentik.scope=openid,email,profile
|
||||||
|
@ -20,16 +20,16 @@ spring.security.oauth2.client.registration.authentik.authorization-grant-type=au
|
||||||
spring.security.oauth2.client.registration.authentik.redirect-uri={baseUrl}/login/oauth2/code/{registrationId}
|
spring.security.oauth2.client.registration.authentik.redirect-uri={baseUrl}/login/oauth2/code/{registrationId}
|
||||||
|
|
||||||
# Provider settings
|
# Provider settings
|
||||||
spring.security.oauth2.client.provider.authentik.issuer-uri=https://oauth.simonis.lol/application/o/casino-dev/
|
spring.security.oauth2.client.provider.authentik.issuer-uri=${AUTH_PROVIDER_ISSUER:https://oauth.simonis.lol/application/o/casino-dev/}
|
||||||
spring.security.oauth2.client.provider.authentik.authorization-uri=https://oauth.simonis.lol/application/o/authorize/
|
spring.security.oauth2.client.provider.authentik.authorization-uri=${AUTH_PROVIDER_AUTHORIZE_URI:https://oauth.simonis.lol/application/o/authorize/}
|
||||||
spring.security.oauth2.client.provider.authentik.token-uri=https://oauth.simonis.lol/application/o/token/
|
spring.security.oauth2.client.provider.authentik.token-uri=${AUTH_PROVIDER_TOKEN_URI:https://oauth.simonis.lol/application/o/token/}
|
||||||
spring.security.oauth2.client.provider.authentik.user-info-uri=https://oauth.simonis.lol/application/o/userinfo/
|
spring.security.oauth2.client.provider.authentik.user-info-uri=${AUTH_PROVIDER_USERINFO_URI:https://oauth.simonis.lol/application/o/userinfo/}
|
||||||
spring.security.oauth2.client.provider.authentik.jwk-set-uri=https://oauth.simonis.lol/application/o/casino-dev/jwks/
|
spring.security.oauth2.client.provider.authentik.jwk-set-uri=${AUTH_PROVIDER_JWKS_URI:https://oauth.simonis.lol/application/o/casino-dev/jwks/}
|
||||||
spring.security.oauth2.client.provider.authentik.user-name-attribute=preferred_username
|
spring.security.oauth2.client.provider.authentik.user-name-attribute=${AUTH_PROVIDER_NAME_ATTR:preferred_username}
|
||||||
|
|
||||||
# Resource server config
|
# Resource server config
|
||||||
spring.security.oauth2.resourceserver.jwt.issuer-uri=https://oauth.simonis.lol/application/o/casino-dev/
|
spring.security.oauth2.resourceserver.jwt.issuer-uri=${AUTH_JWT_ISSUER_URI:https://oauth.simonis.lol/application/o/casino-dev}/
|
||||||
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://oauth.simonis.lol/application/o/casino-dev/jwks/
|
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=${AUTH_JWT_JWT_SET_URI:https://oauth.simonis.lol/application/o/casino-dev/jwks/}
|
||||||
|
|
||||||
#OIDC provider configuration:
|
#OIDC provider configuration:
|
||||||
logging.level.org.springframework.security=DEBUG
|
logging.level.org.springframework.security=DEBUG
|
||||||
|
|
23
frontend/.docker/Dockerfile
Normal file
23
frontend/.docker/Dockerfile
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
FROM oven/bun:debian AS build
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apt-get update -y && apt-get install nodejs -y
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
COPY package.json bun.lock ./
|
||||||
|
RUN bun install --frozen-lockfile
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN bun run build
|
||||||
|
|
||||||
|
FROM nginx:alpine AS production
|
||||||
|
|
||||||
|
RUN rm /etc/nginx/conf.d/default.conf
|
||||||
|
COPY .docker/casino.conf /etc/nginx/templates/nginx.conf.template
|
||||||
|
COPY .docker/entrypoint.sh /docker-entrypoint.d/40-custom-config-env.sh
|
||||||
|
|
||||||
|
COPY --from=build /app/dist/casino /usr/share/nginx/html
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
19
frontend/.docker/casino.conf
Normal file
19
frontend/.docker/casino.conf
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
root /usr/share/nginx/html/browser;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
add_header Cache-Control "no-cache";
|
||||||
|
}
|
||||||
|
|
||||||
|
location /backend/ {
|
||||||
|
proxy_pass http://${BACKEND_HOST}:${BACKEND_PORT}/;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
}
|
||||||
|
}
|
7
frontend/.docker/entrypoint.sh
Executable file
7
frontend/.docker/entrypoint.sh
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Default values if not provided
|
||||||
|
: ${BACKEND_HOST:=localhost}
|
||||||
|
: ${BACKEND_PORT:=8080}
|
||||||
|
|
||||||
|
envsubst '$BACKEND_HOST $BACKEND_PORT' < /etc/nginx/templates/nginx.conf.template > /etc/nginx/conf.d/default.conf
|
||||||
|
exec nginx -g 'daemon off;'
|
15
frontend/.dockerignore
Normal file
15
frontend/.dockerignore
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.angular
|
||||||
|
.git
|
||||||
|
.github
|
||||||
|
.vscode
|
||||||
|
.idea
|
||||||
|
*.md
|
||||||
|
!README.md
|
||||||
|
.DS_Store
|
||||||
|
.env*
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
bun-debug.log*
|
|
@ -13,7 +13,7 @@
|
||||||
"build": {
|
"build": {
|
||||||
"builder": "@angular-devkit/build-angular:application",
|
"builder": "@angular-devkit/build-angular:application",
|
||||||
"options": {
|
"options": {
|
||||||
"outputPath": "dist/lf10-starter2024",
|
"outputPath": "dist/casino",
|
||||||
"index": "src/index.html",
|
"index": "src/index.html",
|
||||||
"browser": "src/main.ts",
|
"browser": "src/main.ts",
|
||||||
"tsConfig": "tsconfig.app.json",
|
"tsConfig": "tsconfig.app.json",
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
version: '3'
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
employee_postgres_data:
|
|
||||||
driver: local
|
|
||||||
|
|
||||||
services:
|
|
||||||
postgres-employee:
|
|
||||||
container_name: postgres_employee
|
|
||||||
image: postgres:17.4
|
|
||||||
volumes:
|
|
||||||
- employee_postgres_data:/var/lib/postgresql/data
|
|
||||||
environment:
|
|
||||||
POSTGRES_DB: employee_db
|
|
||||||
POSTGRES_USER: employee
|
|
||||||
POSTGRES_PASSWORD: secret
|
|
||||||
ports:
|
|
||||||
- "5432:5432"
|
|
||||||
|
|
||||||
employee:
|
|
||||||
container_name: employee
|
|
||||||
image: berndheidemann/employee-management-service:1.1.3
|
|
||||||
# image: berndheidemann/employee-management-service_without_keycloak:1.1
|
|
||||||
environment:
|
|
||||||
spring.datasource.url: jdbc:postgresql://postgres-employee:5432/employee_db
|
|
||||||
spring.datasource.username: employee
|
|
||||||
spring.datasource.password: secret
|
|
||||||
ports:
|
|
||||||
- "8089:8089"
|
|
||||||
depends_on:
|
|
||||||
- postgres-employee
|
|
|
@ -6,7 +6,7 @@ import { routes } from './app.routes';
|
||||||
import { provideHttpClient, withInterceptors } from '@angular/common/http';
|
import { provideHttpClient, withInterceptors } from '@angular/common/http';
|
||||||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
||||||
import { OAuthStorage, provideOAuthClient } from 'angular-oauth2-oidc';
|
import { OAuthStorage, provideOAuthClient } from 'angular-oauth2-oidc';
|
||||||
import { httpInterceptor } from './shared/interceptor/http.interceptor';
|
import { httpInterceptor } from '@shared/interceptor/http.interceptor';
|
||||||
|
|
||||||
export const appConfig: ApplicationConfig = {
|
export const appConfig: ApplicationConfig = {
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import {
|
import {
|
||||||
|
AfterViewInit,
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
|
ChangeDetectorRef,
|
||||||
Component,
|
Component,
|
||||||
ElementRef,
|
ElementRef,
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
inject,
|
inject,
|
||||||
Input,
|
Input,
|
||||||
|
OnChanges,
|
||||||
|
OnDestroy,
|
||||||
OnInit,
|
OnInit,
|
||||||
Output,
|
Output,
|
||||||
ViewChild,
|
|
||||||
AfterViewInit,
|
|
||||||
OnDestroy,
|
|
||||||
OnChanges,
|
|
||||||
SimpleChanges,
|
SimpleChanges,
|
||||||
ChangeDetectorRef,
|
ViewChild,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
import { loadStripe, Stripe } from '@stripe/stripe-js';
|
import { loadStripe, Stripe } from '@stripe/stripe-js';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { ChangeDetectionStrategy, Component, inject, signal, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, inject, OnInit, signal } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { PlayingCardComponent } from './components/playing-card/playing-card.component';
|
import { PlayingCardComponent } from './components/playing-card/playing-card.component';
|
||||||
|
@ -6,7 +6,7 @@ import { DealerHandComponent } from './components/dealer-hand/dealer-hand.compon
|
||||||
import { PlayerHandComponent } from './components/player-hand/player-hand.component';
|
import { PlayerHandComponent } from './components/player-hand/player-hand.component';
|
||||||
import { GameControlsComponent } from './components/game-controls/game-controls.component';
|
import { GameControlsComponent } from './components/game-controls/game-controls.component';
|
||||||
import { GameInfoComponent } from './components/game-info/game-info.component';
|
import { GameInfoComponent } from './components/game-info/game-info.component';
|
||||||
import { Card, BlackjackGame } from '@blackjack/models/blackjack.model';
|
import { BlackjackGame, Card } from '@blackjack/models/blackjack.model';
|
||||||
import { BlackjackService } from '@blackjack/services/blackjack.service';
|
import { BlackjackService } from '@blackjack/services/blackjack.service';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { GameResultComponent } from '@blackjack/components/game-result/game-result.component';
|
import { GameResultComponent } from '@blackjack/components/game-result/game-result.component';
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import {
|
import {
|
||||||
|
AfterViewInit,
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
Component,
|
Component,
|
||||||
|
ElementRef,
|
||||||
Input,
|
Input,
|
||||||
OnChanges,
|
OnChanges,
|
||||||
SimpleChanges,
|
SimpleChanges,
|
||||||
ElementRef,
|
|
||||||
ViewChild,
|
ViewChild,
|
||||||
AfterViewInit,
|
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { CommonModule, CurrencyPipe } from '@angular/common';
|
import { CommonModule, CurrencyPipe } from '@angular/common';
|
||||||
import { CountUp } from 'countup.js';
|
import { CountUp } from 'countup.js';
|
||||||
|
|
|
@ -5,8 +5,8 @@ import {
|
||||||
Input,
|
Input,
|
||||||
OnChanges,
|
OnChanges,
|
||||||
Output,
|
Output,
|
||||||
SimpleChanges,
|
|
||||||
signal,
|
signal,
|
||||||
|
SimpleChanges,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { CommonModule, CurrencyPipe } from '@angular/common';
|
import { CommonModule, CurrencyPipe } from '@angular/common';
|
||||||
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
|
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { ChangeDetectionStrategy, Component, Input, Output, EventEmitter } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
|
||||||
import { CommonModule, CurrencyPipe } from '@angular/common';
|
import { CommonModule, CurrencyPipe } from '@angular/common';
|
||||||
import { animate, style, transition, trigger } from '@angular/animations';
|
import { animate, style, transition, trigger } from '@angular/animations';
|
||||||
import { GameState } from '../../enum/gameState';
|
import { GameState } from '../../enum/gameState';
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import {
|
import {
|
||||||
|
AfterViewInit,
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
Component,
|
Component,
|
||||||
Input,
|
|
||||||
AfterViewInit,
|
|
||||||
ElementRef,
|
ElementRef,
|
||||||
|
Input,
|
||||||
OnChanges,
|
OnChanges,
|
||||||
SimpleChanges,
|
SimpleChanges,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Injectable, inject } from '@angular/core';
|
import { inject, Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Observable, catchError } from 'rxjs';
|
import { catchError, Observable } from 'rxjs';
|
||||||
import { BlackjackGame } from '@blackjack/models/blackjack.model';
|
import { BlackjackGame } from '@blackjack/models/blackjack.model';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
|
|
|
@ -91,9 +91,6 @@
|
||||||
[isOpen]="isTransactionModalOpen"
|
[isOpen]="isTransactionModalOpen"
|
||||||
(closeEventEmitter)="closeTransactionModal()"
|
(closeEventEmitter)="closeTransactionModal()"
|
||||||
/>
|
/>
|
||||||
<button class="bg-deep-blue-light hover:bg-deep-blue-contrast w-full py-2 rounded">
|
|
||||||
Kontoeinstellungen
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { ChangeDetectionStrategy, Component, OnInit, OnDestroy } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { NgFor } from '@angular/common';
|
import { NgFor } from '@angular/common';
|
||||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
export interface Transaction {
|
export interface Transaction {
|
||||||
id: string;
|
|
||||||
status: string;
|
status: string;
|
||||||
amount: number;
|
amount: number;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import {
|
import {
|
||||||
|
AfterViewInit,
|
||||||
Component,
|
Component,
|
||||||
ElementRef,
|
ElementRef,
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
Input,
|
Input,
|
||||||
|
OnDestroy,
|
||||||
Output,
|
Output,
|
||||||
ViewChild,
|
ViewChild,
|
||||||
AfterViewInit,
|
|
||||||
OnDestroy,
|
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { ModalAnimationService } from '@shared/services/modal-animation.service';
|
import { ModalAnimationService } from '@shared/services/modal-animation.service';
|
||||||
import gsap from 'gsap';
|
import gsap from 'gsap';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||||
import { faMoneyBillTransfer, faCreditCard, faWallet } from '@fortawesome/free-solid-svg-icons';
|
import { faCreditCard, faMoneyBillTransfer, faWallet } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { faPaypal, faGooglePay, faApplePay } from '@fortawesome/free-brands-svg-icons';
|
import { faApplePay, faGooglePay, faPaypal } from '@fortawesome/free-brands-svg-icons';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-footer',
|
selector: 'app-footer',
|
||||||
|
|
|
@ -2,8 +2,8 @@ import {
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
Component,
|
Component,
|
||||||
inject,
|
inject,
|
||||||
OnInit,
|
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
|
OnInit,
|
||||||
signal,
|
signal,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue