import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { ItemCatalog, ItemCatalogCreate } from './item-catalog.model'; /** * CRUD des catalogues d'objets (campagne) + génération IA. Mirroir de RandomTableService. */ @Injectable({ providedIn: 'root' }) export class ItemCatalogService { private apiUrl = '/api/item-catalogs'; 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: ItemCatalogCreate): Observable { return this.http.post(this.apiUrl, payload); } update(id: string, payload: ItemCatalog): Observable { return this.http.put(`${this.apiUrl}/${id}`, payload); } delete(id: string): Observable { return this.http.delete(`${this.apiUrl}/${id}`); } /** Génère une PROPOSITION de catalogue via l'IA (non persistée) à préremplir. */ generate(campaignId: string, description: string): Observable { return this.http.post(`${this.apiUrl}/generate`, { campaignId, description }); } }