fix springBoot, adding some mapping
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
47
src/main/java/ch/progetto152/controller/Controller.java
Normal file
47
src/main/java/ch/progetto152/controller/Controller.java
Normal file
@@ -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<List<Location>> getLocations() {
|
||||
List<Location> locations = LocationService.getLocations();
|
||||
return new ResponseEntity<>(locations, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value= waypoint, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Waypoints>> getWaypoints() {
|
||||
List<Waypoints> waypoints = WaypointService.getWaypoints();
|
||||
return new ResponseEntity<>(waypoints, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping(value= location, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<String> createLocation(@RequestBody Location location) {
|
||||
LocationService.createLocation(location);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
}
|
||||
15
src/main/java/ch/progetto152/services/LocationService.java
Normal file
15
src/main/java/ch/progetto152/services/LocationService.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package ch.progetto152.services;
|
||||
|
||||
import ch.progetto152.entity.Location;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LocationService {
|
||||
|
||||
public static List<Location> getLocations() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void createLocation(Location location) {
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import java.util.List;
|
||||
@Service
|
||||
public class UserService {
|
||||
|
||||
|
||||
public List<User> getAllUsers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
11
src/main/java/ch/progetto152/services/WaypointService.java
Normal file
11
src/main/java/ch/progetto152/services/WaypointService.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package ch.progetto152.services;
|
||||
|
||||
import ch.progetto152.entity.Waypoints;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WaypointService {
|
||||
public static List<Waypoints> getWaypoints() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
spring.datasource.password=Eragon05
|
||||
Reference in New Issue
Block a user