Initial commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Entry, CreateEntryDto, UpdateEntryDto, ImportResult } from '../models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class EntryService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
getEntries(monthId: string): Observable<Entry[]> {
|
||||
return this.http.get<Entry[]>(`/api/months/${monthId}/entries`);
|
||||
}
|
||||
|
||||
createEntry(monthId: string, dto: CreateEntryDto): Observable<Entry> {
|
||||
return this.http.post<Entry>(`/api/months/${monthId}/entries`, dto);
|
||||
}
|
||||
|
||||
updateEntry(id: string, dto: UpdateEntryDto): Observable<Entry> {
|
||||
return this.http.put<Entry>(`/api/entries/${id}`, dto);
|
||||
}
|
||||
|
||||
deleteEntry(id: string): Observable<void> {
|
||||
return this.http.delete<void>(`/api/entries/${id}`);
|
||||
}
|
||||
|
||||
importCsv(monthId: string, file: File): Observable<ImportResult> {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
return this.http.post<ImportResult>(`/api/months/${monthId}/entries/import`, formData);
|
||||
}
|
||||
|
||||
exportExcel(monthId: string, fileName: string): Observable<Blob> {
|
||||
return this.http.get(`/api/months/${monthId}/entries/export?fileName=${encodeURIComponent(fileName)}`, {
|
||||
responseType: 'blob',
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user