Ajout de la partie "Système de jeu" avec toute la partie stockage de règles de notre jeu.
Ajout de possibilité de stocker des fiches de personnages associés à une campagne également (personnages joueurs pour le moment)
This commit is contained in:
39
web/src/app/services/game-system.service.ts
Normal file
39
web/src/app/services/game-system.service.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { GameSystem, GameSystemCreate } from './game-system.model';
|
||||
|
||||
/**
|
||||
* Service HTTP pour les GameSystems (systèmes de JDR).
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class GameSystemService {
|
||||
private apiUrl = 'http://localhost:8080/api/game-systems';
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
getAll(): Observable<GameSystem[]> {
|
||||
return this.http.get<GameSystem[]>(this.apiUrl);
|
||||
}
|
||||
|
||||
getById(id: string): Observable<GameSystem> {
|
||||
return this.http.get<GameSystem>(`${this.apiUrl}/${id}`);
|
||||
}
|
||||
|
||||
create(payload: GameSystemCreate): Observable<GameSystem> {
|
||||
return this.http.post<GameSystem>(this.apiUrl, payload);
|
||||
}
|
||||
|
||||
update(id: string, payload: GameSystemCreate): Observable<GameSystem> {
|
||||
return this.http.put<GameSystem>(`${this.apiUrl}/${id}`, payload);
|
||||
}
|
||||
|
||||
delete(id: string): Observable<void> {
|
||||
return this.http.delete<void>(`${this.apiUrl}/${id}`);
|
||||
}
|
||||
|
||||
search(q: string): Observable<GameSystem[]> {
|
||||
const params = new HttpParams().set('q', q);
|
||||
return this.http.get<GameSystem[]>(`${this.apiUrl}/search`, { params });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user