1 | package edu.ucsb.cs156.courses.controllers; | |
2 | ||
3 | import com.fasterxml.jackson.core.JsonProcessingException; | |
4 | import com.fasterxml.jackson.databind.ObjectMapper; | |
5 | import edu.ucsb.cs156.courses.collections.ConvertedSectionCollection; | |
6 | import edu.ucsb.cs156.courses.documents.ConvertedSection; | |
7 | import io.swagger.v3.oas.annotations.Operation; | |
8 | import io.swagger.v3.oas.annotations.Parameter; | |
9 | import java.util.List; | |
10 | import org.springframework.beans.factory.annotation.Autowired; | |
11 | import org.springframework.http.ResponseEntity; | |
12 | import org.springframework.web.bind.annotation.GetMapping; | |
13 | import org.springframework.web.bind.annotation.RequestMapping; | |
14 | import org.springframework.web.bind.annotation.RequestParam; | |
15 | import org.springframework.web.bind.annotation.RestController; | |
16 | ||
17 | @RestController | |
18 | @RequestMapping("/api/public/courseovertime") | |
19 | public class CourseOverTimeBuildingController { | |
20 | private ObjectMapper mapper = new ObjectMapper(); | |
21 | ||
22 | @Autowired ConvertedSectionCollection convertedSectionCollection; | |
23 | ||
24 | @Operation(summary = "Get a list of courses over time, filtered by (abbreviated) building code") | |
25 | @GetMapping(value = "/buildingsearch", produces = "application/json") | |
26 | public ResponseEntity<String> search( | |
27 | @Parameter( | |
28 | name = "startQtr", | |
29 | description = | |
30 | "Starting quarter in yyyyq format, e.g. 20231 for W23, 20232 for S23, etc. (1=Winter, 2=Spring, 3=Summer, 4=Fall)", | |
31 | example = "20231", | |
32 | required = true) | |
33 | @RequestParam | |
34 | String startQtr, | |
35 | @Parameter( | |
36 | name = "endQtr", | |
37 | description = | |
38 | "Ending quarter in yyyyq format, e.g. 20231 for W23, 20232 for S23, etc. (1=Winter, 2=Spring, 3=Summer, 4=Fall)", | |
39 | example = "20231", | |
40 | required = true) | |
41 | @RequestParam | |
42 | String endQtr, | |
43 | @Parameter( | |
44 | name = "buildingCode", | |
45 | description = "Building code such as PHELP for Phelps, GIRV for Girvetz", | |
46 | example = "GIRV", | |
47 | required = true) | |
48 | @RequestParam | |
49 | String buildingCode) | |
50 | throws JsonProcessingException { | |
51 | List<ConvertedSection> courseResults = | |
52 | convertedSectionCollection.findByQuarterRangeAndBuildingCode( | |
53 | startQtr, endQtr, buildingCode); | |
54 | String body = mapper.writeValueAsString(courseResults); | |
55 |
1
1. search : replaced return value with null for edu/ucsb/cs156/courses/controllers/CourseOverTimeBuildingController::search → KILLED |
return ResponseEntity.ok().body(body); |
56 | } | |
57 | } | |
Mutations | ||
55 |
1.1 |