From 157518a850f935f76856fbcb001d6ff4be9a6acc Mon Sep 17 00:00:00 2001 From: DEEP MEHTA Date: Tue, 8 Nov 2022 01:16:15 +0000 Subject: [PATCH] Update customer flow --- .../add-schedule/add-schedule.component.html | 41 ++++- .../add-schedule/add-schedule.component.ts | 145 +++++++++++++++++- .../add-service/add-service.component.html | 35 +++++ .../app/add-service/add-service.component.ts | 21 +++ .../app/services/service/service.service.ts | 52 ++++++- sql-files/set_up.sql | 25 ++- .../controllers/CreateTableController.java | 48 ++++++ .../controllers/ServiceEventController.java | 104 ++++++++----- 8 files changed, 421 insertions(+), 50 deletions(-) diff --git a/service-center-app/src/app/add-schedule/add-schedule.component.html b/service-center-app/src/app/add-schedule/add-schedule.component.html index ebbca73..7390ca9 100644 --- a/service-center-app/src/app/add-schedule/add-schedule.component.html +++ b/service-center-app/src/app/add-schedule/add-schedule.component.html @@ -8,15 +8,47 @@

Cart

Service ID Service Name + Service Time (hrs) + Service Price ($) {{service.id}} {{service.service_NAME}} + {{getServiceTime(service)}} + {{getServicePrice(service)}} + + + Total + + {{getTotalTime()}} + {{getTotalPrice()}} +
+Preferred Date
+ + + + Enter a valid date + + +
+
+Preferred Start Time
+ + + +
+


@@ -26,6 +58,8 @@

Repair Services

Service ID Service Name + Service Time (hrs) + Service Price ($) Add to cart @@ -33,8 +67,10 @@

Repair Services

{{service.id}} {{service.service_NAME}} + {{getServiceTime(service)}} + {{getServicePrice(service)}} - + @@ -42,8 +78,7 @@

Repair Services

Maintenance Service

-

Your next scheduled maintenance is: Schedule {{this.nextScheduledService}}

+

Your next scheduled maintenance is: Schedule {{this.nextScheduledService}}



- diff --git a/service-center-app/src/app/add-schedule/add-schedule.component.ts b/service-center-app/src/app/add-schedule/add-schedule.component.ts index 5f9b8b2..4410a77 100644 --- a/service-center-app/src/app/add-schedule/add-schedule.component.ts +++ b/service-center-app/src/app/add-schedule/add-schedule.component.ts @@ -1,11 +1,17 @@ +import { DatePipe } from '@angular/common'; import { Component, OnInit } from '@angular/core'; import { MatSnackBar } from '@angular/material/snack-bar'; import { Router } from '@angular/router'; import { Customer } from '../models/Customer'; import { CustomerCar } from '../models/CustomerCar'; +import { Invoice } from '../models/Invoice'; import { MaintenanceService } from '../models/MaintenanceService'; import { RepairService } from '../models/RepairService'; import { Service } from '../models/Service'; +import { ServiceCenterProvidesService } from '../models/ServiceCenterProvidesService'; +import { ServiceEvent } from '../models/ServiceEvent'; +import { ServicesCar } from '../models/ServicesCar'; +import { ServiceCenterProvidesServiceService } from '../services/service-center-provides-service/service-center-provides-service.service'; import { ServiceService } from '../services/service/service.service'; @Component({ @@ -27,15 +33,23 @@ export class AddScheduleComponent implements OnInit { nextScheduledService: String = ''; nextScheduledServiceId: number = 0; maintenanceServiceAdded: boolean = false; + serviceCars: ServicesCar[] = []; + scps: ServiceCenterProvidesService[] = []; + preferredDate: Date = new Date(); + date: Date = new Date(); + time = [8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19] + preferredTime: number = 0; + remainingTime: number = 11; + mechanicId: number = 0; - constructor(public router: Router, public _apiService: ServiceService, private _snackBar: MatSnackBar) { } + constructor(public router: Router, public _apiService: ServiceService, private _snackBar: MatSnackBar, public scpsApi: ServiceCenterProvidesServiceService) { } ngOnInit(): void { this.loading = true; this.customer = ServiceService.selectedCustomer; this.customerCar = ServiceService.selectedCustomerCar; - this.nextScheduledService = this.customerCar.last_SCHEDULED_MAINTENANCE==1?'B':(this.customerCar.last_SCHEDULED_MAINTENANCE==2?'C':'A'); - this.nextScheduledServiceId = this.customerCar.last_SCHEDULED_MAINTENANCE==1?2:(this.customerCar.last_SCHEDULED_MAINTENANCE==2?3:1); + this.nextScheduledService = this.customerCar.last_SCHEDULED_MAINTENANCE == 1 ? 'B' : (this.customerCar.last_SCHEDULED_MAINTENANCE == 2 ? 'C' : 'A'); + this.nextScheduledServiceId = this.customerCar.last_SCHEDULED_MAINTENANCE == 1 ? 2 : (this.customerCar.last_SCHEDULED_MAINTENANCE == 2 ? 3 : 1); this._apiService.getServices().subscribe( (res: any) => { this.services = res; @@ -47,7 +61,25 @@ export class AddScheduleComponent implements OnInit { (res: any) => { this.repairServices = res; this.onlyRepairServices = this.services.filter(service => this.checkIfServiceIsRepair(service)); - this.loading = false; + this.scpsApi.getServiceCenterProvidesServices(this.customer.service_CENTER_ID).subscribe( + (res: any) => { + this.scps = res; + this._apiService.getServiceCars(this.customerCar.car_ID).subscribe( + (res: any) => { + this.serviceCars = res; + this.loading = false; + }, + (err: any) => { + this.loading = false; + console.log(err); + } + ); + }, + (err: any) => { + this.loading = false; + console.log(err); + } + ); }, error => { this.loading = false; @@ -91,6 +123,8 @@ export class AddScheduleComponent implements OnInit { this._snackBar.open('Service added to cart', 'Close', { duration: 2000, }); + this.remainingTime = this.remainingTime - this.getServiceTime(service); + this.time = this.time.slice(0, this.remainingTime + 1); } removeFromCart(service: Service) { @@ -115,10 +149,107 @@ export class AddScheduleComponent implements OnInit { this._snackBar.open('Maintenance services added to cart', 'Close', { duration: 2000, }); + this.remainingTime = 11 - this.getTotalTime(); + this.time = this.time.slice(0, this.remainingTime + 1); } - checkout() { - ServiceService.selectedServices = this.cartService; - this.router.navigate(['/checkout']); + getServiceTime(service: Service): number { + for (const element of this.serviceCars) { + if (element.id == service.id) { + return element.time_ESTIMATED; + } + } + return 0; + } + + getServicePrice(service: Service) { + for (const element of this.scps) { + if (element.id == service.id) { + return element.price; + } + } + return 0; + } + + getTotalTime() { + let total = 0; + for (const element of this.cartService) { + total += this.getServiceTime(element); + } + return total; } + + getTotalPrice() { + let total = 0; + for (const element of this.cartService) { + total += this.getServicePrice(element); + } + return total; + } + + checkout() { + this.loading = true; + let datePipe = new DatePipe('en-US'); + let dateString = datePipe.transform(this.preferredDate, 'dd-MMM-yyyy')!.toString(); + let currentStartTime = this.preferredTime; + this._apiService.getAvailableMechanic(this.customer.service_CENTER_ID, dateString).subscribe( + (res: any) => { + this.mechanicId = res; + let invoiceId = Math.floor(Math.random() * 90000) + 10000; + let invoice = new Invoice({ + invoice_ID: invoiceId, + invoice_STATUS: 0, + total_COST: this.getTotalPrice() + }); + this._apiService.addInvoice(invoice).subscribe( + (res: any) => { + if (res) { + let serviceEvents: ServiceEvent[] = []; + this.cartService.forEach(element => { + let start_TIME = currentStartTime > 12 ? currentStartTime - 12 : currentStartTime; + let end_TIME = +currentStartTime + this.getServiceTime(element); + end_TIME = end_TIME > 12 ? end_TIME - 12 : end_TIME; + currentStartTime = end_TIME; + let serviceEvent = new ServiceEvent({ + service_ID: Math.floor(Math.random() * 90000) + 10000, + id: element.id, + mechanic_ID: this.mechanicId, + service_CENTER_ID: this.customer.service_CENTER_ID, + vin: this.customerCar.vin, + invoice_ID: invoiceId, + start_TIME: datePipe.transform(this.preferredDate, 'dd-MMM-yyyy')!.toString() + " " + start_TIME + ":00:00", + end_TIME: datePipe.transform(this.preferredDate, 'dd-MMM-yyyy')!.toString() + " " + end_TIME + ":00:00" + }); + serviceEvents.push(serviceEvent); + }); + this._apiService.addServiceEvents(serviceEvents).subscribe( + (res: any) => { + if (res) { + this.loading = false; + this._snackBar.open('Service booked', 'Close', { + duration: 2000, + }); + this.router.navigate(['customerHomePage']); + } + }, + (err: any) => { + this.loading = false; + console.log(err); + } + ); + } + }, + (err: any) => { + this.loading = false; + console.log(err); + } + ); + + }, + (err: any) => { + this.loading = false; + console.log(err); + } + ) + }; } diff --git a/service-center-app/src/app/add-service/add-service.component.html b/service-center-app/src/app/add-service/add-service.component.html index 7a01f5e..2cd33e8 100644 --- a/service-center-app/src/app/add-service/add-service.component.html +++ b/service-center-app/src/app/add-service/add-service.component.html @@ -51,6 +51,41 @@

New Service

+
+ Time Taken for Honda
+ + + + Enter a valid time + + +
+ + +
+ Time Taken for Nissan
+ + + + Enter a valid time + + +
+ + +
+ Time Taken for Toyota
+ + + + Enter a valid time + + +
+
diff --git a/service-center-app/src/app/add-service/add-service.component.ts b/service-center-app/src/app/add-service/add-service.component.ts index 460d8a9..b36f2ef 100644 --- a/service-center-app/src/app/add-service/add-service.component.ts +++ b/service-center-app/src/app/add-service/add-service.component.ts @@ -6,6 +6,7 @@ import { RepairService } from '../models/RepairService'; import { ScheduleBundle } from '../models/ScheduleBundle'; import { Service } from '../models/Service'; import { ServiceCategory } from '../models/ServiceCategory'; +import { ServicesCar } from '../models/ServicesCar'; import { ScheduleBundleService } from '../services/schedule-bundle/schedule-bundle.service'; import { ServiceCategoryService } from '../services/service-category/service-category.service'; import { ServiceService } from '../services/service/service.service'; @@ -37,6 +38,7 @@ export class AddServiceComponent implements OnInit { scheduleBundles: ScheduleBundle[] = []; repairServiceCheck: boolean = false; maintenanceServiceCheck: boolean = false; + timeTaken = [0,0,0] constructor(public router: Router, public _apiService: ServiceService, private _snackBar: MatSnackBar, private categoryServce: ServiceCategoryService, private scheduleBundleService: ScheduleBundleService) { } @@ -100,6 +102,25 @@ export class AddServiceComponent implements OnInit { console.error('Error occurred while adding maintenance service to the database. Error: ' + error); }); } + + for (let i=0; i<3; i++){ + let serviceCar = new ServicesCar({ + id: this.service.id, + car_ID: i+1, + time_ESTIMATED: this.timeTaken[i] + }); + this._apiService.addServiceCar(serviceCar).subscribe((result: boolean) => { + if (result) { + this._snackBar.open('Service added successfully', 'Close', { + duration: 2000, + }); + this.router.navigate(['adminHomePage']); + this.loading = false; + } + this.loading = false; + } + ); + } } else{ this.loading = false; diff --git a/service-center-app/src/app/services/service/service.service.ts b/service-center-app/src/app/services/service/service.service.ts index 2bc3f2f..bed2d48 100644 --- a/service-center-app/src/app/services/service/service.service.ts +++ b/service-center-app/src/app/services/service/service.service.ts @@ -2,9 +2,12 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import { map, Observable } from 'rxjs'; +import { Invoice } from 'src/app/models/Invoice'; import { MaintenanceService } from 'src/app/models/MaintenanceService'; import { RepairService } from 'src/app/models/RepairService'; import { Service } from 'src/app/models/Service'; +import { ServiceEvent } from 'src/app/models/ServiceEvent'; +import { ServicesCar } from 'src/app/models/ServicesCar'; import { environment } from 'src/environments/environment'; @Injectable({ @@ -15,6 +18,9 @@ export class ServiceService { private apiUrl = environment.apiBaseUrl + "/service"; private maintenanceServiceUrl = environment.apiBaseUrl + "/maintenanceService"; private repairServiceUrl = environment.apiBaseUrl + "/repairService"; + private serviceCarUrl = environment.apiBaseUrl + "/servicesCar"; + private serviceEventUrl = environment.apiBaseUrl + "/serviceEvent"; + private invoiceApiUrl = environment.apiBaseUrl + "/invoice"; static selectedCustomer: any; static selectedCustomerCar: any; static selectedServices: any; @@ -100,5 +106,49 @@ export class ServiceService { return json; })); } - + + public getServiceCars(carId: number): Observable { + return this.http.get(`${this.serviceCarUrl}/${carId}`).pipe( + map((json: any) => { + const services: ServicesCar[] = []; + for (const service of json) { + services.push(new ServicesCar(service)); + } + return services; + }) + ); + } + + public addServiceCar(serviceCar: ServicesCar): Observable { + return this.http.post(`${this.serviceCarUrl}`, serviceCar).pipe(map((json: boolean) => { + return json; + })); + } + + public getAvailableMechanic(serviceCenterId: number, date: string): Observable { + return this.http.get(`${this.serviceEventUrl}/getMechanic/${serviceCenterId}?date=${date}`).pipe( + map((json: any) => { + return json; + }) + ); + } + + public addInvoice(invoice: Invoice): Observable { + return this.http.post(`${this.invoiceApiUrl}`, invoice).pipe(map((json: boolean) => { + return json; + })); + } + + public addServiceEvent(serviceEvent: ServiceEvent): Observable { + return this.http.post(`${this.serviceEventUrl}`, serviceEvent).pipe(map((json: boolean) => { + return json; + })); + } + + public addServiceEvents(serviceEvents: ServiceEvent[]): Observable { + return this.http.post(`${this.serviceEventUrl}/all`, serviceEvents).pipe(map((json: boolean) => { + return json; + })); + } + } diff --git a/sql-files/set_up.sql b/sql-files/set_up.sql index 46f1471..723f6fe 100644 --- a/sql-files/set_up.sql +++ b/sql-files/set_up.sql @@ -206,4 +206,27 @@ CREATE TABLE SWAP_SLOT ( REQUESTED_EMPLOYEE_ID, REQUESTED_SERVICE_CENTER_ID ) -); \ No newline at end of file +); +create or replace TRIGGER VERIFY_WAGE_IS_IN_LIMIT +BEFORE UPDATE OF hourly_rate ON HOURLY_PAID_EMPLOYEE +FOR EACH ROW +DECLARE maxWage REAL; minWage REAL; +BEGIN +SELECT SC.MAX_WAGE into maxWage FROM SERVICE_CENTER SC WHERE SC.service_center_id = :new.service_center_id; +SELECT SC.MIN_WAGE into minWage FROM SERVICE_CENTER SC WHERE SC.service_center_id = :new.service_center_id; +IF :new.hourly_rate > maxWage OR :new.hourly_rate < minWage +THEN :new.hourly_rate := :old.hourly_rate; +END IF; +END; + +create or replace TRIGGER UPDATE_SERVICE_CENTER_STATUS +BEFORE INSERT ON EMPLOYEE +FOR EACH ROW +WHEN (new.ROLE = 3) +DECLARE totalMechanics INT; +BEGIN +SELECT Count(*) into totalMechanics FROM EMPLOYEE E WHERE E.service_center_id = :new.service_center_id; +IF totalMechanics >= 3 +THEN UPDATE SERVICE_CENTER SC SET SC.operational_status = 1 WHERE SC.service_center_id = :new.service_center_id; +END IF; +END; \ No newline at end of file diff --git a/src/main/java/com/dbms/team15/controllers/CreateTableController.java b/src/main/java/com/dbms/team15/controllers/CreateTableController.java index cde182b..e5384b4 100644 --- a/src/main/java/com/dbms/team15/controllers/CreateTableController.java +++ b/src/main/java/com/dbms/team15/controllers/CreateTableController.java @@ -427,4 +427,52 @@ public boolean CreateTriggerCheckCustomerStatusAfterDelete() { return true; } + @GetMapping("/create/trigger/ensure_hourly_rate") + public boolean CreateTriggerEnsureHourlyRate() { + + String sql = new StringBuilder() + .append("CREATE TRIGGER ENSURE_HOURLY_RATE ") + .append("BEFORE UPDATE OF hourly_rate ON HOURLY_PAID_EMPLOYEE ") + .append("FOR EACH ROW ") + .append("DECLARE maxWage REAL; minWage REAL; ") + .append("BEGIN ") + .append("SELECT SC.MAX_WAGE into maxWage FROM SERVICE_CENTER SC WHERE SC.service_center_id = :new.service_center_id; ") + .append("SELECT SC.MIN_WAGE into minWage FROM SERVICE_CENTER SC WHERE SC.service_center_id = :new.service_center_id; ") + .append("IF :new.hourly_rate > maxWage OR :new.hourly_rate < minWage ") + .append("THEN :new.hourly_rate := :old.hourly_rate; ") + .append("END IF; ") + .append("END; ") + .toString(); + + jdbcTemplate.execute( + sql + ); + + return true; + } + + @GetMapping("/create/trigger/update_service_center_status") + public boolean CreateTriggerUpdateServiceCenterStatus() { + + String sql = new StringBuilder() + .append("CREATE TRIGGER UPDATE_SERVICE_CENTER_STATUS ") + .append("BEFORE INSERT ON EMPLOYEE ") + .append("FOR EACH ROW ") + .append("WHEN (new.ROLE = 3) ") + .append("DECLARE totalMechanics INT; ") + .append("BEGIN ") + .append("SELECT Count(*) into totalMechanics FROM EMPLOYEE E WHERE E.service_center_id = :new.service_center_id; ") + .append("IF totalMechanics >= 3 ") + .append("THEN UPDATE SERVICE_CENTER SC SET SC.operational_status = 1 WHERE SC.service_center_id = :new.service_center_id; ") + .append("END IF; ") + .append("END; ") + .toString(); + + jdbcTemplate.execute( + sql + ); + + return true; + } + } diff --git a/src/main/java/com/dbms/team15/controllers/ServiceEventController.java b/src/main/java/com/dbms/team15/controllers/ServiceEventController.java index d7f5160..e130b3b 100644 --- a/src/main/java/com/dbms/team15/controllers/ServiceEventController.java +++ b/src/main/java/com/dbms/team15/controllers/ServiceEventController.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @CrossOrigin(maxAge = 3600) @@ -27,22 +28,22 @@ public List getServiceEvent() { String sql = "SELECT * FROM SERVICE_EVENT"; List serviceEvents = jdbcTemplate.query( - sql, - BeanPropertyRowMapper.newInstance(ServiceEvent.class) - ); + sql, + BeanPropertyRowMapper.newInstance(ServiceEvent.class)); serviceEvents.forEach(System.out::println); return serviceEvents; } @GetMapping("/api/scheduledServices/{service_center_id}/{customer_id}") - public List getScheduledServices(@PathVariable("customer_id") int customer_id, @PathVariable("service_center_id") int service_center_id) { - String sql = "SELECT UNIQUE S.SERVICE_NAME, CC.VIN, SE.start_time, SE.end_time FROM CUSTOMER C, SERVICE_EVENT SE, CUSTOMER_CAR CC, SERVICE S WHERE SE.vin = CC.vin AND SE.ID = S.ID AND CC.customer_id = C.customer_id AND CC.service_center_id = C.service_center_id AND C.customer_id = " + customer_id + " AND C.service_center_id = " + service_center_id + " ORDER BY START_TIME"; + public List getScheduledServices(@PathVariable("customer_id") int customer_id, + @PathVariable("service_center_id") int service_center_id) { + String sql = "SELECT UNIQUE S.SERVICE_NAME, CC.VIN, SE.start_time, SE.end_time FROM CUSTOMER C, SERVICE_EVENT SE, CUSTOMER_CAR CC, SERVICE S WHERE SE.vin = CC.vin AND SE.ID = S.ID AND CC.customer_id = C.customer_id AND CC.service_center_id = C.service_center_id AND C.customer_id = " + + customer_id + " AND C.service_center_id = " + service_center_id + " ORDER BY START_TIME"; List scheduledServices = jdbcTemplate.query( - sql, - BeanPropertyRowMapper.newInstance(CustomerScheduledService.class) - ); + sql, + BeanPropertyRowMapper.newInstance(CustomerScheduledService.class)); scheduledServices.forEach(System.out::println); return scheduledServices; @@ -50,20 +51,38 @@ public List getScheduledServices(@PathVariable("custom @PostMapping("/api/serviceEvent") public boolean addServiceEvent(@RequestBody ServiceEvent serviceEvent) { - String sql = - "INSERT INTO SERVICE_EVENT (SERVICE_ID, ID, MECHANIC_ID, SERVICE_CENTER_ID, VIN, INVOICE_ID, START_TIME, END_TIME) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; + String sql = "INSERT INTO SERVICE_EVENT (SERVICE_ID, ID, MECHANIC_ID, SERVICE_CENTER_ID, VIN, INVOICE_ID, START_TIME, END_TIME) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; jdbcTemplate.update( - sql, - serviceEvent.getSERVICE_ID(), - serviceEvent.getID(), - serviceEvent.getMECHANIC_ID(), - serviceEvent.getSERVICE_CENTER_ID(), - serviceEvent.getVIN(), - serviceEvent.getINVOICE_ID(), - serviceEvent.getSTART_TIME(), - serviceEvent.getEND_TIME() - ); + sql, + serviceEvent.getSERVICE_ID(), + serviceEvent.getID(), + serviceEvent.getMECHANIC_ID(), + serviceEvent.getSERVICE_CENTER_ID(), + serviceEvent.getVIN(), + serviceEvent.getINVOICE_ID(), + serviceEvent.getSTART_TIME(), + serviceEvent.getEND_TIME()); + + return true; + } + + @PostMapping("/api/serviceEvent/all") + public boolean addServiceEvents(@RequestBody List serviceEvents) { + String sql = "INSERT INTO SERVICE_EVENT (SERVICE_ID, ID, MECHANIC_ID, SERVICE_CENTER_ID, VIN, INVOICE_ID, START_TIME, END_TIME) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; + + for (ServiceEvent serviceEvent : serviceEvents) { + jdbcTemplate.update( + sql, + serviceEvent.getSERVICE_ID(), + serviceEvent.getID(), + serviceEvent.getMECHANIC_ID(), + serviceEvent.getSERVICE_CENTER_ID(), + serviceEvent.getVIN(), + serviceEvent.getINVOICE_ID(), + serviceEvent.getSTART_TIME(), + serviceEvent.getEND_TIME()); + } return true; } @@ -73,32 +92,41 @@ public ServiceEvent getServiceEventByName(@PathVariable int service_id) { String sql = "SELECT * FROM SERVICE_EVENT WHERE SERVICE_ID = " + service_id; List serviceEvents = jdbcTemplate.query( - sql, - BeanPropertyRowMapper.newInstance(ServiceEvent.class) - ); + sql, + BeanPropertyRowMapper.newInstance(ServiceEvent.class)); return serviceEvents.get(0); } + @GetMapping("/api/serviceEvent/getMechanic/{service_center_id}") + public Integer getAvailableMechanic(@PathVariable int service_center_id, + @RequestParam(value = "date", defaultValue = "") String date) { + String sql = "SELECT SE.MECHANIC_ID FROM SERVICE_EVENT SE WHERE SE.service_center_id = " + service_center_id + + " AND '" + date + "' NOT BETWEEN SE.START_TIME AND SE.END_TIME"; + + List mechanics = jdbcTemplate.queryForList( + sql, + Integer.class); + + return mechanics.get(0); + } + @PutMapping("/api/serviceEvent/{service_id}") public boolean updateServiceEvent( - @PathVariable int service_id, - @RequestBody ServiceEvent serviceEvent - ) { - String sql = - "UPDATE SERVICE_EVENT SET MECHANIC_ID = ?, VIN = ?, INVOICE_ID = ?, START_TIME = ?, END_TIME = ?, SERVICE_CENTER_ID = ?, ID = ? WHERE SERVICE_ID = ?"; + @PathVariable int service_id, + @RequestBody ServiceEvent serviceEvent) { + String sql = "UPDATE SERVICE_EVENT SET MECHANIC_ID = ?, VIN = ?, INVOICE_ID = ?, START_TIME = ?, END_TIME = ?, SERVICE_CENTER_ID = ?, ID = ? WHERE SERVICE_ID = ?"; jdbcTemplate.update( - sql, - serviceEvent.getMECHANIC_ID(), - serviceEvent.getVIN(), - serviceEvent.getINVOICE_ID(), - serviceEvent.getSTART_TIME(), - serviceEvent.getEND_TIME(), - serviceEvent.getSERVICE_CENTER_ID(), - serviceEvent.getID(), - service_id - ); + sql, + serviceEvent.getMECHANIC_ID(), + serviceEvent.getVIN(), + serviceEvent.getINVOICE_ID(), + serviceEvent.getSTART_TIME(), + serviceEvent.getEND_TIME(), + serviceEvent.getSERVICE_CENTER_ID(), + serviceEvent.getID(), + service_id); return true; }