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

Add facade skillGetAll

parent d26f5bb0
......@@ -3,6 +3,7 @@ package cz.muni.fi.pa165.facade;
import cz.muni.fi.pa165.dto.AgentCountDto;
import cz.muni.fi.pa165.dto.AgentDetailDto;
import cz.muni.fi.pa165.dto.AgentListDto;
import cz.muni.fi.pa165.dto.SkillDto;
import org.springframework.data.domain.Page;
public interface AgentFacade {
......@@ -12,4 +13,5 @@ public interface AgentFacade {
Page<AgentListDto> getAgentWithSkill(String skill, int page, int pageSize);
Page<AgentListDto> getAgentWithCountryXp(Long countryId, int page, int pageSize);
Page<AgentListDto> getAllAgents(int page, int pageSize);
Page<SkillDto> getAllSkills(int page, int pageSize);
}
......@@ -2,9 +2,11 @@ package cz.muni.fi.pa165.facade;
import cz.muni.fi.pa165.config.AgentDetailMapper;
import cz.muni.fi.pa165.config.AgentListMapper;
import cz.muni.fi.pa165.config.SkillMapper;
import cz.muni.fi.pa165.dto.AgentCountDto;
import cz.muni.fi.pa165.dto.AgentDetailDto;
import cz.muni.fi.pa165.dto.AgentListDto;
import cz.muni.fi.pa165.dto.SkillDto;
import cz.muni.fi.pa165.entity.*;
import cz.muni.fi.pa165.service.AgentService;
import cz.muni.fi.pa165.service.CountryService;
......@@ -35,15 +37,17 @@ public class AgentFacadeImpl implements AgentFacade {
private final AgentDetailMapper agentDetailMapper;
private final AgentListMapper agentListMapper;
private final SkillMapper skillMapper;
@Autowired
public AgentFacadeImpl(AgentService agentService, MissionService missionService, CountryService countryService, SkillService skillService, AgentDetailMapper agentDetailMapper, AgentListMapper agentListMapper) {
public AgentFacadeImpl(AgentService agentService, MissionService missionService, CountryService countryService, SkillService skillService, AgentDetailMapper agentDetailMapper, AgentListMapper agentListMapper, SkillMapper skillMapper) {
this.agentService = agentService;
this.missionService = missionService;
this.countryService = countryService;
this.skillService = skillService;
this.agentDetailMapper = agentDetailMapper;
this.agentListMapper = agentListMapper;
this.skillMapper = skillMapper;
}
@Override
......@@ -120,6 +124,14 @@ public class AgentFacadeImpl implements AgentFacade {
return agents.map(agentListMapper::map);
}
@Override
public Page<SkillDto> getAllSkills(int page, int pageSize) {
Pageable pageable = PageRequest.of(page, pageSize);
Page<Skill> skills = skillService.findAll(pageable);
return skills.map(skillMapper::map);
}
private Page<AgentListDto> createPage(List<Agent> agents, Pageable pageable) {
List<AgentListDto> mappedAgents = agents.stream().map(agentListMapper::map).collect(Collectors.toList());
final int start = (int) pageable.getOffset();
......
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