Class StudentsController

java.lang.Object
edu.ucsb.cs156.happiercows.controllers.ApiController
edu.ucsb.cs156.happiercows.controllers.StudentsController

@RequestMapping("/api/Students") @RestController public class StudentsController extends ApiController
  • Constructor Details

    • StudentsController

      public StudentsController()
  • Method Details

    • allStudents

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("/all") public Iterable<Students> allStudents()
      List all students
      Returns:
      an iterable of Students
    • postStudents

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public Students postStudents(@RequestParam String lastName, @RequestParam String firstMiddleName, @RequestParam String email, @RequestParam String perm, @RequestParam Long courseId) throws com.fasterxml.jackson.core.JsonProcessingException
      Create new Student
      Parameters:
      lastName - last name
      firstMiddleName - first and middle name
      email - email
      perm - Perm number
      courseId - course ID
      Returns:
      saved student
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getById

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("") public Students getById(@RequestParam Long id)
      Get a student by id
      Parameters:
      id - the id of the student
      Returns:
      a Student
    • updateStudents

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public Students updateStudents(@RequestParam Long id, @RequestBody @Valid @Valid Students incoming)
      Update a single Student
      Parameters:
      id - id of the Student to update
      incoming - the new Student
      Returns:
      the updated Students object
    • deleteStudents

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteStudents(@RequestParam Long id)
      Delete a Student
      Parameters:
      id - the id of the Students to delete
      Returns:
      a message indicating the Students was deleted