Set better path for rest
This commit is contained in:
@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/locations")
|
||||
@RequestMapping("/progetto152/locations")
|
||||
public class LocationController {
|
||||
private final LocationService locationService;
|
||||
|
||||
@@ -19,13 +19,13 @@ public class LocationController {
|
||||
this.locationService = locationService;
|
||||
}
|
||||
|
||||
@GetMapping("/get/all")
|
||||
@GetMapping("")
|
||||
public ResponseEntity<List<LocationEntity>> getAllLocations() {
|
||||
List<LocationEntity> Locations = locationService.getAllLocations();
|
||||
return new ResponseEntity<>(Locations, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/get/{id}")
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<LocationEntity> getLocationById(@PathVariable("id") Long id) {
|
||||
LocationEntity location = locationService.getLocationById(id);
|
||||
if (location != null) {
|
||||
@@ -35,8 +35,8 @@ public class LocationController {
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/get/name/{name}")
|
||||
public ResponseEntity<LocationEntity> getLocationByName(@PathVariable("name") String name) {
|
||||
@GetMapping("?name={name}")
|
||||
public ResponseEntity<LocationEntity> getLocationByName(@PathVariable("location") String name) {
|
||||
LocationEntity location = locationService.getLocationByName(name);
|
||||
if (location != null) {
|
||||
return new ResponseEntity<>(location, HttpStatus.OK);
|
||||
@@ -45,13 +45,13 @@ public class LocationController {
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/create/{id}")
|
||||
@PostMapping("")
|
||||
public ResponseEntity<LocationEntity> createLocation(@RequestBody LocationEntity location) {
|
||||
LocationEntity createdLocation = locationService.createLocation(location);
|
||||
return new ResponseEntity<>(createdLocation, HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping("/put/{id}")
|
||||
@PutMapping("{id}")
|
||||
public ResponseEntity<LocationEntity> updateLocation(@PathVariable("id") Long id, @RequestBody LocationEntity location) {
|
||||
LocationEntity location1 = locationService.updateLocation(id, location);
|
||||
if (location1 != null) {
|
||||
@@ -61,7 +61,7 @@ public class LocationController {
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@DeleteMapping("{id}")
|
||||
public ResponseEntity<Void> deleteLocation(@PathVariable("id") Long id) {
|
||||
boolean deleted = locationService.deleteLocation(id);
|
||||
if (deleted) {
|
||||
|
||||
Reference in New Issue
Block a user