Skip to content
Snippets Groups Projects
Commit ad2014e6 authored by Martin Slovík's avatar Martin Slovík
Browse files

Adding GET and DELETE operations to FlightController

parent 0fb2192a
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,4 @@ public interface FlightFacade<K> { ...@@ -19,6 +19,4 @@ public interface FlightFacade<K> {
List<FlightDto> findAll(); List<FlightDto> findAll();
void deleteById(K id); void deleteById(K id);
void deleteAll();
} }
...@@ -54,16 +54,21 @@ public class FlightFacadeImpl implements FlightFacade<Long> { ...@@ -54,16 +54,21 @@ public class FlightFacadeImpl implements FlightFacade<Long> {
@Override @Override
public List<FlightDto> findAll() { public List<FlightDto> findAll() {
return null; var foundFlights = flightService.findAll();
} var flightDtos = foundFlights
.stream()
.map(flightMapper::toDto)
.toList();
@Override for (var i = 0; i < foundFlights.size(); i++) {
public void deleteById(Long id) { flightDtos.get(i).setStewards(mapStewardDtos(foundFlights.get(i)));
}
return flightDtos;
} }
@Override @Override
public void deleteAll() { public void deleteById(Long id) {
flightService.deleteById(id);
} }
} }
...@@ -45,7 +45,8 @@ public class FlightController implements FlightApiDelegate { ...@@ -45,7 +45,8 @@ public class FlightController implements FlightApiDelegate {
*/ */
@Override @Override
public ResponseEntity<Void> deleteFlight(Long id) { public ResponseEntity<Void> deleteFlight(Long id) {
return FlightApiDelegate.super.deleteFlight(id); flightFacade.deleteById(id);
return null;
} }
/** /**
...@@ -57,7 +58,7 @@ public class FlightController implements FlightApiDelegate { ...@@ -57,7 +58,7 @@ public class FlightController implements FlightApiDelegate {
*/ */
@Override @Override
public ResponseEntity<List<FlightDto>> getAllFlights() { public ResponseEntity<List<FlightDto>> getAllFlights() {
return FlightApiDelegate.super.getAllFlights(); return ResponseEntity.ok(flightFacade.findAll());
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment