service for entity created
This commit is contained in:
39
src/app/service/http/location.service.ts
Normal file
39
src/app/service/http/location.service.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import {Injectable} from "@angular/core";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {LocationEntity} from "../../interface/LocationEntity";
|
||||
|
||||
const BASE_URL = "localhost:8080/progetto152/";
|
||||
const LOCATION = BASE_URL + "location/";
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
|
||||
export class LocationService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
) {
|
||||
}
|
||||
|
||||
getLocations() {
|
||||
return this.http.get<LocationEntity[]>(LOCATION);
|
||||
}
|
||||
|
||||
getLocation(location: string) {
|
||||
return this.http.get<LocationEntity>(LOCATION + location);
|
||||
}
|
||||
|
||||
createLocation(location: LocationEntity) {
|
||||
return this.http.post<LocationEntity>(LOCATION, location);
|
||||
}
|
||||
|
||||
updateLocation(location: LocationEntity) {
|
||||
return this.http.put<LocationEntity>(LOCATION, location);
|
||||
}
|
||||
|
||||
deleteLocation(id: number) {
|
||||
return this.http.delete<LocationEntity>(LOCATION + id);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user