service for entity created
This commit is contained in:
43
src/app/service/http/waypoint.service.ts
Normal file
43
src/app/service/http/waypoint.service.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import {Injectable} from "@angular/core";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {WaypointsEntity} from "../../interface/WaypointsEntity";
|
||||
|
||||
const BASE_URL = "localhost:8080/progetto152/";
|
||||
const WAYPOINT = BASE_URL + "waypoint/";
|
||||
const GET_WAYPOINT_BY_ID = WAYPOINT + "id/";
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
|
||||
export class LocationService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
) {
|
||||
}
|
||||
|
||||
getWaypoints(location: string) {
|
||||
return this.http.get<WaypointsEntity[]>(WAYPOINT + location);
|
||||
}
|
||||
|
||||
getWaypoint(location: string, id: number) {
|
||||
return this.http.get<WaypointsEntity>(WAYPOINT + location + "/" + id);
|
||||
}
|
||||
|
||||
getWaypointById(id: number) {
|
||||
return this.http.get<WaypointsEntity>(GET_WAYPOINT_BY_ID + id);
|
||||
}
|
||||
|
||||
createWaypoint(waypoint: WaypointsEntity) {
|
||||
return this.http.post<WaypointsEntity>(WAYPOINT, waypoint);
|
||||
}
|
||||
|
||||
updateWaypoint(waypoint: WaypointsEntity, id: number) {
|
||||
return this.http.put<WaypointsEntity>(WAYPOINT + id, waypoint);
|
||||
}
|
||||
|
||||
deleteWaypoint(id: number) {
|
||||
return this.http.delete<WaypointsEntity>(WAYPOINT + id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user