import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { Enemy, EnemyCreate } from './enemy.model'; /** * Service HTTP des fiches d'ennemis (bestiaire de campagne). */ @Injectable({ providedIn: 'root' }) export class EnemyService { private apiUrl = '/api/enemies'; constructor(private http: HttpClient) {} getByCampaign(campaignId: string): Observable { return this.http.get(`${this.apiUrl}/campaign/${campaignId}`); } getById(id: string): Observable { return this.http.get(`${this.apiUrl}/${id}`); } create(payload: EnemyCreate): Observable { return this.http.post(this.apiUrl, payload); } update(id: string, payload: Enemy): Observable { return this.http.put(`${this.apiUrl}/${id}`, payload); } delete(id: string): Observable { return this.http.delete(`${this.apiUrl}/${id}`); } /** Recherche par nom — alimente la recherche globale (Ctrl+K). */ search(q: string): Observable { return this.http.get(`${this.apiUrl}/search`, { params: { q } }); } }