minor refactor

This commit is contained in:
2025-12-19 15:41:44 +01:00
parent e34fa841bc
commit 5280ebd764

View File

@@ -1,6 +1,5 @@
package de.pnreichmuth.timekeep_backend.services;
import de.pnreichmuth.timekeep_backend.entities.Racer;
import de.pnreichmuth.timekeep_backend.entities.Team;
import de.pnreichmuth.timekeep_backend.exceptions.TeamExistsException;
import de.pnreichmuth.timekeep_backend.exceptions.TeamNotFoundException;
@@ -20,7 +19,6 @@ import java.util.UUID;
@RequiredArgsConstructor
public class TeamService {
private final TeamRepository teamRepository;
private final RacerRepository racerRepository;
private void checkTeamIsDuplicate(Team team) throws TeamExistsException {
List<Team> teams = teamRepository.findAll();
@@ -30,12 +28,14 @@ public class TeamService {
}
public Team getTeam(UUID id){
return teamRepository.findById(id).orElse(null);
Team team = teamRepository.findById(id).orElse(null);
if(team == null) throw new TeamNotFoundException("Team with id "+id+" not found");
return team;
}
public Team getTeam(String name){
Team team = teamRepository.getTeamByTeamName(name).orElse(null);
if(team == null) throw new TeamNotFoundException("Team "+name+" not found");
if(team == null) throw new TeamNotFoundException("Team with name "+name+" not found");
return team;
}