Skip to content
Snippets Groups Projects
Commit ad5c265e authored by Ján Dovjak's avatar Ján Dovjak
Browse files

feat: GetFreePlayers created

parent 1d3f1a8b
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ package cz.muni.fi.pa165.icehockeymanager.facades; ...@@ -2,6 +2,7 @@ package cz.muni.fi.pa165.icehockeymanager.facades;
import cz.muni.fi.pa165.icehockeymanager.dto.PlayerCreateDTO; import cz.muni.fi.pa165.icehockeymanager.dto.PlayerCreateDTO;
import cz.muni.fi.pa165.icehockeymanager.dto.PlayerDTO; import cz.muni.fi.pa165.icehockeymanager.dto.PlayerDTO;
import cz.muni.fi.pa165.icehockeymanager.dto.TeamDTO;
import cz.muni.fi.pa165.icehockeymanager.exceptions.UnknownPlayerException; import cz.muni.fi.pa165.icehockeymanager.exceptions.UnknownPlayerException;
import cz.muni.fi.pa165.icehockeymanager.exceptions.UnknownTeamException; import cz.muni.fi.pa165.icehockeymanager.exceptions.UnknownTeamException;
import cz.muni.fi.pa165.icehockeymanager.model.Player; import cz.muni.fi.pa165.icehockeymanager.model.Player;
...@@ -53,7 +54,8 @@ public class TeamManagerFacadeImpl implements TeamManagerFacade{ ...@@ -53,7 +54,8 @@ public class TeamManagerFacadeImpl implements TeamManagerFacade{
@Override @Override
public Collection<PlayerDTO> getFreePlayers() { public Collection<PlayerDTO> getFreePlayers() {
return null; var players = playerService.getFreePlayers();
return beanMappingService.mapTo(players, PlayerDTO.class);
} }
@Override @Override
......
package cz.muni.fi.pa165.icehockeymanager.services; package cz.muni.fi.pa165.icehockeymanager.services;
import cz.muni.fi.pa165.icehockeymanager.dto.PlayerDTO;
import cz.muni.fi.pa165.icehockeymanager.model.Player; import cz.muni.fi.pa165.icehockeymanager.model.Player;
import cz.muni.fi.pa165.icehockeymanager.model.Team; import cz.muni.fi.pa165.icehockeymanager.model.Team;
import java.util.Collection;
import java.util.Optional; import java.util.Optional;
/** /**
...@@ -19,4 +21,6 @@ public interface PlayerService { ...@@ -19,4 +21,6 @@ public interface PlayerService {
Optional<Player> findPlayer(long id); Optional<Player> findPlayer(long id);
void createPlayer(Player player, Team team); void createPlayer(Player player, Team team);
Collection<Player> getFreePlayers();
} }
...@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import java.util.Collection;
import java.util.Optional; import java.util.Optional;
@Service @Service
...@@ -29,4 +30,9 @@ public class PlayerServiceImpl implements PlayerService { ...@@ -29,4 +30,9 @@ public class PlayerServiceImpl implements PlayerService {
player.setTeam(team); player.setTeam(team);
playerDao.create(player); playerDao.create(player);
} }
@Override
public Collection<Player> getFreePlayers() {
return playerDao.getAllFreePlayers();
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment