Primo rilascio
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { ApiService } from './api.service';
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
// Interfaccia per i dati della definizione turno
|
||||
export interface ShiftDefinition {
|
||||
id: number;
|
||||
name: string;
|
||||
start_time: string; // Formato HH:MM:SS o HH:MM
|
||||
end_time: string; // Formato HH:MM:SS o HH:MM
|
||||
notes?: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
// Interfaccia per i dati di input
|
||||
export type ShiftDefinitionInput = Partial<Omit<ShiftDefinition, 'id' | 'created_at' | 'updated_at'>>;
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ShiftDefinitionService extends ApiService {
|
||||
|
||||
constructor(authService: AuthService, http: HttpClient) {
|
||||
super(authService, http, 'shift-definitions');
|
||||
}
|
||||
|
||||
// GET /api/shift-definitions
|
||||
getShiftDefinitions(): Observable<ShiftDefinition[]> {
|
||||
return this.get<ShiftDefinition[]>(`${this.controllerName}`);
|
||||
}
|
||||
|
||||
// GET /api/shift-definitions/{id}
|
||||
getShiftDefinition(id: number): Observable<ShiftDefinition> {
|
||||
return this.get<ShiftDefinition>(`${this.controllerName}/${id}`);
|
||||
}
|
||||
|
||||
// POST /api/shift-definitions
|
||||
addShiftDefinition(shift: ShiftDefinitionInput): Observable<ShiftDefinition> {
|
||||
return this.post<ShiftDefinition>(`${this.controllerName}`, shift); // Invia come JSON
|
||||
}
|
||||
|
||||
// PUT /api/shift-definitions/{id}
|
||||
updateShiftDefinition(id: number, shift: ShiftDefinitionInput): Observable<ShiftDefinition> {
|
||||
return this.put<ShiftDefinition>(`${this.controllerName}/${id}`, shift); // Invia come JSON
|
||||
}
|
||||
|
||||
// DELETE /api/shift-definitions/{id}
|
||||
deleteShiftDefinition(id: number): Observable<null> {
|
||||
return this.delete<null>(`${this.controllerName}/${id}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user