-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathWeatherController.java
More file actions
34 lines (26 loc) · 1008 Bytes
/
WeatherController.java
File metadata and controls
34 lines (26 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package org.example.weeklab4.controller;
import org.example.weeklab4.service.WeatherService;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@RequestMapping("/weather")
public class WeatherController {
private final WeatherService weatherService;
public WeatherController(WeatherService weatherService) {
this.weatherService = weatherService;
}
@GetMapping("/temperature")
public int getTemp() { return weatherService.getTemperature(); }
@GetMapping("/condition")
public String getCondition() { return weatherService.getCondition(); }
@GetMapping("/wind")
public int getWind() { return weatherService.getWindSpeed(); }
@GetMapping("/all")
public Map<String, Object> getAllWeather() {
return Map.of(
"temperature", weatherService.getTemperature(),
"condition", weatherService.getCondition(),
"windSpeed", weatherService.getWindSpeed()
);
}
}