Implements getting the team info for a Hunter in a Hunt

This commit is contained in:
2026-05-13 00:08:08 -05:00
parent b2ba9ce676
commit 46132bb4fd
3 changed files with 13 additions and 2 deletions

View File

@@ -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))