fix service

This commit is contained in:
2023-04-29 20:26:49 +02:00
parent e42ecade5d
commit ff3fb43cb0
4 changed files with 20 additions and 18 deletions

View File

@@ -2,8 +2,8 @@ import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http"; import {HttpClient} from "@angular/common/http";
import {LocationEntity} from "../../interface/LocationEntity"; import {LocationEntity} from "../../interface/LocationEntity";
const BASE_URL = "localhost:8080/progetto152/"; const BASE_URL = "progetto152";
const LOCATION = BASE_URL + "location/"; const LOCATION = BASE_URL + "/location";
@Injectable({ @Injectable({
@@ -21,7 +21,7 @@ export class LocationService {
} }
getLocation(location: string) { getLocation(location: string) {
return this.http.get<LocationEntity>(LOCATION + location); return this.http.get<LocationEntity>(LOCATION + "/" + location);
} }
createLocation(location: LocationEntity) { createLocation(location: LocationEntity) {

View File

@@ -2,16 +2,16 @@ import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http"; import {HttpClient} from "@angular/common/http";
import {UserEntity} from "../../interface/UserEntity"; import {UserEntity} from "../../interface/UserEntity";
const BASE_URL = "localhost:8080/progetto152/"; const BASE_URL = "progetto152";
const USER = BASE_URL + "user/"; const USER = BASE_URL + "/user";
const GET_USER_BY_ID = USER + "id/"; const GET_USER_BY_ID = USER + "/id";
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class LocationService { export class UserService {
constructor( constructor(
private http: HttpClient, private http: HttpClient,
) { ) {
@@ -22,11 +22,11 @@ export class LocationService {
} }
getUser(username: string) { getUser(username: string) {
return this.http.get<UserEntity>(USER + username); return this.http.get<UserEntity>(USER + "/" + username);
} }
getUserById(id: number) { getUserById(id: number) {
return this.http.get<UserEntity>(GET_USER_BY_ID + id); return this.http.get<UserEntity>(GET_USER_BY_ID + "/" + id);
} }
createUser(user: UserEntity) { createUser(user: UserEntity) {

View File

@@ -1,9 +1,10 @@
import {Injectable} from "@angular/core"; import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http"; import {HttpClient} from "@angular/common/http";
import {WaypointsEntity} from "../../interface/WaypointsEntity"; import {WaypointsEntity} from "../../interface/WaypointsEntity";
import {catchError, throwError} from "rxjs";
const BASE_URL = "localhost:8080/progetto152/"; const BASE_URL = "progetto152";
const WAYPOINT = BASE_URL + "waypoint/"; const WAYPOINT = BASE_URL + "/waypoint";
const GET_WAYPOINT_BY_ID = WAYPOINT + "id/"; const GET_WAYPOINT_BY_ID = WAYPOINT + "id/";
@@ -11,18 +12,19 @@ const GET_WAYPOINT_BY_ID = WAYPOINT + "id/";
providedIn: 'root', providedIn: 'root',
}) })
export class LocationService { export class WaypointService {
constructor( constructor(
private http: HttpClient, private http: HttpClient,
) { ) {
} }
getWaypoints(location: string) { getWaypoints(location: string) {
return this.http.get<WaypointsEntity[]>(WAYPOINT + location); return this.http.get<WaypointsEntity[]>(WAYPOINT + "/" + location)
} }
getWaypoint(location: string, id: number) { getWaypoint(location: string, id: number) {
return this.http.get<WaypointsEntity>(WAYPOINT + location + "/" + id); return this.http.get<WaypointsEntity>(WAYPOINT + "/" + location + "/" + id);
} }
getWaypointById(id: number) { getWaypointById(id: number) {
@@ -34,7 +36,7 @@ export class LocationService {
} }
updateWaypoint(waypoint: WaypointsEntity, id: number) { updateWaypoint(waypoint: WaypointsEntity, id: number) {
return this.http.put<WaypointsEntity>(WAYPOINT + id, waypoint); return this.http.put<WaypointsEntity>(WAYPOINT + "/" + id, waypoint);
} }
deleteWaypoint(id: number) { deleteWaypoint(id: number) {

View File

@@ -4,8 +4,8 @@ import {catchError, Observable} from "rxjs";
import {LocationEntity} from "../../interface/LocationEntity"; import {LocationEntity} from "../../interface/LocationEntity";
import {WaypointsEntity} from "../../interface/WaypointsEntity"; import {WaypointsEntity} from "../../interface/WaypointsEntity";
const BASE_URL = "localhost:8080/progetto152/"; const BASE_URL = "progetto152";
const WAYPOINT_VISITED = BASE_URL + "waypoint/visited/"; const WAYPOINT_VISITED = BASE_URL + "/waypoint/visited/";
const GET_WAYPOINT_BY_USER = WAYPOINT_VISITED + "USER/"; const GET_WAYPOINT_BY_USER = WAYPOINT_VISITED + "USER/";
@@ -13,7 +13,7 @@ const GET_WAYPOINT_BY_USER = WAYPOINT_VISITED + "USER/";
providedIn: 'root', providedIn: 'root',
}) })
export class LocationService { export class WaypointVisitedService {
constructor( constructor(
private http: HttpClient, private http: HttpClient,
) { ) {