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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
43
src/app/service/http/user.service.ts
Normal file
43
src/app/service/http/user.service.ts
Normal file
@@ -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<UserEntity[]>(USER);
|
||||||
|
}
|
||||||
|
|
||||||
|
getUser(username: string) {
|
||||||
|
return this.http.get<UserEntity>(USER + username);
|
||||||
|
}
|
||||||
|
|
||||||
|
getUserById(id: number) {
|
||||||
|
return this.http.get<UserEntity>(GET_USER_BY_ID + id);
|
||||||
|
}
|
||||||
|
|
||||||
|
createUser(user: UserEntity) {
|
||||||
|
return this.http.post<UserEntity>(USER, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateUser(user: UserEntity, id: number) {
|
||||||
|
return this.http.put<UserEntity>(USER + id, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteUser(id: number) {
|
||||||
|
return this.http.delete<UserEntity>(USER + id);
|
||||||
|
}
|
||||||
|
}
|
||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
45
src/app/service/http/waypointVisited.service.ts
Normal file
45
src/app/service/http/waypointVisited.service.ts
Normal file
@@ -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<WaypointsEntity[]>(WAYPOINT_VISITED);
|
||||||
|
}
|
||||||
|
|
||||||
|
getwaypointVisited(id: number) {
|
||||||
|
return this.http.get<WaypointsEntity>(WAYPOINT_VISITED + id);
|
||||||
|
}
|
||||||
|
|
||||||
|
getWaypointByUser(user: string) {
|
||||||
|
return this.http.get<WaypointsEntity[]>(GET_WAYPOINT_BY_USER + user);
|
||||||
|
}
|
||||||
|
|
||||||
|
createWaypoint(waypoint: WaypointsEntity) {
|
||||||
|
return this.http.post<WaypointsEntity>(WAYPOINT_VISITED, waypoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateWaypoint(waypoint: WaypointsEntity, id: number) {
|
||||||
|
return this.http.put<WaypointsEntity>(WAYPOINT_VISITED + id, waypoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteWaypoint(id: number) {
|
||||||
|
return this.http.delete<WaypointsEntity>(WAYPOINT_VISITED + id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<LocationEntity[]>("/progetto152/location");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user