Quellcode durchsuchen

Vehicle update updated

main
Madiwka3 vor 1 Jahr
Ursprung
Commit
9370ae4103
2 geänderte Dateien mit 19 neuen und 14 gelöschten Zeilen
  1. +11
    -11
      app/db/repository/vehicle.py
  2. +8
    -3
      app/schemas/vehicle.py

+ 11
- 11
app/db/repository/vehicle.py Datei anzeigen

@@ -87,23 +87,23 @@ def replace_vehicle_data(id: int, vehicle: UpdateVehicle, db: Session):
vehicle_object = vehicle_db.first()
if not vehicle_object:
return "vehiclenotfound"
#vehicle_object.CurrentLocation = vehicle.CurrentLocation
#vehicle_object.Fuel = vehicle.Fuel
#vehicle_object.LicensePlate = vehicle.LicensePlate
#vehicle_object.DriverHistory = vehicle.DriverHistory
#vehicle_object.Type = vehicle.Type
# vehicle_object.CurrentLocation = vehicle.CurrentLocation
vehicle_object.Fuel = vehicle.Fuel
vehicle_object.LicensePlate = vehicle.LicensePlate
# vehicle_object.DriverHistory = vehicle.DriverHistory
vehicle_object.Type = vehicle.Type
vehicle_object.Mileage = vehicle.Mileage
#vehicle_object.Model = vehicle.Model
vehicle_object.Model = vehicle.Model
vehicle_object.Status = vehicle.Status
#res = assign_vehicle_driver(id, vehicle.AssignedDriver, db)
#if res == "nodriver":
# res = assign_vehicle_driver(id, vehicle.AssignedDriver, db)
# if res == "nodriver":
# return "driverNotFound"
#vehicle_object.Capacity = vehicle.Capacity
#vehicle_object.Year = vehicle.Year
vehicle_object.Capacity = vehicle.Capacity
vehicle_object.Year = vehicle.Year
print(vehicle_object)
db.add(vehicle_object)
db.commit()
#vehicle_object.AssignedDriver = vehicle.AssignedDriver
# vehicle_object.AssignedDriver = vehicle.AssignedDriver
return vehicle_object




+ 8
- 3
app/schemas/vehicle.py Datei anzeigen

@@ -28,9 +28,14 @@ class OutputVehicle(BaseModel):


class UpdateVehicle(BaseModel):
Mileage: int
Status: str
Mileage: Optional[int]
Status: Optional[str]
Capacity: Optional[int]
Model: Optional[str]
Year: Optional[int]
LicensePlate: Optional[str]
Fuel: Optional[int] = 0
Type: Optional[str]


class VehicleLocation(BaseModel):


Laden…
Abbrechen
Speichern