29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import { HttpClient } from '@angular/common/http';
|
|
import { Injectable } from '@angular/core';
|
|
import { Observable } from 'rxjs';
|
|
import { Allowance } from '../models/allowance';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class AllowanceService {
|
|
private url = 'http://localhost:8080/api';
|
|
|
|
constructor(private http: HttpClient) {}
|
|
|
|
getAllowanceList(userId: number): Observable<Array<Allowance>> {
|
|
return this.http.get<Allowance[]>(`${this.url}/user/${userId}/allowance`);
|
|
}
|
|
|
|
getAllowanceById(allowanceId: number, userId: number): Observable<Allowance> {
|
|
return this.http.get<Allowance>(`${this.url}/user/${userId}/allowance/${allowanceId}`);
|
|
}
|
|
|
|
createAllowance(allowance: Partial<Allowance>, userId: number) {
|
|
this.http.post(`${this.url}/user/${userId}/allowance`, allowance).subscribe();
|
|
}
|
|
|
|
updateAllowance(allowance: Partial<Allowance>, allowanceId: number, userId: number) {
|
|
this.http.put(`${this.url}/user/${userId}/allowance/${allowanceId}`, allowance).subscribe();
|
|
}
|
|
} |