Package dev.karlkadak.backend.controller
Class CityController
java.lang.Object
dev.karlkadak.backend.controller.CityController
REST controller for interacting with the city database
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CityManager
private final CityRepository
private final WeatherDataRepository
-
Constructor Summary
ConstructorsConstructorDescriptionCityController
(CityRepository cityRepository, CityManager cityManager, WeatherDataRepository weatherDataRepository) -
Method Summary
Modifier and TypeMethodDescription(package private) org.springframework.http.ResponseEntity
<List<CityResponse>> all()
API endpoint for retrieving information about allCity
objects for which data collection is enabled(package private) org.springframework.http.ResponseEntity
<Void> API endpoint for disabling weather data tracking for aCity
object(package private) org.springframework.http.ResponseEntity
<CityResponse> enable
(AddCityRequest addCityRequest) API endpoint for adding and / or enabling weather data tracking for aCity
object(package private) org.springframework.http.ResponseEntity
<CityResponse> API endpoint for retrieving information about a singleCity
object(package private) org.springframework.http.ResponseEntity
<WeatherResponse> API endpoint for requesting the most recent weather data linked to aCity
object
-
Field Details
-
cityRepository
-
cityManager
-
weatherDataRepository
-
-
Constructor Details
-
CityController
@Autowired public CityController(CityRepository cityRepository, CityManager cityManager, WeatherDataRepository weatherDataRepository)
-
-
Method Details
-
all
API endpoint for retrieving information about allCity
objects for which data collection is enabled- Returns:
- list of
CityResponse
objects representing allCity
objects for which data collection is enabled
-
enable
@PostMapping org.springframework.http.ResponseEntity<CityResponse> enable(@RequestBody AddCityRequest addCityRequest) API endpoint for adding and / or enabling weather data tracking for aCity
object- Parameters:
addCityRequest
- request body (city name)- Returns:
- a
CityResponse
object representing the added / enabledCity
object
-
one
@GetMapping("/{id}") org.springframework.http.ResponseEntity<CityResponse> one(@PathVariable Long id) API endpoint for retrieving information about a singleCity
object- Parameters:
id
- theCity
object'sid
- Returns:
- a
CityResponse
object representing the selectedCity
object
-
disable
-
weather
@GetMapping("/{id}/weather") org.springframework.http.ResponseEntity<WeatherResponse> weather(@PathVariable Long id) API endpoint for requesting the most recent weather data linked to aCity
object- Parameters:
id
- theCity
object'sid
- Returns:
- the DTO of latest recorded
WeatherData
object
-