feat: Averages update in Temperatures service
This commit is contained in:
parent
770ccf63a5
commit
1afff3819b
1 changed files with 12 additions and 0 deletions
|
@ -2,7 +2,10 @@ package eu.ztsh.lfr.core.impl;
|
||||||
|
|
||||||
import eu.ztsh.lfr.core.TemperaturesService;
|
import eu.ztsh.lfr.core.TemperaturesService;
|
||||||
import eu.ztsh.lfr.model.Average;
|
import eu.ztsh.lfr.model.Average;
|
||||||
|
import eu.ztsh.lfr.model.Averages;
|
||||||
|
import eu.ztsh.lfr.model.events.FileProcessedEvent;
|
||||||
import jakarta.annotation.Nonnull;
|
import jakarta.annotation.Nonnull;
|
||||||
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -10,10 +13,19 @@ import java.util.List;
|
||||||
@Service
|
@Service
|
||||||
public class TemperaturesServiceImpl implements TemperaturesService {
|
public class TemperaturesServiceImpl implements TemperaturesService {
|
||||||
|
|
||||||
|
private Averages averages;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public List<Average> getTemperaturesFor(String city) {
|
public List<Average> getTemperaturesFor(String city) {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventListener(FileProcessedEvent.class)
|
||||||
|
public void updateTemperatures(FileProcessedEvent event) {
|
||||||
|
synchronized (this) {
|
||||||
|
averages = event.averages();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue