package eu.ztsh.lfr.web; import eu.ztsh.lfr.core.TemperaturesService; import eu.ztsh.lfr.model.Average; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; @RestController @RequestMapping("/api/temperatures") public class TemperaturesController { private final TemperaturesService temperaturesService; @Autowired public TemperaturesController(TemperaturesService temperaturesService) { this.temperaturesService = temperaturesService; } @GetMapping("/{city}") public ResponseEntity> getTemperatures(@PathVariable String city) { var data = temperaturesService.getTemperaturesFor(city); return data.isEmpty() ? ResponseEntity.notFound().build() : ResponseEntity.ok(data); } }