| 1 | package edu.ucsb.cs156.spring.backenddemo.controllers; | |
| 2 | ||
| 3 | import org.springframework.web.bind.annotation.RestController; | |
| 4 | ||
| 5 | import edu.ucsb.cs156.spring.backenddemo.services.EarthquakeQueryService; | |
| 6 | import lombok.extern.slf4j.Slf4j; | |
| 7 | ||
| 8 | import org.springframework.web.bind.annotation.GetMapping; | |
| 9 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 10 | import org.springframework.web.bind.annotation.RequestParam; | |
| 11 | import org.springframework.beans.factory.annotation.Autowired; | |
| 12 | import org.springframework.http.ResponseEntity; | |
| 13 | ||
| 14 | import com.fasterxml.jackson.core.JsonProcessingException; | |
| 15 | import com.fasterxml.jackson.databind.ObjectMapper; | |
| 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="Earthquake info from USGS") | |
| 22 | @Slf4j | |
| 23 | @RestController | |
| 24 | @RequestMapping("/api/earthquakes") | |
| 25 | public class EarthquakesController { | |
| 26 | | |
| 27 | ObjectMapper mapper = new ObjectMapper(); | |
| 28 | ||
| 29 | @Autowired | |
| 30 | EarthquakeQueryService earthquakeQueryService; | |
| 31 | ||
| 32 | @Operation(summary = "Get earthquakes a certain distance from UCSB's Storke Tower", description = "JSON return format documented here: https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php") | |
| 33 | @GetMapping("/get") | |
| 34 | public ResponseEntity<String> getEarthquakes( | |
| 35 | @Parameter(name="distance", description="distance in km from Storke Tower", example="100") @RequestParam String distance, | |
| 36 | @Parameter(name="minMag", description="minimum magnitude", example="2.5") @RequestParam String minMag | |
| 37 | ) throws JsonProcessingException { | |
| 38 | log.info("getEarthquakes: distance={} minMag={}", distance, minMag); | |
| 39 | String result = earthquakeQueryService.getJSON(distance, minMag); | |
| 40 |
1
1. getEarthquakes : replaced return value with null for edu/ucsb/cs156/spring/backenddemo/controllers/EarthquakesController::getEarthquakes → KILLED |
return ResponseEntity.ok().body(result); |
| 41 | } | |
| 42 | ||
| 43 | } | |
Mutations | ||
| 40 |
1.1 |