Class AdminController

java.lang.Object
com.ericbouchut.learndev.admin.AdminController

@Controller @RequestMapping("/admin") public class AdminController extends Object
Web endpoints of the administration area under /admin/** (gated to ROLE_ADMIN by the security rules): the account list, instructor account creation, and account archiving. Rules and the audit trail live in AccountAdminService.
  • Constructor Details

  • Method Details

    • userList

      @GetMapping("/users") public String userList(org.springframework.ui.Model model)
      Display every account with its roles and active flag.
      Parameters:
      model - receives the accounts
      Returns:
      the account list view name
    • newInstructorForm

      @GetMapping("/users/new-instructor") public String newInstructorForm(org.springframework.ui.Model model)
      Display the instructor account creation form.
      Parameters:
      model - receives an empty form
      Returns:
      the account form view name
    • createInstructor

      @PostMapping("/users/new-instructor") public String createInstructor(@Valid @ModelAttribute("form") @Valid RegisterForm form, org.springframework.validation.BindingResult binding, Principal principal, jakarta.servlet.http.HttpServletRequest request)
      Create an instructor account. Duplicate username/email surface as field errors, like self-registration.
      Parameters:
      form - the submitted form, validated by @Valid
      binding - collects validation and duplicate-field errors
      principal - the logged-in admin
      request - provides the client IP for the audit trail
      Returns:
      a redirect to the account list, or the re-rendered form
    • archiveAccount

      @PostMapping("/users/{userId}/archive") public String archiveAccount(@PathVariable UUID userId, Principal principal, jakarta.servlet.http.HttpServletRequest request)
      Archive an account (PRG with an archived flag).
      Parameters:
      userId - the account to archive
      principal - the logged-in admin (self-archive guard)
      request - provides the client IP for the audit trail
      Returns:
      a redirect to the account list
    • unlockAccount

      @PostMapping("/users/{userId}/unlock") public String unlockAccount(@PathVariable UUID userId, Principal principal, jakarta.servlet.http.HttpServletRequest request)
      Unlock an account locked by failed logins (PRG with an unlocked flag).
      Parameters:
      userId - the account to unlock
      principal - the logged-in admin
      request - provides the client IP for the audit trail
      Returns:
      a redirect to the account list
    • reactivateAccount

      @PostMapping("/users/{userId}/reactivate") public String reactivateAccount(@PathVariable UUID userId, Principal principal, jakarta.servlet.http.HttpServletRequest request)
      Reactivate an account (PRG with a reactivated flag).
      Parameters:
      userId - the account to reactivate
      principal - the logged-in admin
      request - provides the client IP for the audit trail
      Returns:
      a redirect to the account list
    • courseList

      @GetMapping("/courses") public String courseList(org.springframework.ui.Model model)
      Display every course, any status, any instructor, with its lessons (content moderation view).
      Parameters:
      model - receives the courses and their lessons
      Returns:
      the course moderation view name
    • transitionCourse

      @PostMapping("/courses/{courseId}/{action:archive|restore}") public String transitionCourse(@PathVariable Long courseId, @PathVariable String action, Principal principal, jakarta.servlet.http.HttpServletRequest request)
      Archive or restore any course, bypassing the instructor ownership rule (the lifecycle guards still apply). PRG back to the list.
      Parameters:
      courseId - the course to transition
      action - archive or restore
      principal - the logged-in admin
      request - provides the client IP for the audit trail
      Returns:
      a redirect to the course moderation view
    • transitionLesson

      @PostMapping("/courses/{courseId}/lessons/{lessonId}/{action:archive|restore}") public String transitionLesson(@PathVariable Long courseId, @PathVariable Long lessonId, @PathVariable String action, Principal principal, jakarta.servlet.http.HttpServletRequest request)
      Archive or restore any lesson of a course, bypassing the instructor ownership rule. PRG back to the list.
      Parameters:
      courseId - the course the lesson belongs to
      lessonId - the lesson to transition
      action - archive or restore
      principal - the logged-in admin
      request - provides the client IP for the audit trail
      Returns:
      a redirect to the course moderation view