package Ġss il val uc as . bot service . web . controller Ċ Ċ import Ġorg . springframework . http . HttpStatus Ċ import Ġorg . springframework . http . Response Entity Ċ import Ġorg . springframework . web . bind . annotation .* Ċ import Ġss il val uc as . bot service . model . entity . Driver Ċ import Ġss il val uc as . bot service . data . repository . Driver Repository Ċ Ċ @ RestController Ċ @ RequestMapping (" api / driver /") Ċ class ĠDriver Controller ( val Ġrepository : ĠDriver Repository ) Ġ{ ĊĊĠĠĠ Ġ@ PostMapping (" register ") ĊĠĠĠ Ġfun Ġcreate (@ RequestBody Ġdriver : ĠDriver ) Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠResponseEntity . ok ( repository . save ( driver )) ĊĊĠĠĠ Ġ@ GetMapping (" list ") ĊĠĠĠ Ġfun Ġfetch All Drivers () Ġ= ĠResponseEntity . status ( HttpStatus . CREATED ). body ( repository . findAll ()) ĊĊĠĠĠ Ġ@ GetMapping ("{ phoneNumber }") ĊĠĠĠ Ġfun Ġfetch Driver (@ PathVariable ĠphoneNumber : ĠString ) Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠResponseEntity . ok ( repository . findFirst By PhoneNumber ( phoneNumber )) ĊĊĠĠĠ Ġ@ Put Mapping (" update /{ phoneNumber }") ĊĠĠĠ Ġfun Ġupdate (@ PathVariable ĠphoneNumber : ĠString , Ġ@ RequestBody Ġdriver : ĠDriver ): ĠResponseEntity < Driver > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdriver DB Ġ= Ġrepository . findFirst By PhoneNumber ( phoneNumber ). orElse Throw Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRuntimeException (" Driver Ġnot Ġfound Ġby Ġcell phone : Ġ$ phoneNumber ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . save ( driver DB . copy ( name Ġ= Ġdriver . name , ĠphoneNumber Ġ= Ġdriver . phoneNumber )) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Delete Mapping (" delete /{ phoneNumber }") ĊĠĠĠ Ġfun Ġdelete (@ PathVariable ĠphoneNumber : ĠString ) Ġ= Ġrepository . findFirst By PhoneNumber ( phoneNumber ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. if Present Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . delete ( it ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ċ }