Class AdminController
java.lang.Object
springboot.bg.harisauto.web.controller.AdminController
@Controller
@RequestMapping("/admin")
@PreAuthorize("hasRole(\'ADMIN\')")
public class AdminController
extends Object
AdminController.java - Controller for handling admin-related web requests.
- Author:
- Kristian Popov
-
Constructor Summary
ConstructorsConstructorDescriptionAdminController(UserService userService, CatalogService catalogService, BookingService bookingService) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionarchiveBooking(UUID id, org.springframework.web.servlet.mvc.support.RedirectAttributes attributes) Archives a booking.cancelBooking(UUID id, org.springframework.web.servlet.mvc.support.RedirectAttributes attributes) Cancels a booking.org.springframework.web.servlet.ModelAndViewchangeAdminEmail(AuthenticationMetaData metaData, @Valid AdminChangeEmailRequest request, org.springframework.validation.BindingResult result) Changes the admin's email.org.springframework.web.servlet.ModelAndViewchangeAdminPassword(AuthenticationMetaData metaData, @Valid AdminChangePasswordRequest request, org.springframework.validation.BindingResult result) Changes the admin's password.org.springframework.web.servlet.ModelAndViewcreateNewUser(AuthenticationMetaData metaData, @Valid RegisterNewUserRequest request, org.springframework.validation.BindingResult result) Creates a new user account.org.springframework.web.servlet.ModelAndViewcreateService(AuthenticationMetaData metaData, @Valid CreateServiceRequest request, org.springframework.validation.BindingResult result) Creates a new service.org.springframework.web.servlet.ModelAndViewdeleteService(UUID serviceId) Deletes a service by id.org.springframework.web.servlet.ModelAndViewdeleteUser(UUID userId) Delete user by id.org.springframework.web.servlet.ModelAndViewshowBookingPage(AuthenticationMetaData metaData) Shows the appointment page.org.springframework.web.servlet.ModelAndViewshowDashboard(AuthenticationMetaData metaData) Shows the admin dashboard.org.springframework.web.servlet.ModelAndViewshowRepairsPage(AuthenticationMetaData metaData) Shows the repair page.org.springframework.web.servlet.ModelAndViewshowReportsPage(AuthenticationMetaData metadata) Shows the admin reports page.org.springframework.web.servlet.ModelAndViewshowServicePage(AuthenticationMetaData metaData) Shows the admin services page.org.springframework.web.servlet.ModelAndViewshowSettingsPage(AuthenticationMetaData metaData) Shows the admin settings page.org.springframework.web.servlet.ModelAndViewshowUsers(AuthenticationMetaData metaData) Shows the admin users page.org.springframework.web.servlet.ModelAndViewupdateService(AuthenticationMetaData metaData, @Valid UpdateServiceRequest request, org.springframework.validation.BindingResult result) Updates an existing service.org.springframework.web.servlet.ModelAndViewupdateUser(AuthenticationMetaData metaData, @Valid UpdateUserRequest request, org.springframework.validation.BindingResult result) Updates an existing user account from the admin dashboard.
-
Constructor Details
-
AdminController
@Autowired public AdminController(UserService userService, CatalogService catalogService, BookingService bookingService) Constructor.
-
-
Method Details
-
showDashboard
@GetMapping("/dashboard") public org.springframework.web.servlet.ModelAndView showDashboard(@AuthenticationPrincipal AuthenticationMetaData metaData) Shows the admin dashboard.- Parameters:
metaData- The authentication metadata.- Returns:
- The admin dashboard.
-
showUsers
@GetMapping("/users") public org.springframework.web.servlet.ModelAndView showUsers(@AuthenticationPrincipal AuthenticationMetaData metaData) Shows the admin users page.- Parameters:
metaData- The authentication metadata.- Returns:
- The admin users page.
-
showServicePage
@GetMapping("/services") public org.springframework.web.servlet.ModelAndView showServicePage(@AuthenticationPrincipal AuthenticationMetaData metaData) Shows the admin services page.- Parameters:
metaData- The authentication metadata.- Returns:
- The admin services page.
-
showBookingPage
@GetMapping("/bookings") public org.springframework.web.servlet.ModelAndView showBookingPage(@AuthenticationPrincipal AuthenticationMetaData metaData) Shows the appointment page.- Parameters:
metaData- The authentication metadata.- Returns:
- The appointment page.
-
cancelBooking
@PostMapping("/bookings/{id}/cancel") public String cancelBooking(@PathVariable("id") UUID id, org.springframework.web.servlet.mvc.support.RedirectAttributes attributes) Cancels a booking.- Parameters:
id- The booking id.attributes- Flash attributes for the redirect.- Returns:
- Redirect back to the bookings page.
-
archiveBooking
@PostMapping("/bookings/{id}/archive") public String archiveBooking(@PathVariable("id") UUID id, org.springframework.web.servlet.mvc.support.RedirectAttributes attributes) Archives a booking.- Parameters:
id- The booking id.attributes- Flash attributes for the redirect.- Returns:
- Redirect back to the bookings page.
-
showRepairsPage
@GetMapping("/repairs") public org.springframework.web.servlet.ModelAndView showRepairsPage(@AuthenticationPrincipal AuthenticationMetaData metaData) Shows the repair page.- Parameters:
metaData- The authentication metadata.- Returns:
- The repair page.
-
showReportsPage
@GetMapping("/reports") public org.springframework.web.servlet.ModelAndView showReportsPage(@AuthenticationPrincipal AuthenticationMetaData metadata) Shows the admin reports page.- Parameters:
metadata- The authentication metadata.- Returns:
- The admin reports page.
-
showSettingsPage
@GetMapping("/settings") public org.springframework.web.servlet.ModelAndView showSettingsPage(@AuthenticationPrincipal AuthenticationMetaData metaData) Shows the admin settings page.- Parameters:
metaData- The authentication metadata.- Returns:
- The admin settings page.
-
createNewUser
@PostMapping("/new-user") public org.springframework.web.servlet.ModelAndView createNewUser(@AuthenticationPrincipal AuthenticationMetaData metaData, @Valid @Valid RegisterNewUserRequest request, org.springframework.validation.BindingResult result) Creates a new user account.- Parameters:
metaData- The authentication metadata.request- The registration request.result- The binding result.- Returns:
- The updated users page.
-
updateUser
@PutMapping("/update-user") public org.springframework.web.servlet.ModelAndView updateUser(@AuthenticationPrincipal AuthenticationMetaData metaData, @Valid @Valid UpdateUserRequest request, org.springframework.validation.BindingResult result) Updates an existing user account from the admin dashboard.- Parameters:
metaData- The authentication metadata.request- The update request.result- The binding result.- Returns:
- The updated users page.
-
deleteUser
@DeleteMapping("/delete-user/{userId}") public org.springframework.web.servlet.ModelAndView deleteUser(@PathVariable("userId") UUID userId) Delete user by id.- Parameters:
userId- The user id.
-
changeAdminEmail
@PutMapping("/settings/email") public org.springframework.web.servlet.ModelAndView changeAdminEmail(@AuthenticationPrincipal AuthenticationMetaData metaData, @Valid @Valid AdminChangeEmailRequest request, org.springframework.validation.BindingResult result) Changes the admin's email.- Parameters:
metaData- The authentication metadata.request- The change email request.result- The binding result.- Returns:
- The settings page.
-
changeAdminPassword
@PutMapping("/settings/password") public org.springframework.web.servlet.ModelAndView changeAdminPassword(@AuthenticationPrincipal AuthenticationMetaData metaData, @Valid @Valid AdminChangePasswordRequest request, org.springframework.validation.BindingResult result) Changes the admin's password.- Parameters:
metaData- The authentication metadata.request- The change password request.result- The binding result.- Returns:
- The settings page.
-
createService
@PostMapping("/new-service") public org.springframework.web.servlet.ModelAndView createService(@AuthenticationPrincipal AuthenticationMetaData metaData, @Valid @Valid CreateServiceRequest request, org.springframework.validation.BindingResult result) Creates a new service.- Parameters:
metaData- The authentication metadata.request- The create service request.result- The binding result.- Returns:
- The services page.
-
updateService
@PutMapping("/update-service") public org.springframework.web.servlet.ModelAndView updateService(@AuthenticationPrincipal AuthenticationMetaData metaData, @Valid @Valid UpdateServiceRequest request, org.springframework.validation.BindingResult result) Updates an existing service.- Parameters:
metaData- The authentication metadata.request- The update service request.result- The binding result.- Returns:
- The services page.
-
deleteService
@DeleteMapping("/delete-service/{serviceId}") public org.springframework.web.servlet.ModelAndView deleteService(@PathVariable("serviceId") UUID serviceId) Deletes a service by id.- Parameters:
serviceId- The service id.
-