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.TidesQueryService; | |
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 | @Tag(name="Tide Information from NOAA https://api.tidesandcurrents.noaa.gov/api/prod/") | |
23 | @Slf4j | |
24 | ||
25 | @RestController | |
26 | @RequestMapping("/api/tides") | |
27 | public class TidesController { | |
28 | ObjectMapper mapper = new ObjectMapper(); | |
29 | ||
30 | @Autowired | |
31 | TidesQueryService tidesQueryService; | |
32 | ||
33 | @Operation(summary = "Get water level for date range, in local time.", description = "For station id, see: https://tidesandcurrents.noaa.gov/tide_predictions.html?gid=1393") | |
34 | @GetMapping("/get") | |
35 | public ResponseEntity<String> getTides( | |
36 | @Parameter(name="beginDate", description="beginDate in format yyyymmdd") @RequestParam String beginDate, | |
37 | @Parameter(name="endDate", description="endDate in format yyyymmdd") @RequestParam String endDate, | |
38 | @Parameter(name="station", description="station", example="9411340") @RequestParam String station | |
39 | ) throws JsonProcessingException { | |
40 | log.info("getTides: beginDate={} endDate={} station={}", beginDate, endDate, station); | |
41 | String result = tidesQueryService.getJSON(beginDate, endDate, station); | |
42 |
1
1. getTides : replaced return value with null for edu/ucsb/cs156/spring/backenddemo/controllers/TidesController::getTides → KILLED |
return ResponseEntity.ok().body(result); |
43 | } | |
44 | ||
45 | } | |
Mutations | ||
42 |
1.1 |