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 Details

  • 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.