Commit d26f5bb0 authored by Jiri Novotny's avatar Jiri Novotny
Browse files

Add facade countryGetAll

parent afe37773
......@@ -2,8 +2,10 @@ package cz.muni.fi.pa165.facade;
import cz.muni.fi.pa165.dto.CountryDetailDto;
import cz.muni.fi.pa165.dto.CountryNameDto;
import org.springframework.data.domain.Page;
public interface CountryFacade {
CountryNameDto getCountryName(Long missionId);
CountryDetailDto getCountryDetail(Long missionId);
Page<CountryNameDto> getAllCountries(int page, int pageSize);
}
......@@ -5,8 +5,12 @@ import cz.muni.fi.pa165.config.CountryNameMapper;
import cz.muni.fi.pa165.dto.CountryDetailDto;
import cz.muni.fi.pa165.dto.CountryNameDto;
import cz.muni.fi.pa165.entity.Country;
import cz.muni.fi.pa165.service.CountryService;
import cz.muni.fi.pa165.service.MissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
/**
......@@ -15,13 +19,15 @@ import org.springframework.stereotype.Service;
@Service
public class CountryFacadeImpl implements CountryFacade {
private final MissionService missionService;
private final CountryService countryService;
private final CountryNameMapper countryNameMapper;
private final CountryDetailMapper countryDetailMapper;
@Autowired
public CountryFacadeImpl(MissionService missionService, CountryNameMapper countryNameMapper, CountryDetailMapper countryDetailMapper) {
public CountryFacadeImpl(MissionService missionService, CountryService countryService, CountryNameMapper countryNameMapper, CountryDetailMapper countryDetailMapper) {
this.missionService = missionService;
this.countryService = countryService;
this.countryNameMapper = countryNameMapper;
this.countryDetailMapper = countryDetailMapper;
}
......@@ -39,4 +45,12 @@ public class CountryFacadeImpl implements CountryFacade {
return countryDetailMapper.map(country);
}
@Override
public Page<CountryNameDto> getAllCountries(int page, int pageSize) {
Pageable pageable = PageRequest.of(page, pageSize);
Page<Country> countries = countryService.findAll(pageable);
return countries.map(countryNameMapper::map);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment