Last active
December 1, 2019 01:17
-
-
Save Jet-C/462820dcd33b744481aba7c754a1cfdc to your computer and use it in GitHub Desktop.
Vehicle controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping("/demo") | |
public class VehicleController { | |
@Autowired | |
VehicleService vehicleService; | |
@ApiOperation(value = "Retrieves a list of all vehicle records") | |
@GetMapping(value = "/vehicles", produces = MediaType.APPLICATION_JSON_VALUE) | |
public ResponseEntity<List<Vehicle>> getAllVehicles() { | |
List<Vehicle> vehicles = vehicleService.getAllVehicles(); | |
if (vehicles.isEmpty()) { | |
throw new VehicleNotFoundException("No vehicle records were found"); | |
} | |
return new ResponseEntity<List<Vehicle>>(vehicles, HttpStatus.OK); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment