diff --git a/car/src/main/java/cz/muni/pa165/car/rest/CarController.java b/car/src/main/java/cz/muni/pa165/car/rest/CarController.java index 63050c96c4a96e61932d0cb48a519fbcc7fd605a..443c3f93735242d5463b1e424e3844ee60fa541e 100644 --- a/car/src/main/java/cz/muni/pa165/car/rest/CarController.java +++ b/car/src/main/java/cz/muni/pa165/car/rest/CarController.java @@ -56,7 +56,7 @@ public class CarController { * @return a ResponseEntity containing a message indicating whether the car was deleted or not */ @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) { return ResponseEntity.ok(carService.deleteById(carId)); } @@ -68,7 +68,7 @@ public class CarController { * @return a ResponseEntity containing the DTO of the retrieved 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) { return ResponseEntity.ok(carService.getCarById(carId)); } @@ -79,7 +79,7 @@ public class CarController { * @return a ResponseEntity containing a list of DTOs representing 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() { return ResponseEntity.ok(carService.getAllCars()); } diff --git a/car/src/main/java/cz/muni/pa165/car/service/CarServiceImpl.java b/car/src/main/java/cz/muni/pa165/car/service/CarServiceImpl.java index 70101950120d5622b3afa705378a6e7e5144cbfe..f2e2d1cf2f8c669bb37b276a5343fe6e6649fd9a 100644 --- a/car/src/main/java/cz/muni/pa165/car/service/CarServiceImpl.java +++ b/car/src/main/java/cz/muni/pa165/car/service/CarServiceImpl.java @@ -76,7 +76,7 @@ public class CarServiceImpl implements CarService { */ 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>(); for (Pair<Long, String> componentPair : carRequestDto.getComponentIdsNames()) { @@ -92,6 +92,11 @@ public class CarServiceImpl implements CarService { } car.setDrivers(drivers); + if (carRequestDto.getMainDriverId() != null) { + var mainDriver = getDriverById(carRequestDto.getMainDriverId()); + car.setMainDriver(mainDriver); + } + return car; }