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 info from NOAA") | |
23 | @Slf4j | |
24 | @RestController | |
25 | @RequestMapping("/api/tides") | |
26 | public class TidesController { | |
27 | ||
28 | ObjectMapper mapper = new ObjectMapper(); | |
29 | ||
30 | @Autowired | |
31 | TidesQueryService tidesQueryService; | |
32 | ||
33 | @Operation(summary = "Get tide information based start date, end date, and station information", description = "JSON return format documented here: https://tidesandcurrents.noaa.gov ") | |
34 | @GetMapping("/get") | |
35 | public ResponseEntity<String> getTides( | |
36 | @Parameter(name="beginDate", description="start date for query", example="20231113") @RequestParam String beginDate, | |
37 | @Parameter(name="endDate", description="end date for query", example="20231115") @RequestParam String endDate, | |
38 | @Parameter(name="station", description="station number for query", example="9414290") @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 |