From 84106748414c968606812a3b5300e827e5e2dec0 Mon Sep 17 00:00:00 2001 From: Alf Sebastian Houge Date: Tue, 8 Mar 2022 13:49:11 +0100 Subject: [PATCH 01/23] Add vin field vehicle data --- server/db/dbModels.go | 1 + server/db/migrations.go | 4 ++++ server/models/vehicle.go | 1 + server/service/vehicleService.go | 1 + ui/src/router/views/createVehicle.vue | 5 +++++ 5 files changed, 12 insertions(+) diff --git a/server/db/dbModels.go b/server/db/dbModels.go index c0ac9fe..8e2df75 100644 --- a/server/db/dbModels.go +++ b/server/db/dbModels.go @@ -60,6 +60,7 @@ type Vehicle struct { Base Nickname string `json:"nickname"` Registration string `json:"registration"` + VIN string `json:"vin"` Make string `json:"make"` Model string `json:"model"` YearOfManufacture int `json:"yearOfManufacture"` diff --git a/server/db/migrations.go b/server/db/migrations.go index cddd3b3..ecd4039 100644 --- a/server/db/migrations.go +++ b/server/db/migrations.go @@ -18,6 +18,10 @@ var migrations = []localMigration{ Name: "2021_06_24_04_42_SetUserDisabledFalse", Query: "update users set is_disabled=0", }, + { + Name: "2022_03_08_13_16_AddVIN", + Query: "ALTER TABLE vehicles ADD COLUMN vin text", + }, } func RunMigrations() { diff --git a/server/models/vehicle.go b/server/models/vehicle.go index e81af97..4373cc3 100644 --- a/server/models/vehicle.go +++ b/server/models/vehicle.go @@ -17,6 +17,7 @@ type SubItemQuery struct { type CreateVehicleRequest struct { Nickname string `form:"nickname" json:"nickname" binding:"required"` Registration string `form:"registration" json:"registration" binding:"required"` + VIN string `form:"vin" json:"vin"` Make string `form:"make" json:"make" binding:"required"` Model string `form:"model" json:"model" binding:"required"` YearOfManufacture int `form:"yearOfManufacture" json:"yearOfManufacture"` diff --git a/server/service/vehicleService.go b/server/service/vehicleService.go index 5e853af..3cadb78 100644 --- a/server/service/vehicleService.go +++ b/server/service/vehicleService.go @@ -99,6 +99,7 @@ func UpdateVehicle(vehicleID string, model models.UpdateVehicleRequest) error { //return db.DB.Model(&toUpdate).Updates(db.Vehicle{ toUpdate.Nickname = model.Nickname toUpdate.Registration = model.Registration + toUpdate.VIN = model.VIN toUpdate.Model = model.Model toUpdate.Make = model.Make toUpdate.YearOfManufacture = model.YearOfManufacture diff --git a/ui/src/router/views/createVehicle.vue b/ui/src/router/views/createVehicle.vue index 7f25469..a408585 100644 --- a/ui/src/router/views/createVehicle.vue +++ b/ui/src/router/views/createVehicle.vue @@ -47,6 +47,7 @@ export default { fuelUnit: null, fuelType: null, registration: '', + vin: '', nickname: '', engineSize: null, make: '', @@ -58,6 +59,7 @@ export default { fuelUnit: veh.fuelUnit, fuelType: veh.fuelType, registration: veh.registration, + vin: veh.vin, nickname: veh.nickname, engineSize: veh.engineSize, make: veh.make, @@ -138,6 +140,9 @@ export default { + + +