1 | package edu.ucsb.cs156.frontiers.controllers; | |
2 | ||
3 | import java.security.NoSuchAlgorithmException; | |
4 | import java.security.spec.InvalidKeySpecException; | |
5 | import java.util.*; | |
6 | ||
7 | import org.springframework.beans.factory.annotation.Autowired; | |
8 | import org.springframework.http.HttpHeaders; | |
9 | import org.springframework.http.HttpStatus; | |
10 | import org.springframework.http.ResponseEntity; | |
11 | import org.springframework.security.access.prepost.PreAuthorize; | |
12 | import org.springframework.web.bind.annotation.ExceptionHandler; | |
13 | import org.springframework.web.bind.annotation.GetMapping; | |
14 | import org.springframework.web.bind.annotation.PostMapping; | |
15 | import org.springframework.web.bind.annotation.RequestMapping; | |
16 | import org.springframework.web.bind.annotation.RequestParam; | |
17 | import org.springframework.web.bind.annotation.ResponseStatus; | |
18 | import org.springframework.web.bind.annotation.RestController; | |
19 | ||
20 | import com.fasterxml.jackson.core.JsonProcessingException; | |
21 | ||
22 | import edu.ucsb.cs156.frontiers.entities.Course; | |
23 | import edu.ucsb.cs156.frontiers.entities.User; | |
24 | import edu.ucsb.cs156.frontiers.entities.RosterStudent; | |
25 | import edu.ucsb.cs156.frontiers.enums.OrgStatus; | |
26 | import edu.ucsb.cs156.frontiers.enums.RosterStatus; | |
27 | import edu.ucsb.cs156.frontiers.entities.CourseStaff; | |
28 | import edu.ucsb.cs156.frontiers.errors.EntityNotFoundException; | |
29 | import edu.ucsb.cs156.frontiers.errors.InvalidInstallationTypeException; | |
30 | import edu.ucsb.cs156.frontiers.models.CurrentUser; | |
31 | import edu.ucsb.cs156.frontiers.repositories.CourseRepository; | |
32 | import edu.ucsb.cs156.frontiers.repositories.CourseStaffRepository; | |
33 | import edu.ucsb.cs156.frontiers.repositories.RosterStudentRepository; | |
34 | import edu.ucsb.cs156.frontiers.repositories.UserRepository; | |
35 | import edu.ucsb.cs156.frontiers.services.OrganizationLinkerService; | |
36 | import io.swagger.v3.oas.annotations.Operation; | |
37 | import io.swagger.v3.oas.annotations.Parameter; | |
38 | import io.swagger.v3.oas.annotations.tags.Tag; | |
39 | import lombok.extern.slf4j.Slf4j; | |
40 | ||
41 | @Tag(name = "CourseStaff") | |
42 | @RequestMapping("/api/coursestaff") | |
43 | @RestController | |
44 | @Slf4j | |
45 | public class CourseStaffController extends ApiController { | |
46 | | |
47 | @Autowired | |
48 | private CourseRepository courseRepository; | |
49 | ||
50 | @Autowired | |
51 | private CourseStaffRepository courseStaffRepository; | |
52 | ||
53 | ||
54 | /** | |
55 | * This method creates a new Course Staff Roster. | |
56 | * | |
57 | * @return the created course staff roster | |
58 | */ | |
59 | ||
60 | @Operation(summary = "Create a new course staff member") | |
61 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
62 | @PostMapping("/post") | |
63 | public CourseStaff postStaffRoster( | |
64 | @Parameter(name = "role") @RequestParam String role, | |
65 | @Parameter(name = "studentEmail") @RequestParam String studentEmail, | |
66 | @Parameter(name = "courseId") @RequestParam Long courseId) throws EntityNotFoundException { | |
67 | ||
68 | Course course = courseRepository.findById(courseId) | |
69 |
1
1. lambda$postStaffRoster$0 : replaced return value with null for edu/ucsb/cs156/frontiers/controllers/CourseStaffController::lambda$postStaffRoster$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(Course.class, courseId)); |
70 | CourseStaff cs = CourseStaff.builder() | |
71 | .email(studentEmail) | |
72 | .course(course) | |
73 | .role(role) | |
74 | .orgStatus(OrgStatus.NONE) | |
75 | .build(); | |
76 | CourseStaff savedCourseStaff = courseStaffRepository.save(cs); | |
77 | ||
78 |
1
1. postStaffRoster : replaced return value with null for edu/ucsb/cs156/frontiers/controllers/CourseStaffController::postStaffRoster → KILLED |
return savedCourseStaff; |
79 | } | |
80 | ||
81 | } | |
Mutations | ||
69 |
1.1 |
|
78 |
1.1 |