package de.avatic.taric.service;

import de.avatic.taric.model.Geo;
import de.avatic.taric.model.GeoGroup;
import de.avatic.taric.repository.GeoGroupRepository;
import de.avatic.taric.repository.GeoRepository;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class GeoService {

    private final GeoGroupRepository geoGroupRepository;
    private final GeoRepository geoRepository;

    public GeoService(GeoGroupRepository geoGroupRepository, GeoRepository geoRepository) {
        this.geoGroupRepository = geoGroupRepository;
        this.geoRepository = geoRepository;
    }

    public Optional<Geo> getGeo(String countryCode) {
        return geoRepository.findByIso3166Code(countryCode);
    }

    public List<GeoGroup> getGeoGroupByCountryCode(String countryCode) {
        return geoGroupRepository.findByCountryCode(countryCode);
    }

    public List<GeoGroup> getGeoGroup(String abbr) {
        return geoGroupRepository.findByAbbr(abbr);
    }
}
