fixes for 3rd practical

This commit is contained in:
2025-12-25 05:12:04 +02:00
parent d203544a6f
commit a50b754881
8 changed files with 149 additions and 75 deletions
@@ -10,6 +10,7 @@ import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import ua.com.dxrkness.client.FreightClient;
import ua.com.dxrkness.client.VehicleClient;
import ua.com.dxrkness.dto.RouteRequest;
import ua.com.dxrkness.model.Freight;
import ua.com.dxrkness.model.Route;
import ua.com.dxrkness.model.Vehicle;
@@ -153,8 +154,8 @@ public class RouteController {
description = "Route object to be created. Must include valid vehicleId and freightId list.",
required = true
)
@RequestBody Route newRoute) {
return routeService.add(newRoute);
@RequestBody RouteRequest newRoute) {
return routeService.add(newRoute.toEntity());
}
@Operation(
@@ -177,8 +178,8 @@ public class RouteController {
description = "Updated route object",
required = true
)
@RequestBody Route newRoute) {
return routeService.update(id, newRoute);
@RequestBody RouteRequest newRoute) {
return routeService.update(id, newRoute.toEntity());
}
@Operation(
@@ -201,8 +202,8 @@ public class RouteController {
description = "Route object with fields to update",
required = true
)
@RequestBody Route newRoute) {
return routeService.update(id, newRoute);
@RequestBody RouteRequest newRoute) {
return routeService.update(id, newRoute.toEntity());
}
@@ -52,7 +52,7 @@ public final class RouteService {
route.distanceKm(),
route.estimatedDurationHours(),
route.status());
repo.add(route);
repo.add(newRoute);
return newRoute;
}