Files
LoreMind/web/src/app/services/item-catalog.service.ts
IETM_FIXE\ietm6 da2a66d06a
Some checks failed
Build & Push Images / build (brain) (push) Has been cancelled
Build & Push Images / build (core) (push) Has been cancelled
Build & Push Images / build (web) (push) Has been cancelled
Build & Push Images / build-switcher (push) Has been cancelled
Amélioration de l'IA pour la partie atelier PDF
Mise en place d'un outil permettant de faire des tableau d'objets pour des boutiques par exemple
2026-06-08 17:00:22 +02:00

40 lines
1.3 KiB
TypeScript

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<ItemCatalog[]> {
return this.http.get<ItemCatalog[]>(`${this.apiUrl}/campaign/${campaignId}`);
}
getById(id: string): Observable<ItemCatalog> {
return this.http.get<ItemCatalog>(`${this.apiUrl}/${id}`);
}
create(payload: ItemCatalogCreate): Observable<ItemCatalog> {
return this.http.post<ItemCatalog>(this.apiUrl, payload);
}
update(id: string, payload: ItemCatalog): Observable<ItemCatalog> {
return this.http.put<ItemCatalog>(`${this.apiUrl}/${id}`, payload);
}
delete(id: string): Observable<void> {
return this.http.delete<void>(`${this.apiUrl}/${id}`);
}
/** Génère une PROPOSITION de catalogue via l'IA (non persistée) à préremplir. */
generate(campaignId: string, description: string): Observable<ItemCatalog> {
return this.http.post<ItemCatalog>(`${this.apiUrl}/generate`, { campaignId, description });
}
}