From 86a3c5006dbaa97c27dd19fa27e8cd9a8cfafefe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20Ku=CC=88ng?= Date: Wed, 26 Apr 2023 18:13:07 +0200 Subject: [PATCH] fix springBoot, adding some mapping --- .idea/uiDesigner.xml | 124 ++++++++++++++++++ .../progetto152/Progetto152Application.java | 7 +- .../ch/progetto152/controller/Controller.java | 47 +++++++ .../progetto152/services/LocationService.java | 15 +++ .../ch/progetto152/services/UserService.java | 1 - .../progetto152/services/WaypointService.java | 11 ++ src/main/resources/application.properties | 2 +- 7 files changed, 200 insertions(+), 7 deletions(-) create mode 100644 .idea/uiDesigner.xml create mode 100644 src/main/java/ch/progetto152/controller/Controller.java create mode 100644 src/main/java/ch/progetto152/services/LocationService.java create mode 100644 src/main/java/ch/progetto152/services/WaypointService.java diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/ch/progetto152/Progetto152Application.java b/src/main/java/ch/progetto152/Progetto152Application.java index d094331..e7467c1 100644 --- a/src/main/java/ch/progetto152/Progetto152Application.java +++ b/src/main/java/ch/progetto152/Progetto152Application.java @@ -1,6 +1,6 @@ package ch.progetto152; -import ch.progetto152.controller.UserController; +import ch.progetto152.controller.Controller; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -12,9 +12,6 @@ public class Progetto152Application { SpringApplication.run(Progetto152Application.class, args); } - @Bean - public UserController newController() { - return new UserController(); - } + } diff --git a/src/main/java/ch/progetto152/controller/Controller.java b/src/main/java/ch/progetto152/controller/Controller.java new file mode 100644 index 0000000..e558288 --- /dev/null +++ b/src/main/java/ch/progetto152/controller/Controller.java @@ -0,0 +1,47 @@ +package ch.progetto152.controller; + + +import ch.progetto152.entity.Location; +import ch.progetto152.entity.User; +import ch.progetto152.entity.Waypoints; +import ch.progetto152.services.LocationService; +import ch.progetto152.services.UserService; +import ch.progetto152.services.WaypointService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping(value = "api/progetto152", produces = MediaType.APPLICATION_JSON_VALUE) +public class Controller { + + private static final String location = "location"; + private static final String waypoint = "waypoint"; + + @Autowired + private UserService userService; + + + @GetMapping(value= location, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity> getLocations() { + List locations = LocationService.getLocations(); + return new ResponseEntity<>(locations, HttpStatus.OK); + } + + @GetMapping(value= waypoint, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity> getWaypoints() { + List waypoints = WaypointService.getWaypoints(); + return new ResponseEntity<>(waypoints, HttpStatus.OK); + } + + @PostMapping(value= location, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity createLocation(@RequestBody Location location) { + LocationService.createLocation(location); + return new ResponseEntity<>(HttpStatus.CREATED); + } + +} diff --git a/src/main/java/ch/progetto152/services/LocationService.java b/src/main/java/ch/progetto152/services/LocationService.java new file mode 100644 index 0000000..a8719d1 --- /dev/null +++ b/src/main/java/ch/progetto152/services/LocationService.java @@ -0,0 +1,15 @@ +package ch.progetto152.services; + +import ch.progetto152.entity.Location; + +import java.util.List; + +public class LocationService { + + public static List getLocations() { + return null; + } + + public static void createLocation(Location location) { + } +} diff --git a/src/main/java/ch/progetto152/services/UserService.java b/src/main/java/ch/progetto152/services/UserService.java index ebf92f0..dff14a2 100644 --- a/src/main/java/ch/progetto152/services/UserService.java +++ b/src/main/java/ch/progetto152/services/UserService.java @@ -9,7 +9,6 @@ import java.util.List; @Service public class UserService { - public List getAllUsers() { return null; } diff --git a/src/main/java/ch/progetto152/services/WaypointService.java b/src/main/java/ch/progetto152/services/WaypointService.java new file mode 100644 index 0000000..4b41fb0 --- /dev/null +++ b/src/main/java/ch/progetto152/services/WaypointService.java @@ -0,0 +1,11 @@ +package ch.progetto152.services; + +import ch.progetto152.entity.Waypoints; + +import java.util.List; + +public class WaypointService { + public static List getWaypoints() { + return null; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index d9adbbc..5543e77 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,4 +1,4 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/Progetto152 spring.datasource.username=root -spring.datasource.password=Admin123 \ No newline at end of file +spring.datasource.password=Eragon05 \ No newline at end of file