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 Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionList all studentsdeleteStudents(Long id) Delete a StudentGet a student by idCreate new StudentupdateStudents(Long id, @Valid Students incoming) Update a single StudentMethods inherited from class edu.ucsb.cs156.happiercows.controllers.ApiController
genericMessage, getCurrentUser, handleBadRequest, handleGenericException 
- 
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 namefirstMiddleName- first and middle nameemail- emailperm- Perm numbercourseId- 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 updateincoming- 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
 
 
 -