64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
import { HttpClient } from '@angular/common/http';
|
|
import { inject, Injectable } from '@angular/core';
|
|
import { Observable } from 'rxjs';
|
|
import { IUser } from '../model/interface/user.interface';
|
|
import { IKey } from '../model/interface/key.interface';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class ApiService {
|
|
private http: HttpClient = inject(HttpClient);
|
|
|
|
constructor() { }
|
|
|
|
|
|
getAllUsers(): Observable<IUser[]> {
|
|
return this.http.get<IUser[]>('/api/user');
|
|
}
|
|
|
|
saveUser(user: IUser) {
|
|
return this.http.post('/api/user', user);
|
|
}
|
|
|
|
getRoles(): Observable<{id: string, name: string}[]> {
|
|
return this.http.get<{id: string, name: string}[]>('/api/role');
|
|
}
|
|
|
|
getKeys(): Observable<IKey[]> {
|
|
return this.http.get<IKey[]>('api/key')
|
|
}
|
|
|
|
updateKey(key: IKey): Observable<IKey> {
|
|
return this.http.put<IKey>('api/key', key);
|
|
}
|
|
|
|
getCylinders(): Observable<any[]> {
|
|
return this.http.get<any[]>('api/key/cylinder');
|
|
}
|
|
|
|
createKey(key: any) {
|
|
}
|
|
|
|
postKeySystem(keySystem: any) {
|
|
return this.http.post('api/key/system', keySystem);
|
|
}
|
|
|
|
handoverKey(data: any) {
|
|
return this.http.post(`api/key/${data.key.id}/handover`, data);
|
|
}
|
|
|
|
getHandovers(keyID: string): Observable<any[]> {
|
|
return this.http.get<any[]>(`api/key/${keyID}/handover`);
|
|
}
|
|
|
|
createCustomer(data: { name: string, system: any}) {
|
|
return this.http.post('api/customer', data);
|
|
}
|
|
|
|
getCustomers(): Observable<any[]> {
|
|
return this.http.get<any[]>('api/customer')
|
|
}
|
|
|
|
}
|