Skip to content
Snippets Groups Projects
Commit 2afeb9a2 authored by Tomáš Marek's avatar Tomáš Marek
Browse files

Method createCar searches for mainDriver

parent d079e52f
No related branches found
No related tags found
2 merge requests!60Docker,!3915 milestone 2 by tomas
...@@ -56,7 +56,7 @@ public class CarController { ...@@ -56,7 +56,7 @@ public class CarController {
* @return a ResponseEntity containing a message indicating whether the car was deleted or not * @return a ResponseEntity containing a message indicating whether the car was deleted or not
*/ */
@Operation(summary = "Delete a car") @Operation(summary = "Delete a car")
@DeleteMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) @DeleteMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteCar(@RequestParam Long carId) { public ResponseEntity<String> deleteCar(@RequestParam Long carId) {
return ResponseEntity.ok(carService.deleteById(carId)); return ResponseEntity.ok(carService.deleteById(carId));
} }
...@@ -68,7 +68,7 @@ public class CarController { ...@@ -68,7 +68,7 @@ public class CarController {
* @return a ResponseEntity containing the DTO of the retrieved car * @return a ResponseEntity containing the DTO of the retrieved car
*/ */
@Operation(summary = "Get a car") @Operation(summary = "Get a car")
@GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) @GetMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<CarResponseDto> getCar(@RequestParam Long carId) { public ResponseEntity<CarResponseDto> getCar(@RequestParam Long carId) {
return ResponseEntity.ok(carService.getCarById(carId)); return ResponseEntity.ok(carService.getCarById(carId));
} }
...@@ -79,7 +79,7 @@ public class CarController { ...@@ -79,7 +79,7 @@ public class CarController {
* @return a ResponseEntity containing a list of DTOs representing all cars * @return a ResponseEntity containing a list of DTOs representing all cars
*/ */
@Operation(summary = "Get all cars") @Operation(summary = "Get all cars")
@GetMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE) @GetMapping(path = "/all", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<CarResponseDto>> getAllSeasons() { public ResponseEntity<List<CarResponseDto>> getAllSeasons() {
return ResponseEntity.ok(carService.getAllCars()); return ResponseEntity.ok(carService.getAllCars());
} }
......
...@@ -76,7 +76,7 @@ public class CarServiceImpl implements CarService { ...@@ -76,7 +76,7 @@ public class CarServiceImpl implements CarService {
*/ */
public static Car carDtoConverter(CarRequestDto carRequestDto) { public static Car carDtoConverter(CarRequestDto carRequestDto) {
var car = Car.builder().id(0L).build(); var car = Car.builder().id(null).build();
var components = new ArrayList<CarComponent>(); var components = new ArrayList<CarComponent>();
for (Pair<Long, String> componentPair : carRequestDto.getComponentIdsNames()) { for (Pair<Long, String> componentPair : carRequestDto.getComponentIdsNames()) {
...@@ -92,6 +92,11 @@ public class CarServiceImpl implements CarService { ...@@ -92,6 +92,11 @@ public class CarServiceImpl implements CarService {
} }
car.setDrivers(drivers); car.setDrivers(drivers);
if (carRequestDto.getMainDriverId() != null) {
var mainDriver = getDriverById(carRequestDto.getMainDriverId());
car.setMainDriver(mainDriver);
}
return car; return car;
} }
......
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