| 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 | ||
| 21 | private ObjectMapper mapper = new ObjectMapper(); | |
| 22 | ||
| 23 | @Autowired ConvertedSectionCollection convertedSectionCollection; | |
| 24 | ||
| 25 | @Operation(summary = "Get a list of courses over time, filtered by (abbreviated) building code") | |
| 26 | @GetMapping(value = "/buildingsearch", produces = "application/json") | |
| 27 | public ResponseEntity<String> search( | |
| 28 | @Parameter( | |
| 29 | name = "startQtr", | |
| 30 | description = | |
| 31 | "Starting quarter in yyyyq format, e.g. 20231 for W23, 20232 for S23, etc. (1=Winter, 2=Spring, 3=Summer, 4=Fall)", | |
| 32 | example = "20231", | |
| 33 | required = true) | |
| 34 | @RequestParam | |
| 35 | String startQtr, | |
| 36 | @Parameter( | |
| 37 | name = "endQtr", | |
| 38 | description = | |
| 39 | "Ending quarter in yyyyq format, e.g. 20231 for W23, 20232 for S23, etc. (1=Winter, 2=Spring, 3=Summer, 4=Fall)", | |
| 40 | example = "20231", | |
| 41 | required = true) | |
| 42 | @RequestParam | |
| 43 | String endQtr, | |
| 44 | @Parameter( | |
| 45 | name = "buildingCode", | |
| 46 | description = "Building code such as PHELP for Phelps, GIRV for Girvetz", | |
| 47 | example = "GIRV", | |
| 48 | required = true) | |
| 49 | @RequestParam | |
| 50 | String buildingCode) | |
| 51 | throws JsonProcessingException { | |
| 52 | List<ConvertedSection> courseResults = | |
| 53 | convertedSectionCollection.findByQuarterRangeAndBuildingCode( | |
| 54 | startQtr, endQtr, buildingCode); | |
| 55 | String body = mapper.writeValueAsString(courseResults); | |
| 56 |
1
1. search : replaced return value with null for edu/ucsb/cs156/courses/controllers/CourseOverTimeBuildingController::search → KILLED |
return ResponseEntity.ok().body(body); |
| 57 | } | |
| 58 | } | |
Mutations | ||
| 56 |
1.1 |