Compare commits
No commits in common. "v1.32.0" and "v1.31.0" have entirely different histories.
15 changed files with 17 additions and 319 deletions
|
@ -6,7 +6,6 @@ import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -27,7 +26,4 @@ public class TransactionEntity {
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private TransactionStatus status = TransactionStatus.PROCESSING;
|
private TransactionStatus status = TransactionStatus.PROCESSING;
|
||||||
|
|
||||||
@Column(name = "created_at")
|
|
||||||
private Date createdAt = new Date();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,20 +5,10 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public interface TransactionRepository extends JpaRepository<TransactionEntity, Long> {
|
public interface TransactionRepository extends JpaRepository<TransactionEntity, Long> {
|
||||||
@Query("SELECT t FROM TransactionEntity t WHERE t.sessionId = ?1")
|
@Query("SELECT t FROM TransactionEntity t WHERE t.sessionId = ?1")
|
||||||
Optional<TransactionEntity> findOneBySessionID(String sessionId);
|
Optional<TransactionEntity> findOneBySessionID(String sessionId);
|
||||||
|
|
||||||
@Query("SELECT t FROM TransactionEntity t WHERE t.user = ?1")
|
|
||||||
List<TransactionEntity> findAllByUserId(UserEntity id);
|
|
||||||
|
|
||||||
@Query("SELECT t FROM TransactionEntity t WHERE t.user = ?1 ORDER BY t.createdAt DESC LIMIT ?2 OFFSET ?3")
|
|
||||||
List<TransactionEntity> findByUserIdWithLimit(UserEntity userEntity, Integer limit, Integer offset);
|
|
||||||
|
|
||||||
@Query("SELECT COUNT(t) > ?2 + ?3 FROM TransactionEntity t WHERE t.user = ?1")
|
|
||||||
Boolean hasMore(UserEntity userEntity, Integer limit, Integer offset);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,12 @@ 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.GetMapping;
|
||||||
|
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 de.szut.casino.user.dto.CreateUserDto;
|
import de.szut.casino.user.dto.CreateUserDto;
|
||||||
import de.szut.casino.user.dto.GetUserDto;
|
import de.szut.casino.user.dto.GetUserDto;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
package de.szut.casino.user.transaction;
|
|
||||||
|
|
||||||
import de.szut.casino.deposit.TransactionEntity;
|
|
||||||
import de.szut.casino.deposit.TransactionRepository;
|
|
||||||
import de.szut.casino.user.UserEntity;
|
|
||||||
import de.szut.casino.user.UserService;
|
|
||||||
import de.szut.casino.user.transaction.dto.GetTransactionDto;
|
|
||||||
import de.szut.casino.user.transaction.dto.UserTransactionsDto;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class GetTransactionService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TransactionRepository transactionRepository;
|
|
||||||
|
|
||||||
public UserTransactionsDto getUserTransactionsDto(String authToken, Integer limit, Integer offset) {
|
|
||||||
Optional<UserEntity> user = this.userService.getCurrentUser(authToken);
|
|
||||||
if (user.isPresent()) {
|
|
||||||
List<TransactionEntity> transactionEntities = this.transactionRepository.findByUserIdWithLimit(user.get(), limit, offset);
|
|
||||||
Boolean hasMore = this.transactionRepository.hasMore(user.get(), limit, offset);
|
|
||||||
|
|
||||||
return new UserTransactionsDto(mapTransactionsToDtos(transactionEntities), hasMore);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new UserTransactionsDto(List.of(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GetTransactionDto> mapTransactionsToDtos(List<TransactionEntity> transactions) {
|
|
||||||
return transactions.stream()
|
|
||||||
.map(transaction -> new GetTransactionDto(
|
|
||||||
transaction.getAmount(),
|
|
||||||
transaction.getStatus(),
|
|
||||||
transaction.getCreatedAt())
|
|
||||||
).toList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
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 org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
public class TransactionController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private GetTransactionService transactionService;
|
|
||||||
|
|
||||||
@GetMapping("/user/transactions")
|
|
||||||
public ResponseEntity<UserTransactionsDto> getUserTransactions(
|
|
||||||
@RequestHeader("Authorization") String authToken,
|
|
||||||
@RequestParam(value = "limit", required = false) Integer limit,
|
|
||||||
@RequestParam(value = "offset", required = false) Integer offset
|
|
||||||
) {
|
|
||||||
UserTransactionsDto transactionEntities = this.transactionService.getUserTransactionsDto(authToken, limit, offset);
|
|
||||||
|
|
||||||
return ResponseEntity.ok(transactionEntities);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package de.szut.casino.user.transaction.dto;
|
|
||||||
|
|
||||||
import de.szut.casino.deposit.TransactionStatus;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class GetTransactionDto {
|
|
||||||
public double amount = 0;
|
|
||||||
public TransactionStatus status = TransactionStatus.PROCESSING;
|
|
||||||
public Date createdAt = new Date();
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
package de.szut.casino.user.transaction.dto;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class UserTransactionsDto {
|
|
||||||
public List<GetTransactionDto> transactions;
|
|
||||||
public Boolean hasMore;
|
|
||||||
}
|
|
||||||
|
|
|
@ -81,16 +81,9 @@
|
||||||
[isOpen]="isDepositModalOpen"
|
[isOpen]="isDepositModalOpen"
|
||||||
(closeModalEmitter)="closeDepositModal()"
|
(closeModalEmitter)="closeDepositModal()"
|
||||||
></app-deposit>
|
></app-deposit>
|
||||||
<button
|
<button class="bg-deep-blue-light hover:bg-deep-blue-contrast w-full py-2 rounded">
|
||||||
class="bg-deep-blue-light hover:bg-deep-blue-contrast w-full py-2 rounded"
|
|
||||||
(click)="openTransactionModal()"
|
|
||||||
>
|
|
||||||
Transaktionen
|
Transaktionen
|
||||||
</button>
|
</button>
|
||||||
<app-transaction-history
|
|
||||||
[isOpen]="isTransactionModalOpen"
|
|
||||||
(closeEventEmitter)="closeTransactionModal()"
|
|
||||||
/>
|
|
||||||
<button class="bg-deep-blue-light hover:bg-deep-blue-contrast w-full py-2 rounded">
|
<button class="bg-deep-blue-light hover:bg-deep-blue-contrast w-full py-2 rounded">
|
||||||
Kontoeinstellungen
|
Kontoeinstellungen
|
||||||
</button>
|
</button>
|
||||||
|
@ -107,13 +100,11 @@
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
<div
|
<div
|
||||||
class="flex justify-between items-center"
|
class="flex justify-between items-center"
|
||||||
*ngFor="let transaction of (recentTransactionData | async)?.transactions"
|
*ngFor="let transaction of recentTransactions"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<p class="text-sm font-medium">{{ transaction.status }}</p>
|
<p class="text-sm font-medium">{{ transaction.type }}</p>
|
||||||
<p class="text-xs text-text-secondary">
|
<p class="text-xs text-text-secondary">{{ transaction.date }}</p>
|
||||||
{{ transaction.createdAt | date: 'd.m.Y H:m' }}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<span [class]="transaction.amount > 0 ? 'text-emerald' : 'text-accent-red'">
|
<span [class]="transaction.amount > 0 ? 'text-emerald' : 'text-accent-red'">
|
||||||
{{ transaction.amount | currency: 'EUR' }}
|
{{ transaction.amount | currency: 'EUR' }}
|
||||||
|
|
|
@ -1,36 +1,22 @@
|
||||||
import { ChangeDetectionStrategy, Component, inject, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
||||||
import { AsyncPipe, CurrencyPipe, DatePipe, NgFor } from '@angular/common';
|
import { CurrencyPipe, NgFor } from '@angular/common';
|
||||||
import { DepositComponent } from '../deposit/deposit.component';
|
import { DepositComponent } from '../deposit/deposit.component';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { ConfirmationComponent } from '@shared/components/confirmation/confirmation.component';
|
import { ConfirmationComponent } from '@shared/components/confirmation/confirmation.component';
|
||||||
|
import { Transaction } from 'app/model/Transaction';
|
||||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
||||||
import { Game } from 'app/model/Game';
|
import { Game } from 'app/model/Game';
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { TransactionService } from '@service/transaction.service';
|
|
||||||
import format from 'ajv/dist/vocabularies/format';
|
|
||||||
import { TransactionHistoryComponent } from '../transaction-history/transaction-history.component';
|
|
||||||
import { TransactionData } from '../../model/TransactionData';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-homepage',
|
selector: 'app-homepage',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [NavbarComponent, CurrencyPipe, NgFor, DepositComponent, ConfirmationComponent],
|
||||||
NavbarComponent,
|
|
||||||
CurrencyPipe,
|
|
||||||
NgFor,
|
|
||||||
DepositComponent,
|
|
||||||
ConfirmationComponent,
|
|
||||||
AsyncPipe,
|
|
||||||
DatePipe,
|
|
||||||
TransactionHistoryComponent,
|
|
||||||
],
|
|
||||||
templateUrl: './home.component.html',
|
templateUrl: './home.component.html',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export default class HomeComponent implements OnInit {
|
export default class HomeComponent implements OnInit {
|
||||||
isDepositModalOpen = false;
|
isDepositModalOpen = false;
|
||||||
isDepositSuccessful = false;
|
isDepositSuccessful = false;
|
||||||
isTransactionModalOpen = false;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public route: ActivatedRoute,
|
public route: ActivatedRoute,
|
||||||
|
@ -88,13 +74,11 @@ export default class HomeComponent implements OnInit {
|
||||||
|
|
||||||
allGames: Game[] = [...this.featuredGames];
|
allGames: Game[] = [...this.featuredGames];
|
||||||
|
|
||||||
recentTransactionData: Observable<TransactionData> =
|
recentTransactions: Transaction[] = [];
|
||||||
inject(TransactionService).getUsersTransactions(5);
|
|
||||||
|
|
||||||
openDepositModal() {
|
openDepositModal() {
|
||||||
this.isDepositModalOpen = true;
|
this.isDepositModalOpen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
closeDepositModal() {
|
closeDepositModal() {
|
||||||
this.isDepositModalOpen = false;
|
this.isDepositModalOpen = false;
|
||||||
}
|
}
|
||||||
|
@ -102,22 +86,11 @@ export default class HomeComponent implements OnInit {
|
||||||
openDepositConfirmationModal() {
|
openDepositConfirmationModal() {
|
||||||
this.isDepositSuccessful = true;
|
this.isDepositSuccessful = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
openTransactionModal() {
|
|
||||||
this.isTransactionModalOpen = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
closeDepositConfirmationModal() {
|
closeDepositConfirmationModal() {
|
||||||
this.isDepositSuccessful = false;
|
this.isDepositSuccessful = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
closeTransactionModal() {
|
|
||||||
this.isTransactionModalOpen = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
navigateToGame(route: string) {
|
navigateToGame(route: string) {
|
||||||
this.router.navigate([route]);
|
this.router.navigate([route]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected readonly format = format;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
button[disabled] {
|
|
||||||
cursor: not-allowed;
|
|
||||||
background-color: #077b58;
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
button[disabled]:hover {
|
|
||||||
background-color: #077b58;
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
<div *ngIf="isOpen" [@fadeInOut] class="modal-bg" style="z-index: 1000; position: fixed">
|
|
||||||
<div class="modal-card" [@cardAnimation]>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
(click)="closeDialog()"
|
|
||||||
class="absolute top-2 right-2 text-text-secondary"
|
|
||||||
>
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 24 24">
|
|
||||||
<path
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
stroke-width="2"
|
|
||||||
d="M18 6L6 18M6 6l12 12"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
<h2 class="modal-heading mb-0">Transaktionen</h2>
|
|
||||||
<p class="pb-1 text-text-secondary mb-4">Hier siehst du alle vergangenen Einzahlungen</p>
|
|
||||||
@for (transaction of (transactionData$ | async)?.transactions; track null) {
|
|
||||||
<div class="flex justify-between items-center mb-4">
|
|
||||||
<div>
|
|
||||||
<p class="text-sm font-medium">{{ transaction.status }}</p>
|
|
||||||
<p class="text-xs text-text-secondary">{{ transaction.createdAt | date: 'd.m.Y H:m' }}</p>
|
|
||||||
</div>
|
|
||||||
<span [class]="transaction.amount > 0 ? 'text-emerald' : 'text-accent-red'">
|
|
||||||
{{ transaction.amount | currency: 'EUR' }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
} @empty {
|
|
||||||
<div class="flex justify-center items-center w-full h-32">
|
|
||||||
<div
|
|
||||||
class="spinner-border animate-spin inline-block w-8 h-8 border-4 rounded-full border-gray-300 border-t-gree-600"
|
|
||||||
role="status"
|
|
||||||
>
|
|
||||||
<span class="sr-only">Loading...</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
<div class="inline inline-flex w-full gap-2">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
(click)="back()"
|
|
||||||
class="button-primary w-full py-2"
|
|
||||||
[disabled]="offset <= 0"
|
|
||||||
>
|
|
||||||
<
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
(click)="forward()"
|
|
||||||
class="button-primary w-full py-2"
|
|
||||||
[disabled]="!(transactionData$ | async)?.hasMore"
|
|
||||||
>
|
|
||||||
>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
|
@ -1,54 +0,0 @@
|
||||||
import {
|
|
||||||
ChangeDetectionStrategy,
|
|
||||||
Component,
|
|
||||||
EventEmitter,
|
|
||||||
inject,
|
|
||||||
Input,
|
|
||||||
Output,
|
|
||||||
} from '@angular/core';
|
|
||||||
import { TransactionService } from '@service/transaction.service';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { AsyncPipe, CurrencyPipe, DatePipe, NgForOf, NgIf } from '@angular/common';
|
|
||||||
import { AnimatedNumberComponent } from '@blackjack/components/animated-number/animated-number.component';
|
|
||||||
import { TransactionData } from '../../model/TransactionData';
|
|
||||||
|
|
||||||
const PER_PAGE = 5;
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
standalone: true,
|
|
||||||
selector: 'app-transaction-history',
|
|
||||||
imports: [NgForOf, AsyncPipe, CurrencyPipe, DatePipe, AnimatedNumberComponent, NgIf],
|
|
||||||
templateUrl: './transaction-history.component.html',
|
|
||||||
styleUrl: './transaction-history.component.css',
|
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
||||||
})
|
|
||||||
export class TransactionHistoryComponent {
|
|
||||||
@Input()
|
|
||||||
isOpen = false;
|
|
||||||
@Output()
|
|
||||||
closeEventEmitter = new EventEmitter<void>();
|
|
||||||
|
|
||||||
protected offset = 0;
|
|
||||||
|
|
||||||
private transactionService: TransactionService = inject(TransactionService);
|
|
||||||
transactionData$: Observable<TransactionData> = this.loadTransactions();
|
|
||||||
|
|
||||||
closeDialog() {
|
|
||||||
this.isOpen = false;
|
|
||||||
this.closeEventEmitter.emit();
|
|
||||||
}
|
|
||||||
|
|
||||||
forward() {
|
|
||||||
this.offset++;
|
|
||||||
this.transactionData$ = this.loadTransactions();
|
|
||||||
}
|
|
||||||
|
|
||||||
back() {
|
|
||||||
this.offset--;
|
|
||||||
this.transactionData$ = this.loadTransactions();
|
|
||||||
}
|
|
||||||
|
|
||||||
loadTransactions() {
|
|
||||||
return this.transactionService.getUsersTransactions(PER_PAGE, this.offset * PER_PAGE);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
export interface Transaction {
|
export interface Transaction {
|
||||||
id: string;
|
id: string;
|
||||||
status: string;
|
type: string;
|
||||||
amount: number;
|
amount: number;
|
||||||
createdAt: string;
|
date: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
import { Transaction } from './Transaction';
|
|
||||||
|
|
||||||
export interface TransactionData {
|
|
||||||
transactions: Transaction[];
|
|
||||||
hasMore: boolean;
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
import { inject, Injectable } from '@angular/core';
|
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { TransactionData } from '../model/TransactionData';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root',
|
|
||||||
})
|
|
||||||
export class TransactionService {
|
|
||||||
private http: HttpClient = inject(HttpClient);
|
|
||||||
|
|
||||||
public getUsersTransactions(limit: number | null = null, offset: number | null = null) {
|
|
||||||
const baseUrl = new URL(`${window.location.origin}/backend/user/transactions`);
|
|
||||||
|
|
||||||
if (limit !== null) {
|
|
||||||
baseUrl.searchParams.append('limit', limit.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (offset !== null) {
|
|
||||||
baseUrl.searchParams.append('offset', offset.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.http.get<TransactionData>(`${baseUrl}`);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue