added method @GetMapping("/{user}/{id}")
This commit is contained in:
@@ -38,12 +38,14 @@ public class WaypointVisitedController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{user}/{id}")
|
@GetMapping("/{user}/{id}")
|
||||||
public ResponseEntity<Boolean> getWaypointVisitedByWaypointIdAndUserId(@PathVariable("user") Long user, @PathVariable("id") Long id) {
|
public ResponseEntity<Boolean> getWaypointVisitedByWaypointIdAndUserId(@PathVariable("user") Long userId, @PathVariable("id") Long waypointId) {
|
||||||
Boolean waypointVisited = waypointVisitedService.getWaypointsVisitedByWaypointIdAndUserId(id, user);
|
Boolean waypointVisited = waypointVisitedService.getWaypointsVisitedByWaypointIdAndUserId(waypointId, userId);
|
||||||
if (waypointVisited != null) {
|
if (waypointVisited == null) {
|
||||||
return new ResponseEntity<>(waypointVisited, HttpStatus.OK);
|
|
||||||
} else {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
|
} else if (!waypointVisited) {
|
||||||
|
return new ResponseEntity<>(false, HttpStatus.NOT_FOUND);
|
||||||
|
} else {
|
||||||
|
return new ResponseEntity<>(true, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,10 +35,6 @@ public class WaypointVisitedService {
|
|||||||
return waypointVisitedRepository.findWaypointsVisitedEntitiesByWaypointId(id).orElse(null);
|
return waypointVisitedRepository.findWaypointsVisitedEntitiesByWaypointId(id).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WaypointsVisitedEntity getWaypointsVisitedByUserIdAndWaypointId(Long userId, Long waypointId) {
|
|
||||||
return waypointVisitedRepository.findWaypointsVisitedEntitiesByUserIdAndWaypointId(userId, waypointId).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public WaypointsVisitedEntity createWaypoint(WaypointsVisitedEntity waypoint) {
|
public WaypointsVisitedEntity createWaypoint(WaypointsVisitedEntity waypoint) {
|
||||||
if (errorChecking.checkWaypointVisited(waypoint)) {
|
if (errorChecking.checkWaypointVisited(waypoint)) {
|
||||||
return waypointVisitedRepository.save(waypoint);
|
return waypointVisitedRepository.save(waypoint);
|
||||||
@@ -67,4 +63,12 @@ public class WaypointVisitedService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Boolean getWaypointsVisitedByWaypointIdAndUserId(Long waypointId, Long userId) {
|
||||||
|
WaypointsVisitedEntity waypointsVisited = waypointVisitedRepository.findWaypointsVisitedEntitiesByUserIdAndWaypointId(userId, waypointId).orElse(null);
|
||||||
|
if (waypointsVisited != null) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user