Changeset 6fe77af for trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/LocationRestController.java
- Timestamp:
- 02/06/22 18:15:51 (3 years ago)
- Branches:
- master
- Children:
- 571e0df
- Parents:
- 76712b2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/LocationRestController.java
r76712b2 r6fe77af 2 2 3 3 import finki.diplomska.tripplanner.models.Location; 4 import finki.diplomska.tripplanner.models.User; 5 import finki.diplomska.tripplanner.models.dto.LocationDto; 4 6 import finki.diplomska.tripplanner.models.dto.PlannerLocationDto; 5 7 import finki.diplomska.tripplanner.service.LocationService; 6 8 import finki.diplomska.tripplanner.service.PlannerService; 7 9 import org.springframework.http.ResponseEntity; 10 import org.springframework.security.core.Authentication; 8 11 import org.springframework.web.bind.annotation.*; 9 12 … … 82 85 } 83 86 87 @PostMapping("/add") 88 public ResponseEntity<Location> save(@RequestBody LocationDto locationDto, Authentication authentication) { 89 User user = (User) authentication.getPrincipal(); 90 return this.locationService.save(locationDto, user.getUsername()) 91 .map(location -> ResponseEntity.ok().body(location)) 92 .orElseGet(() -> ResponseEntity.badRequest().build()); 93 } 84 94 }
Note:
See TracChangeset
for help on using the changeset viewer.