fix: Entry renamed to Average

This commit is contained in:
Piotr Dec 2024-07-18 02:36:59 +02:00
parent 625dd63137
commit f63604a18a
Signed by: stawros
GPG key ID: F89F27AD8F881A91
4 changed files with 8 additions and 8 deletions

View file

@ -3,7 +3,7 @@
"$schema": "http://json-schema.org/draft/2020-12/schema", "$schema": "http://json-schema.org/draft/2020-12/schema",
"type": "array", "type": "array",
"def": { "def": {
"entry": { "average": {
"type": "object", "type": "object",
"properties": { "properties": {
"year": { "year": {
@ -20,6 +20,6 @@
} }
}, },
"items": { "items": {
"$ref": "#/def/entry" "$ref": "#/def/average"
} }
} }

View file

@ -1,6 +1,6 @@
package eu.ztsh.lfr.core; package eu.ztsh.lfr.core;
import eu.ztsh.lfr.model.Entry; import eu.ztsh.lfr.model.Average;
import jakarta.annotation.Nonnull; import jakarta.annotation.Nonnull;
import java.util.List; import java.util.List;
@ -8,6 +8,6 @@ import java.util.List;
public interface TemperaturesService { public interface TemperaturesService {
@Nonnull @Nonnull
List<Entry> getTemperaturesFor(String city); List<Average> getTemperaturesFor(String city);
} }

View file

@ -1,7 +1,7 @@
package eu.ztsh.lfr.core.impl; package eu.ztsh.lfr.core.impl;
import eu.ztsh.lfr.core.TemperaturesService; import eu.ztsh.lfr.core.TemperaturesService;
import eu.ztsh.lfr.model.Entry; import eu.ztsh.lfr.model.Average;
import jakarta.annotation.Nonnull; import jakarta.annotation.Nonnull;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -12,7 +12,7 @@ public class TemperaturesServiceImpl implements TemperaturesService {
@Nonnull @Nonnull
@Override @Override
public List<Entry> getTemperaturesFor(String city) { public List<Average> getTemperaturesFor(String city) {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }

View file

@ -1,7 +1,7 @@
package eu.ztsh.lfr.web; package eu.ztsh.lfr.web;
import eu.ztsh.lfr.core.TemperaturesService; import eu.ztsh.lfr.core.TemperaturesService;
import eu.ztsh.lfr.model.Entry; import eu.ztsh.lfr.model.Average;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -23,7 +23,7 @@ public class TemperaturesController {
} }
@GetMapping("/{city}") @GetMapping("/{city}")
public ResponseEntity<List<Entry>> getTemperatures(@PathVariable String city) { public ResponseEntity<List<Average>> getTemperatures(@PathVariable String city) {
var data = temperaturesService.getTemperaturesFor(city); var data = temperaturesService.getTemperaturesFor(city);
return data.isEmpty() ? ResponseEntity.notFound().build() : ResponseEntity.ok(data); return data.isEmpty() ? ResponseEntity.notFound().build() : ResponseEntity.ok(data);