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 edu.ucsb.cs156.spring.backenddemo.services.LocationQueryService; | |
7 | import lombok.extern.slf4j.Slf4j; | |
8 | ||
9 | import org.springframework.web.bind.annotation.GetMapping; | |
10 | import org.springframework.web.bind.annotation.RequestMapping; | |
11 | import org.springframework.web.bind.annotation.RequestParam; | |
12 | import org.springframework.beans.factory.annotation.Autowired; | |
13 | import org.springframework.http.ResponseEntity; | |
14 | ||
15 | import com.fasterxml.jackson.core.JsonProcessingException; | |
16 | import com.fasterxml.jackson.databind.ObjectMapper; | |
17 | ||
18 | import io.swagger.v3.oas.annotations.Operation; | |
19 | import io.swagger.v3.oas.annotations.Parameter; | |
20 | import io.swagger.v3.oas.annotations.tags.Tag; | |
21 | ||
22 | ||
23 | @Tag(name="Location info from nominatim.org") | |
24 | @Slf4j | |
25 | @RestController | |
26 | @RequestMapping("/api/locations") | |
27 | public class LocationController { | |
28 | | |
29 | ObjectMapper mapper = new ObjectMapper(); | |
30 | ||
31 | @Autowired | |
32 | LocationQueryService locationQueryService; | |
33 | ||
34 | @Operation(summary = "Get list of locations that match a given location name", description = "Uses API documented here: https://nominatim.org/release-docs/develop/api/Search/") | |
35 | @GetMapping("/get") | |
36 | public ResponseEntity<String> getLocation( | |
37 | @Parameter(name="location", description = "name to search", example="Isla Vista") @RequestParam String location | |
38 | ) throws JsonProcessingException { | |
39 | log.info("getLocations: location={}", location); | |
40 | String result = locationQueryService.getJSON(location); | |
41 |
1
1. getLocation : replaced return value with null for edu/ucsb/cs156/spring/backenddemo/controllers/LocationController::getLocation → KILLED |
return ResponseEntity.ok().body(result); |
42 | } | |
43 | ||
44 | ||
45 | } | |
Mutations | ||
41 |
1.1 |