| 1 | package edu.ucsb.cs156.spring.backenddemo.controllers; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.spring.backenddemo.services.UniversityQueryService; | |
| 4 | import lombok.extern.slf4j.Slf4j; | |
| 5 | ||
| 6 | import org.springframework.web.bind.annotation.GetMapping; | |
| 7 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 8 | import org.springframework.web.bind.annotation.RequestParam; | |
| 9 | import org.springframework.web.bind.annotation.RestController; | |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | import org.springframework.http.ResponseEntity; | |
| 12 | ||
| 13 | import com.fasterxml.jackson.core.JsonProcessingException; | |
| 14 | import com.fasterxml.jackson.databind.ObjectMapper; | |
| 15 | ||
| 16 | ||
| 17 | import io.swagger.v3.oas.annotations.Operation; | |
| 18 | import io.swagger.v3.oas.annotations.Parameter; | |
| 19 | import io.swagger.v3.oas.annotations.tags.Tag; | |
| 20 | ||
| 21 | @Tag(name="University info from universities.hipolabs.com") | |
| 22 | @Slf4j | |
| 23 | @RestController | |
| 24 | @RequestMapping("/api/university") | |
| 25 | public class UniversityController { | |
| 26 | ||
| 27 | ObjectMapper mapper = new ObjectMapper(); | |
| 28 | ||
| 29 | @Autowired | |
| 30 | UniversityQueryService universityQueryService; | |
| 31 | ||
| 32 | @Operation(summary="Get list of universities that match a given name", description ="Uses API documented here: http://universities.hipolabs.com/search") | |
| 33 | ||
| 34 | @GetMapping("/get") | |
| 35 | public ResponseEntity<String> getUniversitiess( | |
| 36 | @Parameter(name="name", example="Harvard") @RequestParam String name | |
| 37 | ) throws JsonProcessingException { | |
| 38 | log.info("getUniversitys: name={}", name); | |
| 39 | String result = universityQueryService.getJSON(name); | |
| 40 |
1
1. getUniversitiess : replaced return value with null for edu/ucsb/cs156/spring/backenddemo/controllers/UniversityController::getUniversitiess → KILLED |
return ResponseEntity.ok().body(result); |
| 41 | } | |
| 42 | ||
| 43 | } | |
Mutations | ||
| 40 |
1.1 |