test
This commit is contained in:
parent
c644a1f2d5
commit
39f23a3c80
8 changed files with 92 additions and 29 deletions
|
|
@ -1,12 +1,12 @@
|
|||
package fr.teamflash.fencerjudgeback.restControllers
|
||||
|
||||
import fr.teamflash.fencerjudgeback.entities.MatchBean
|
||||
import fr.teamflash.fencerjudgeback.restControllers.RefereeRestController.Companion.URL_ORIGIN
|
||||
import fr.teamflash.fencerjudgeback.services.MatchService
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.*
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = ["*"])
|
||||
@RequestMapping("/matches")
|
||||
class MatchRestController(private val matchService: MatchService) {
|
||||
|
||||
|
|
@ -69,7 +69,6 @@ class MatchRestController(private val matchService: MatchService) {
|
|||
}
|
||||
|
||||
// Ajouter un match
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@PostMapping("/create-match")
|
||||
fun createMatch(@RequestBody match: MatchBean): ResponseEntity<MatchBean> {
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(matchService.createMatch(match))
|
||||
|
|
@ -77,14 +76,13 @@ class MatchRestController(private val matchService: MatchService) {
|
|||
}
|
||||
|
||||
// Mettre à jour un match
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
|
||||
@PutMapping("/update-match/{id}")
|
||||
fun updateMatch(@PathVariable id: Long, @RequestBody match: MatchBean): ResponseEntity<Int> {
|
||||
return ResponseEntity.ok(matchService.updateMatch(id, match))
|
||||
}
|
||||
|
||||
// Supprimer un match
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@DeleteMapping("/delete-match/{id}")
|
||||
fun deleteMatch(@PathVariable id: Long): ResponseEntity<Int> {
|
||||
return ResponseEntity.ok(matchService.deleteMatchById(id))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package fr.teamflash.fencerjudgeback.restControllers
|
||||
|
||||
import fr.teamflash.fencerjudgeback.entities.PlayerBean
|
||||
import fr.teamflash.fencerjudgeback.restControllers.RefereeRestController.Companion.URL_ORIGIN
|
||||
import fr.teamflash.fencerjudgeback.services.PlayerService
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.CrossOrigin
|
||||
|
|
@ -15,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping
|
|||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = ["*"])
|
||||
@RequestMapping("/players")
|
||||
class PlayerRestController(private val playerService: PlayerService) {
|
||||
|
||||
|
|
@ -53,21 +53,18 @@ class PlayerRestController(private val playerService: PlayerService) {
|
|||
}
|
||||
|
||||
// Ajouter un joueur
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@PostMapping("/create-player")
|
||||
fun createPlayer(@RequestBody player: PlayerBean): ResponseEntity<PlayerBean> {
|
||||
return ResponseEntity.ok(playerService.createPlayer(player))
|
||||
}
|
||||
|
||||
// Modifier un joueur
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@PutMapping("/update-player/{id}")
|
||||
fun updatePlayer(@PathVariable id: Long, @RequestBody player: PlayerBean): ResponseEntity<Int> {
|
||||
return ResponseEntity.ok(playerService.updatePlayer(id, player))
|
||||
}
|
||||
|
||||
// Supprimer un joueur
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@DeleteMapping("/delete-player/{id}")
|
||||
fun deletePlayer(@PathVariable id: Long): ResponseEntity<Int> {
|
||||
return ResponseEntity.ok(playerService.deletePlayerById(id))
|
||||
|
|
|
|||
|
|
@ -14,13 +14,10 @@ import org.springframework.web.bind.annotation.RequestMapping
|
|||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = ["*"])
|
||||
@RequestMapping("/referees")
|
||||
class RefereeRestController(private val refereeService: RefereeService) {
|
||||
|
||||
companion object {
|
||||
const val URL_ORIGIN: String = "http://localhost:*"
|
||||
}
|
||||
|
||||
// Lister tous les arbitres
|
||||
@GetMapping("/")
|
||||
fun getAll() : ResponseEntity<List<RefereeBean>> {
|
||||
|
|
@ -52,21 +49,18 @@ class RefereeRestController(private val refereeService: RefereeService) {
|
|||
}
|
||||
|
||||
// Ajouter un arbitre
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@PostMapping("/create-referee")
|
||||
fun createReferee(@RequestBody referee: RefereeBean): ResponseEntity<RefereeBean> {
|
||||
return ResponseEntity.ok(refereeService.createReferee(referee))
|
||||
}
|
||||
|
||||
// Modifier un arbitre
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@PutMapping("/update-referee/{id}")
|
||||
fun updateReferee(@PathVariable id: Long, @RequestBody referee: RefereeBean) : ResponseEntity<Int> {
|
||||
return ResponseEntity.ok(refereeService.updateReferee(id, referee))
|
||||
}
|
||||
|
||||
// Supprimer un arbitre
|
||||
@CrossOrigin(origins = [URL_ORIGIN])
|
||||
@DeleteMapping("/delete-referee/{id}")
|
||||
fun deleteReferee(@PathVariable id:Long): ResponseEntity<Int> {
|
||||
return ResponseEntity.ok(refereeService.deleteRefereeById(id))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
import { AppComponent } from './app.component';
|
||||
|
|
@ -29,7 +30,7 @@ import { MatchesDelComponent } from './components/match/matches-del/matches-del.
|
|||
SponsortComponent,
|
||||
MatchesDelComponent,
|
||||
],
|
||||
imports: [BrowserModule, AppRoutingModule, FormsModule],
|
||||
imports: [BrowserModule, AppRoutingModule, FormsModule, HttpClientModule],
|
||||
providers: [],
|
||||
bootstrap: [AppComponent],
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable, Subject, BehaviorSubject, of } from 'rxjs';
|
||||
import { Matches, MatchState } from '@interfaces/matches';
|
||||
|
||||
|
|
@ -46,16 +47,50 @@ export class MatchesService {
|
|||
},
|
||||
];
|
||||
private socket?: WebSocket;
|
||||
private apiUrl = 'http://localhost:8080';
|
||||
private matchUpdates$ = new Subject<Matches[]>();
|
||||
private allMatches: Matches[] = [];
|
||||
private nextMatchId = Math.max(...this.matches.map((m) => m.id)) + 1;
|
||||
|
||||
constructor() {
|
||||
this.connectToMatchUpdatesWebSocket();
|
||||
constructor(private http: HttpClient) {
|
||||
this.sendCurrentMatches();
|
||||
}
|
||||
|
||||
public sendCurrentMatches(): void {
|
||||
if (!this.matches || this.matches.length === 0) {
|
||||
console.warn('[HTTP] ⚠️ Aucun match à envoyer.');
|
||||
return;
|
||||
}
|
||||
|
||||
const headers = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
this.matches.forEach((match) => {
|
||||
this.http
|
||||
.post(
|
||||
this.apiUrl + '/matches/create-match',
|
||||
JSON.stringify(match),
|
||||
headers
|
||||
)
|
||||
.subscribe({
|
||||
next: (response) => {
|
||||
console.log('[HTTP] ✅ Match envoyé avec succès :', response);
|
||||
},
|
||||
error: (error) => {
|
||||
console.error(
|
||||
'[HTTP] ❌ Erreur lors de l’envoi d’un match :',
|
||||
error
|
||||
);
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private connectToMatchUpdatesWebSocket(): void {
|
||||
const wsUrl = 'http://localhost:8080/ws/matches-app';
|
||||
const wsUrl = 'http://localhost:8080/ws';
|
||||
this.socket = new WebSocket(wsUrl);
|
||||
|
||||
this.socket.onopen = () => {
|
||||
|
|
@ -91,10 +126,6 @@ export class MatchesService {
|
|||
}
|
||||
}
|
||||
|
||||
public sendCurrentMatches(): void {
|
||||
this.sendMatchesToWebSocket();
|
||||
}
|
||||
|
||||
getMatches(): Observable<Matches[]> {
|
||||
return this.matchUpdates$.asObservable();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
#FileLock
|
||||
#Mon Jun 02 17:40:34 CEST 2025
|
||||
hostName=ExostFlash
|
||||
id=197313393c88a931fa21bf5ce1281b7253870b00683
|
||||
method=file
|
||||
server=192.167.2.100\:54366
|
||||
BIN
db.mv.db
BIN
db.mv.db
Binary file not shown.
48
db.trace.db
Normal file
48
db.trace.db
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
2025-06-03 09:54:12.514185+02:00 database: close
|
||||
org.h2.message.DbException: IO Exception: "Closing"
|
||||
IO Exception: "Closing" [90028-232]
|
||||
at org.h2.message.DbException.get(DbException.java:212)
|
||||
at org.h2.mvstore.db.Store.close(Store.java:374)
|
||||
at org.h2.engine.Database.closeOpenFilesAndUnlock(Database.java:1292)
|
||||
at org.h2.engine.Database.closeImpl(Database.java:1254)
|
||||
at org.h2.engine.Database.close(Database.java:1173)
|
||||
at org.h2.engine.Database.onShutdown(Database.java:1158)
|
||||
at org.h2.engine.OnExitDatabaseCloser.onShutdown(OnExitDatabaseCloser.java:85)
|
||||
at org.h2.engine.OnExitDatabaseCloser.run(OnExitDatabaseCloser.java:114)
|
||||
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: IO Exception: "Closing"
|
||||
IO Exception: "Closing" [90028-232]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:566)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
|
||||
... 8 more
|
||||
Caused by: org.h2.mvstore.MVStoreException: Reading from file sun.nio.ch.FileChannelImpl@1baeb921 failed at 15775 (length -1), read 0, remaining 24 [2.3.232/1]
|
||||
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)
|
||||
at org.h2.mvstore.DataUtils.readFully(DataUtils.java:455)
|
||||
at org.h2.mvstore.FileStore.readFully(FileStore.java:721)
|
||||
at org.h2.mvstore.SingleFileStore.readFully(SingleFileStore.java:60)
|
||||
at org.h2.mvstore.SingleFileStore.readFully(SingleFileStore.java:28)
|
||||
at org.h2.mvstore.SFChunk.readFully(SFChunk.java:35)
|
||||
at org.h2.mvstore.Chunk.readToC(Chunk.java:496)
|
||||
at org.h2.mvstore.FileStore.getToC(FileStore.java:2070)
|
||||
at org.h2.mvstore.FileStore.rewriteChunks(FileStore.java:1913)
|
||||
at org.h2.mvstore.FileStore.compactRewrite(FileStore.java:1901)
|
||||
at org.h2.mvstore.FileStore.rewriteChunks(FileStore.java:1862)
|
||||
at org.h2.mvstore.FileStore.lambda$compact$0(FileStore.java:879)
|
||||
at org.h2.mvstore.MVStore.tryExecuteUnderStoreLock(MVStore.java:937)
|
||||
at org.h2.mvstore.FileStore.compact(FileStore.java:879)
|
||||
at org.h2.mvstore.RandomAccessStore.compactStore(RandomAccessStore.java:441)
|
||||
at org.h2.mvstore.FileStore.compactStore(FileStore.java:890)
|
||||
at org.h2.mvstore.FileStore.stop(FileStore.java:275)
|
||||
at org.h2.mvstore.MVStore.closeStore(MVStore.java:693)
|
||||
at org.h2.mvstore.MVStore.close(MVStore.java:643)
|
||||
at org.h2.mvstore.db.Store.close(Store.java:364)
|
||||
... 6 more
|
||||
Caused by: java.io.IOException: Le périphérique n’est pas prêt
|
||||
at java.base/sun.nio.ch.FileDispatcherImpl.pread0(Native Method)
|
||||
at java.base/sun.nio.ch.FileDispatcherImpl.pread(FileDispatcherImpl.java:67)
|
||||
at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:338)
|
||||
at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:306)
|
||||
at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:283)
|
||||
at java.base/sun.nio.ch.FileChannelImpl.readInternal(FileChannelImpl.java:984)
|
||||
at java.base/sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:964)
|
||||
at org.h2.mvstore.DataUtils.readFully(DataUtils.java:441)
|
||||
... 24 more
|
||||
Loading…
Add table
Reference in a new issue