Compare commits

..

No commits in common. "v1.37.0" and "v1.36.1" have entirely different histories.

6 changed files with 5 additions and 30 deletions

View file

@ -1,6 +1,5 @@
package de.szut.casino.blackjack;
import de.szut.casino.exceptionHandling.exceptions.InsufficientFundsException;
import de.szut.casino.exceptionHandling.exceptions.UserNotFoundException;
import de.szut.casino.shared.dto.BetDto;
import de.szut.casino.shared.service.BalanceService;
@ -124,7 +123,7 @@ public class BlackJackGameController {
UserEntity user = optionalUser.get();
if (!this.balanceService.hasFunds(user, betDto)) {
throw new InsufficientFundsException();
return ResponseEntity.badRequest().body(Collections.singletonMap("error", "Insufficient funds"));
}
return ResponseEntity.ok(blackJackService.createBlackJackGame(user, betDto.getBetAmount()));

View file

@ -1,6 +1,5 @@
package de.szut.casino.exceptionHandling;
import de.szut.casino.exceptionHandling.exceptions.InsufficientFundsException;
import de.szut.casino.exceptionHandling.exceptions.UserNotFoundException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -18,10 +17,4 @@ public class GlobalExceptionHandler {
ErrorDetails errorDetails = new ErrorDetails(new Date(), ex.getMessage(), request.getDescription(false));
return new ResponseEntity<>(errorDetails, HttpStatus.NOT_FOUND);
}
@ExceptionHandler(InsufficientFundsException.class)
public ResponseEntity<?> handleInsufficientFundsException(InsufficientFundsException ex, WebRequest request) {
ErrorDetails errorDetails = new ErrorDetails(new Date(), ex.getMessage(), request.getDescription(false));
return new ResponseEntity<>(errorDetails, HttpStatus.BAD_REQUEST);
}
}

View file

@ -1,11 +0,0 @@
package de.szut.casino.exceptionHandling.exceptions;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
public class InsufficientFundsException extends RuntimeException {
public InsufficientFundsException() {
super("insufficient funds");
}
}

View file

@ -1,6 +1,5 @@
package de.szut.casino.lootboxes;
import de.szut.casino.exceptionHandling.exceptions.InsufficientFundsException;
import de.szut.casino.exceptionHandling.exceptions.UserNotFoundException;
import de.szut.casino.user.UserEntity;
import de.szut.casino.user.UserRepository;
@ -45,7 +44,9 @@ public class LootBoxController {
UserEntity user = optionalUser.get();
if (lootBoxService.hasSufficientBalance(user, lootBox.getPrice())) {
throw new InsufficientFundsException();
Map<String, String> errorResponse = new HashMap<>();
errorResponse.put("error", "Insufficient balance");
return ResponseEntity.badRequest().body(errorResponse);
}
RewardEntity reward = lootBoxService.determineReward(lootBox);

View file

@ -1,6 +1,5 @@
package de.szut.casino.slots;
import de.szut.casino.exceptionHandling.exceptions.InsufficientFundsException;
import de.szut.casino.exceptionHandling.exceptions.UserNotFoundException;
import de.szut.casino.shared.dto.BetDto;
import de.szut.casino.shared.service.BalanceService;
@ -39,7 +38,7 @@ public class SlotController {
UserEntity user = optionalUser.get();
if (!this.balanceService.hasFunds(user, betDto)) {
throw new InsufficientFundsException();
return ResponseEntity.badRequest().body(Collections.singletonMap("error", "Insufficient funds"));
}
SpinResult spinResult = this.slotService.spin(

View file

@ -3,11 +3,5 @@
: ${BACKEND_HOST:=localhost}
: ${BACKEND_PORT:=8080}
# Wait until the backend host is resolvable
echo "Waiting for backend host $BACKEND_HOST..."
until getent hosts "$BACKEND_HOST" > /dev/null; do
sleep 1
done
envsubst '$BACKEND_HOST $BACKEND_PORT' < /etc/nginx/templates/nginx.conf.template > /etc/nginx/conf.d/default.conf
exec nginx -g 'daemon off;'