forked from Amazon-Back-End-ES-03-25/lab_201
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeatherController.java
More file actions
40 lines (32 loc) · 1.05 KB
/
WeatherController.java
File metadata and controls
40 lines (32 loc) · 1.05 KB
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
35
36
37
38
39
40
package com.example.springdemo.controller;
import com.example.springdemo.model.WeatherInfo;
import com.example.springdemo.service.WeatherService;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/weather")
public class WeatherController {
private final WeatherService weatherService;
public WeatherController(WeatherService weatherService) {
this.weatherService = weatherService;
}
@GetMapping("/temperature")
public int getTemperature() {
return weatherService.getCurrentTemperature();
}
@GetMapping("/condition")
public String getCondition() {
return weatherService.getWeatherCondition();
}
@GetMapping("/wind")
public int getWindSpeed() {
return weatherService.getWindSpeed();
}
@GetMapping("/all")
public WeatherInfo getWeatherInfo() {
return new WeatherInfo(
weatherService.getCurrentTemperature(),
weatherService.getWeatherCondition(),
weatherService.getWindSpeed()
);
}
}