瀏覽代碼

DriverUpdate

main
Madiwka 1 年之前
父節點
當前提交
150031c9a8
共有 2 個檔案被更改,包括 16 行新增14 行删除
  1. +12
    -12
      app/db/repository/vehicle.py
  2. +4
    -2
      app/schemas/vehicle.py

+ 12
- 12
app/db/repository/vehicle.py 查看文件

@@ -76,23 +76,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":
return "driverNotFound"
vehicle_object.Capacity = vehicle.Capacity
vehicle_object.Year = vehicle.Year
#res = assign_vehicle_driver(id, vehicle.AssignedDriver, db)
#if res == "nodriver":
# return "driverNotFound"
#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




+ 4
- 2
app/schemas/vehicle.py 查看文件

@@ -26,8 +26,10 @@ class OutputVehicle(BaseModel):
Status: str


class UpdateVehicle(OutputVehicle):
pass
class UpdateVehicle(BaseModel):
Mileage: int
Status: str


class VehicleLocation(BaseModel):


Loading…
取消
儲存