Package com.unosquare.carmigo.controller
Class DriverController
java.lang.Object
com.unosquare.carmigo.controller.DriverController
Handles Driver APIs.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<DriverResponse>
createDriver
(@Valid DriverRequest driverRequest) Enables logged-in users to create a driver's profile.org.springframework.http.ResponseEntity<DriverResponse>
createDriverById
(int driverId, @Valid DriverRequest driverRequest) Enables logged-in admin users to create a driver's profile for another user.org.springframework.http.ResponseEntity<?>
Enables logged-in user's to delete their driver's profile.org.springframework.http.ResponseEntity<?>
deleteDriverById
(int driverId) Enables logged-in admin users to delete a driver's profile.org.springframework.http.ResponseEntity<DriverResponse>
Enables logged-in users to see their driver's profiles.org.springframework.http.ResponseEntity<DriverResponse>
getDriverById
(int driverId) Enables logged-in admin users to see other driver's profiles.
-
Constructor Details
-
DriverController
public DriverController()
-
-
Method Details
-
createDriver
@PostMapping(value="/create", produces="application/json") @PreAuthorize("hasAuthority(\'ACTIVE\') or hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<DriverResponse> createDriver(@Valid @RequestBody @Valid DriverRequest driverRequest) Enables logged-in users to create a driver's profile.- Parameters:
driverRequest
- Request body asDriverRequest
.- Returns:
- Response body as
DriverResponse
.
-
createDriverById
@PostMapping(value="/{driverId}", produces="application/json") @PreAuthorize("hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<DriverResponse> createDriverById(@PathVariable int driverId, @Valid @RequestBody @Valid DriverRequest driverRequest) Enables logged-in admin users to create a driver's profile for another user.- Parameters:
driverId
- the user to become a driver.driverRequest
- Request body asDriverRequest
.- Returns:
- Response body as
DriverResponse
.
-
getCurrentDriverProfile
@GetMapping(value="/profile", produces="application/json") @PreAuthorize("hasAuthority(\'ACTIVE\') or hasAuthority(\'SUSPENDED\') or hasAuthority(\'ADMIN\') or hasAuthority(\'DEV\')") public org.springframework.http.ResponseEntity<DriverResponse> getCurrentDriverProfile()Enables logged-in users to see their driver's profiles.- Returns:
- Response body as
DriverResponse
.
-
getDriverById
@GetMapping(value="/{driverId}", produces="application/json") @PreAuthorize("hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<DriverResponse> getDriverById(@PathVariable int driverId) Enables logged-in admin users to see other driver's profiles.- Parameters:
driverId
- the driver's id.- Returns:
- Response body as
DriverResponse
.
-
deleteCurrentDriver
@DeleteMapping @PreAuthorize("hasAuthority(\'ACTIVE\') or hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<?> deleteCurrentDriver()Enables logged-in user's to delete their driver's profile.- Returns:
- an empty body.
-
deleteDriverById
@DeleteMapping("/{driverId}") @PreAuthorize("hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<?> deleteDriverById(@PathVariable int driverId) Enables logged-in admin users to delete a driver's profile.- Parameters:
driverId
- the driver's id to be deleted.- Returns:
- an empty body.
-