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 = '/api/game-systems'; constructor(private http: HttpClient) {} getAll(): Observable { return this.http.get(this.apiUrl); } getById(id: string): Observable { return this.http.get(`${this.apiUrl}/${id}`); } create(payload: GameSystemCreate): Observable { return this.http.post(this.apiUrl, payload); } update(id: string, payload: GameSystemCreate): Observable { return this.http.put(`${this.apiUrl}/${id}`, payload); } delete(id: string): Observable { return this.http.delete(`${this.apiUrl}/${id}`); } search(q: string): Observable { const params = new HttpParams().set('q', q); return this.http.get(`${this.apiUrl}/search`, { params }); } }