Implements getting the team info for a Hunter in a Hunt
This commit is contained in:
@@ -41,6 +41,14 @@ class TeamService(
|
||||
.elementAt(0)
|
||||
}
|
||||
|
||||
fun getTeamForHunterInHunt(huntId: HuntId, email: String): Team {
|
||||
val hunter = hunterRepository.findByEmail(email) ?: throw NotFoundException("No hunter with email $email found")
|
||||
val hunterTeamIds = hunterTeamRepository.findByHunterId(hunter.id).map { it.teamId }.toSet()
|
||||
return getTeamsForHunt(huntId)
|
||||
.firstOrNull { it.id in hunterTeamIds }
|
||||
?: throw NotFoundException("No team found for hunter $email in hunt $huntId")
|
||||
}
|
||||
|
||||
fun joinTeam(teamId: TeamId, email: String) {
|
||||
val hunter = hunterRepository.findByEmail(email) ?: throw NotFoundException("No hunter with email $email found")
|
||||
hunterTeamRepository.save(HunterTeamRecord(UUID.randomUUID(), hunter.id, teamId))
|
||||
|
||||
Reference in New Issue
Block a user