1 | package edu.ucsb.cs156.spring.backenddemo.controllers; | |
2 | ||
3 | import edu.ucsb.cs156.spring.backenddemo.services.LocationQueryService; | |
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 | import io.swagger.v3.oas.annotations.Operation; | |
17 | import io.swagger.v3.oas.annotations.Parameter; | |
18 | import io.swagger.v3.oas.annotations.tags.Tag; | |
19 | ||
20 | ||
21 | ||
22 | @Tag(name="Location info from nominatim.org") | |
23 | @Slf4j | |
24 | @RestController | |
25 | @RequestMapping("/api/locations") | |
26 | public class LocationController { | |
27 | | |
28 | ObjectMapper mapper = new ObjectMapper(); | |
29 | ||
30 | @Autowired | |
31 | LocationQueryService locationQueryService; | |
32 | ||
33 | @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/") | |
34 | @GetMapping("/get") | |
35 | public ResponseEntity<String> getLocation( | |
36 | @Parameter(name="location", description="name to search", example="Isla Vista") @RequestParam String location | |
37 | ) throws JsonProcessingException { | |
38 | log.info("getlocstion: location={}", location); | |
39 | String result = locationQueryService.getJSON(location); | |
40 |
1
1. getLocation : replaced return value with null for edu/ucsb/cs156/spring/backenddemo/controllers/LocationController::getLocation → KILLED |
return ResponseEntity.ok().body(result); |
41 | } | |
42 | ||
43 | } | |
Mutations | ||
40 |
1.1 |