Class StaffController

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

@RequestMapping("/api/staff") @RestController public class StaffController extends ApiController
  • Constructor Details

    • StaffController

      public StaffController()
  • Method Details

    • allStaff

      @PreAuthorize("hasRole('ROLE_ADMIN')") @GetMapping("/all") public Iterable<Staff> allStaff()
    • staffForCourse

      @PreAuthorize("hasRole('ROLE_ADMIN')") @GetMapping("/course/{courseId}") public Iterable<Staff> staffForCourse(@PathVariable Long courseId)
    • getStaffById

      @PreAuthorize("hasRole('ROLE_ADMIN')") @GetMapping("/{id}") public Staff getStaffById(@PathVariable Long id)
    • postStaff

      @PreAuthorize("hasRole('ROLE_ADMIN')") @PostMapping("") public Staff postStaff(@RequestBody StaffDTO staffDTO)
    • updateStaff

      @PreAuthorize("hasRole('ROLE_ADMIN')") @PutMapping("/{id}") public Staff updateStaff(@PathVariable Long id, @RequestBody StaffDTO staffDTO)
    • deleteStaff

      @PreAuthorize("hasRole('ROLE_ADMIN')") @DeleteMapping("/{id}") public Object deleteStaff(@PathVariable Long id)
    • uploadStaffCsv

      @PreAuthorize("hasRole('ROLE_ADMIN')") @PostMapping(value="/upload/csv", consumes="multipart/form-data") public CsvUploadResult uploadStaffCsv(@RequestParam Long courseId, @RequestParam("file") org.springframework.web.multipart.MultipartFile file) throws IOException
      Bulk-adds staff to a course from an uploaded CSV file, with a single fixed header format (lastName,firstMiddleName,email). Rows whose email is already on the course's staff list are skipped rather than duplicated.
      Parameters:
      courseId - the course to add the staff to
      file - the uploaded CSV file
      Returns:
      a summary of how many staff were created, and which emails were skipped as already-on-roster
      Throws:
      IOException