mirror of
https://github.com/PaulReichmuth/timekeep-backend.git
synced 2025-12-22 14:41:57 +00:00
minor refactor
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user