Class UserController
java.lang.Object
springboot.bg.harisauto.web.controller.UserController
UserController.java - Controller for handling user-related web requests.
- Author:
- Kristian Popov
-
Constructor Summary
ConstructorsConstructorDescriptionUserController(UserService userService, VehicleService vehicleService, BookingService bookingService) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.web.servlet.ModelAndViewchangePassword(AuthenticationMetaData metaData, @Valid ChangeUserPasswordRequest changeUserPasswordRequest, org.springframework.validation.BindingResult result, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Changes the user's password.org.springframework.web.servlet.ModelAndViewcreateVehicle(AuthenticationMetaData metaData, @Valid CreateVehicleRequest request, org.springframework.validation.BindingResult bindingResult) Creates a new vehicle for the authenticated user.deleteVehicle(UUID id, AuthenticationMetaData metaData) Deletes a vehicle by id.org.springframework.web.servlet.ModelAndViewshowBookings(AuthenticationMetaData metaData) Shows the bookings page for the authenticated user.org.springframework.web.servlet.ModelAndViewshowDashboard(AuthenticationMetaData metaData) Shows the dashboard page for the authenticated user.org.springframework.web.servlet.ModelAndViewshowSettings(AuthenticationMetaData metaData) Shows the settings page for the authenticated user.org.springframework.web.servlet.ModelAndViewshowVehiclePage(AuthenticationMetaData metaData) Shows the vehicle page.org.springframework.web.servlet.ModelAndViewupdateProfile(AuthenticationMetaData metaData, @Valid ChangeProfileInfoRequest changeProfileInfoRequest, org.springframework.validation.BindingResult bindingResult) Updates the user's profile.
-
Constructor Details
-
UserController
@Autowired public UserController(UserService userService, VehicleService vehicleService, BookingService bookingService)
-
-
Method Details
-
showDashboard
@GetMapping("/dashboard") public org.springframework.web.servlet.ModelAndView showDashboard(@AuthenticationPrincipal AuthenticationMetaData metaData) Shows the dashboard page for the authenticated user.- Parameters:
metaData- The authentication metadata.- Returns:
- The dashboard page.
-
showVehiclePage
@GetMapping("/vehicles") public org.springframework.web.servlet.ModelAndView showVehiclePage(@AuthenticationPrincipal AuthenticationMetaData metaData) Shows the vehicle page.- Returns:
- The vehicle page.
-
showBookings
@GetMapping("/my-bookings") public org.springframework.web.servlet.ModelAndView showBookings(@AuthenticationPrincipal AuthenticationMetaData metaData) Shows the bookings page for the authenticated user.- Parameters:
metaData- The authentication metadata.- Returns:
- The bookings page.
-
showSettings
@GetMapping("/settings") public org.springframework.web.servlet.ModelAndView showSettings(@AuthenticationPrincipal AuthenticationMetaData metaData) Shows the settings page for the authenticated user.- Parameters:
metaData- The authentication metadata.- Returns:
- The settings page.
-
createVehicle
@PostMapping("/new-vehicle") public org.springframework.web.servlet.ModelAndView createVehicle(@AuthenticationPrincipal AuthenticationMetaData metaData, @Valid @Valid CreateVehicleRequest request, org.springframework.validation.BindingResult bindingResult) Creates a new vehicle for the authenticated user.- Parameters:
metaData- user authentication metadatarequest- vehicle creation requestbindingResult- binding result- Returns:
- redirect to vehicles page
-
deleteVehicle
@DeleteMapping("/vehicle") public String deleteVehicle(@RequestParam("id") UUID id, @AuthenticationPrincipal AuthenticationMetaData metaData) Deletes a vehicle by id.- Parameters:
id- vehicle idmetaData- user authentication metadata- Returns:
- redirect to vehicles page
-
updateProfile
@PutMapping("/profile") public org.springframework.web.servlet.ModelAndView updateProfile(@AuthenticationPrincipal AuthenticationMetaData metaData, @Valid @Valid ChangeProfileInfoRequest changeProfileInfoRequest, org.springframework.validation.BindingResult bindingResult) Updates the user's profile.- Parameters:
metaData- The authentication metadata.changeProfileInfoRequest- The request containing the new profile information.bindingResult- The binding result.- Returns:
- The updated settings page.
-
changePassword
@PutMapping("/password") public org.springframework.web.servlet.ModelAndView changePassword(@AuthenticationPrincipal AuthenticationMetaData metaData, @Valid @Valid ChangeUserPasswordRequest changeUserPasswordRequest, org.springframework.validation.BindingResult result, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Changes the user's password.- Parameters:
metaData- The authentication metadata.changeUserPasswordRequest- The request containing the new password.result- The binding result.redirectAttributes- The redirect attributes.- Returns:
- The updated settings page.
-