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 CityManagerprivate final CityRepositoryprivate 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 allCityobjects for which data collection is enabled(package private) org.springframework.http.ResponseEntity<Void> API endpoint for disabling weather data tracking for aCityobject(package private) org.springframework.http.ResponseEntity<CityResponse> enable(AddCityRequest addCityRequest) API endpoint for adding and / or enabling weather data tracking for aCityobject(package private) org.springframework.http.ResponseEntity<CityResponse> API endpoint for retrieving information about a singleCityobject(package private) org.springframework.http.ResponseEntity<WeatherResponse> API endpoint for requesting the most recent weather data linked to aCityobject
-
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 allCityobjects for which data collection is enabled- Returns:
- list of
CityResponseobjects representing allCityobjects 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 aCityobject- Parameters:
addCityRequest- request body (city name)- Returns:
- a
CityResponseobject representing the added / enabledCityobject
-
one
@GetMapping("/{id}") org.springframework.http.ResponseEntity<CityResponse> one(@PathVariable Long id) API endpoint for retrieving information about a singleCityobject- Parameters:
id- theCityobject'sid- Returns:
- a
CityResponseobject representing the selectedCityobject
-
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 aCityobject- Parameters:
id- theCityobject'sid- Returns:
- the DTO of latest recorded
WeatherDataobject
-