1 | package edu.ucsb.cs156.courses.controllers; | |
2 | ||
3 | import java.util.List; | |
4 | ||
5 | import edu.ucsb.cs156.courses.collections.ConvertedSectionCollection; | |
6 | import edu.ucsb.cs156.courses.documents.ConvertedSection; | |
7 | import io.swagger.annotations.ApiOperation; | |
8 | ||
9 | import org.slf4j.Logger; | |
10 | import org.slf4j.LoggerFactory; | |
11 | import org.springframework.beans.factory.annotation.Autowired; | |
12 | import org.springframework.http.ResponseEntity; | |
13 | import org.springframework.web.bind.annotation.GetMapping; | |
14 | import org.springframework.web.bind.annotation.RequestMapping; | |
15 | import org.springframework.web.bind.annotation.RequestParam; | |
16 | import org.springframework.web.bind.annotation.RestController; | |
17 | ||
18 | import io.swagger.annotations.ApiParam; | |
19 | ||
20 | import com.fasterxml.jackson.core.JsonProcessingException; | |
21 | import com.fasterxml.jackson.databind.ObjectMapper; | |
22 | ||
23 | @RestController | |
24 | @RequestMapping("/api/public/courseovertime") | |
25 | public class SearchByInstructorController { | |
26 | ||
27 | private final Logger logger = LoggerFactory.getLogger(SearchByInstructorController.class); | |
28 | ||
29 | private ObjectMapper mapper = new ObjectMapper(); | |
30 | ||
31 | @Autowired | |
32 | ConvertedSectionCollection convertedSectionCollection; | |
33 | ||
34 | @ApiOperation(value = "Get a list of courses taught by an instructor") | |
35 | @GetMapping(value = "/instructorsearch", produces = "application/json") | |
36 | public ResponseEntity<String> search | |
37 | ( | |
38 | @ApiParam | |
39 | ( | |
40 | name = "startQtr", | |
41 | required = true, | |
42 | value = "Quarter in YYYYQ format (1=Winter, 2=Spring, 3=Summer, 4=Fall)", | |
43 | example = "20202" | |
44 | ) | |
45 | @RequestParam String startQtr, | |
46 | @ApiParam | |
47 | ( | |
48 | name = "endQtr", | |
49 | required = true, | |
50 | value = "Quarter in YYYYQ format (1=Winter, 2=Spring, 3=Summer, 4=Fall)", | |
51 | example = "20232" | |
52 | ) | |
53 | @RequestParam String endQtr, | |
54 | @ApiParam | |
55 | ( | |
56 | name = "instructor", | |
57 | required = true, | |
58 | value = "Instructor's name", | |
59 | example = "'CONRAD'" | |
60 | ) | |
61 | @RequestParam String instructor | |
62 | ) | |
63 | throws JsonProcessingException | |
64 | { | |
65 | List<ConvertedSection> courseResults = convertedSectionCollection.findByQuarterRangeAndInstructor | |
66 | ( | |
67 | startQtr, | |
68 | endQtr, | |
69 | instructor | |
70 | ); | |
71 | String body = mapper.writeValueAsString(courseResults); | |
72 |
1
1. search : replaced return value with null for edu/ucsb/cs156/courses/controllers/SearchByInstructorController::search → KILLED |
return ResponseEntity.ok().body(body); |
73 | } | |
74 | } | |
Mutations | ||
72 |
1.1 |