| 1 | package edu.ucsb.cs156.courses.controllers; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.courses.entities.GradeHistory; | |
| 4 | ||
| 5 | import edu.ucsb.cs156.courses.repositories.GradeHistoryRepository; | |
| 6 | import edu.ucsb.cs156.courses.services.UCSBGradeHistoryService; | |
| 7 | import edu.ucsb.cs156.courses.utilities.CourseUtilities; | |
| 8 | import io.swagger.annotations.Api; | |
| 9 | import io.swagger.annotations.ApiOperation; | |
| 10 | import lombok.extern.slf4j.Slf4j; | |
| 11 | ||
| 12 | import com.fasterxml.jackson.databind.ObjectMapper; | |
| 13 | ||
| 14 | import org.springframework.beans.factory.annotation.Autowired; | |
| 15 | import org.springframework.http.HttpStatus; | |
| 16 | import org.springframework.http.ResponseEntity; | |
| 17 | import org.springframework.security.access.prepost.PreAuthorize; | |
| 18 | import org.springframework.web.bind.annotation.GetMapping; | |
| 19 | import org.springframework.web.bind.annotation.PostMapping; | |
| 20 | ||
| 21 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 22 | import org.springframework.web.bind.annotation.RequestParam; | |
| 23 | import org.springframework.web.bind.annotation.RequestPart; | |
| 24 | ||
| 25 | import org.springframework.web.bind.annotation.RestController; | |
| 26 | import org.springframework.web.multipart.MultipartFile; | |
| 27 | import org.springframework.web.server.ResponseStatusException; | |
| 28 | ||
| 29 | import java.io.IOException; | |
| 30 | import java.io.InputStreamReader; | |
| 31 | import java.io.Reader; | |
| 32 | import java.util.List; | |
| 33 | ||
| 34 | @Slf4j | |
| 35 | @Api(description = "API for grade history data") | |
| 36 | @RequestMapping("/api/gradehistory") | |
| 37 | @RestController | |
| 38 | public class GradeHistoryController extends ApiController { | |
| 39 | @Autowired | |
| 40 | GradeHistoryRepository gradeHistoryRepository; | |
| 41 | ||
| 42 | @Autowired | |
| 43 | ObjectMapper mapper; | |
| 44 | ||
| 45 | @ApiOperation(value = "Get grade history for a course") | |
| 46 | @GetMapping(value = "/search", produces = "application/json") | |
| 47 | public Iterable<GradeHistory> gradeHistoryBySubjectAreaAndCourseNumber( | |
| 48 | @RequestParam String subjectArea, | |
| 49 | @RequestParam String courseNumber | |
| 50 | ) { | |
| 51 | String course=CourseUtilities.makeFormattedCourseId(subjectArea, courseNumber); | |
| 52 | Iterable<GradeHistory> gradeHistoryRows = gradeHistoryRepository.findByCourse(course); | |
| 53 |
1
1. gradeHistoryBySubjectAreaAndCourseNumber : replaced return value with null for edu/ucsb/cs156/courses/controllers/GradeHistoryController::gradeHistoryBySubjectAreaAndCourseNumber → KILLED |
return gradeHistoryRows; |
| 54 | } | |
| 55 | ||
| 56 | @ApiOperation(value = "Get all grade history") | |
| 57 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 58 | @GetMapping("/all") | |
| 59 | public Iterable<GradeHistory> allHistory() { | |
| 60 | Iterable<GradeHistory> gradeHistoryRows = gradeHistoryRepository.findAll(); | |
| 61 |
1
1. allHistory : replaced return value with null for edu/ucsb/cs156/courses/controllers/GradeHistoryController::allHistory → SURVIVED |
return gradeHistoryRows; |
| 62 | } | |
| 63 | ||
| 64 | | |
| 65 | } | |
Mutations | ||
| 53 |
1.1 |
|
| 61 |
1.1 |