diff --git a/src/app/service/http/location.service.ts b/src/app/service/http/location.service.ts new file mode 100644 index 0000000..398d4f4 --- /dev/null +++ b/src/app/service/http/location.service.ts @@ -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(LOCATION); + } + + getLocation(location: string) { + return this.http.get(LOCATION + location); + } + + createLocation(location: LocationEntity) { + return this.http.post(LOCATION, location); + } + + updateLocation(location: LocationEntity) { + return this.http.put(LOCATION, location); + } + + deleteLocation(id: number) { + return this.http.delete(LOCATION + id); + } + +} diff --git a/src/app/service/http/user.service.ts b/src/app/service/http/user.service.ts new file mode 100644 index 0000000..c750706 --- /dev/null +++ b/src/app/service/http/user.service.ts @@ -0,0 +1,43 @@ +import {Injectable} from "@angular/core"; +import {HttpClient} from "@angular/common/http"; +import {UserEntity} from "../../interface/UserEntity"; + +const BASE_URL = "localhost:8080/progetto152/"; +const USER = BASE_URL + "user/"; +const GET_USER_BY_ID = USER + "id/"; + + +@Injectable({ + providedIn: 'root', +}) + +export class LocationService { + constructor( + private http: HttpClient, + ) { + } + + getUsers() { + return this.http.get(USER); + } + + getUser(username: string) { + return this.http.get(USER + username); + } + + getUserById(id: number) { + return this.http.get(GET_USER_BY_ID + id); + } + + createUser(user: UserEntity) { + return this.http.post(USER, user); + } + + updateUser(user: UserEntity, id: number) { + return this.http.put(USER + id, user); + } + + deleteUser(id: number) { + return this.http.delete(USER + id); + } +} diff --git a/src/app/service/http/waypoint.service.ts b/src/app/service/http/waypoint.service.ts new file mode 100644 index 0000000..8784c5d --- /dev/null +++ b/src/app/service/http/waypoint.service.ts @@ -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(WAYPOINT + location); + } + + getWaypoint(location: string, id: number) { + return this.http.get(WAYPOINT + location + "/" + id); + } + + getWaypointById(id: number) { + return this.http.get(GET_WAYPOINT_BY_ID + id); + } + + createWaypoint(waypoint: WaypointsEntity) { + return this.http.post(WAYPOINT, waypoint); + } + + updateWaypoint(waypoint: WaypointsEntity, id: number) { + return this.http.put(WAYPOINT + id, waypoint); + } + + deleteWaypoint(id: number) { + return this.http.delete(WAYPOINT + id); + } +} diff --git a/src/app/service/http/waypointVisited.service.ts b/src/app/service/http/waypointVisited.service.ts new file mode 100644 index 0000000..3ec45ad --- /dev/null +++ b/src/app/service/http/waypointVisited.service.ts @@ -0,0 +1,45 @@ +import {Injectable} from "@angular/core"; +import {HttpClient} from "@angular/common/http"; +import {catchError, Observable} from "rxjs"; +import {LocationEntity} from "../../interface/LocationEntity"; +import {WaypointsEntity} from "../../interface/WaypointsEntity"; + +const BASE_URL = "localhost:8080/progetto152/"; +const WAYPOINT_VISITED = BASE_URL + "waypoint/visited/"; +const GET_WAYPOINT_BY_USER = WAYPOINT_VISITED + "USER/"; + + +@Injectable({ + providedIn: 'root', +}) + +export class LocationService { + constructor( + private http: HttpClient, + ) { + } + + getWaypoints() { + return this.http.get(WAYPOINT_VISITED); + } + + getwaypointVisited(id: number) { + return this.http.get(WAYPOINT_VISITED + id); + } + + getWaypointByUser(user: string) { + return this.http.get(GET_WAYPOINT_BY_USER + user); + } + + createWaypoint(waypoint: WaypointsEntity) { + return this.http.post(WAYPOINT_VISITED, waypoint); + } + + updateWaypoint(waypoint: WaypointsEntity, id: number) { + return this.http.put(WAYPOINT_VISITED + id, waypoint); + } + + deleteWaypoint(id: number) { + return this.http.delete(WAYPOINT_VISITED + id); + } +} diff --git a/src/app/service/location.service.ts b/src/app/service/location.service.ts deleted file mode 100644 index 5916516..0000000 --- a/src/app/service/location.service.ts +++ /dev/null @@ -1,25 +0,0 @@ -import {Injectable} from "@angular/core"; -import {HttpClient} from "@angular/common/http"; -import {catchError, Observable} from "rxjs"; -import {LocationEntity} from "../interface/LocationEntity"; - -const BASE_URL = "localhost:8080/progetto152/"; -const GET_LOCATIONS = BASE_URL + "location"; - - -@Injectable({ - providedIn: 'root', -}) - -export class LocationService { - constructor( - private http: HttpClient, - ) {} - - getLocations(){ - return this.http.get("/progetto152/location"); - } - - - -}