mirror of
https://github.com/PaulReichmuth/timekeep-backend.git
synced 2025-12-22 22:41:59 +00:00
minor refactor
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package de.pnreichmuth.timekeep_backend.services;
|
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.entities.Team;
|
||||||
import de.pnreichmuth.timekeep_backend.exceptions.TeamExistsException;
|
import de.pnreichmuth.timekeep_backend.exceptions.TeamExistsException;
|
||||||
import de.pnreichmuth.timekeep_backend.exceptions.TeamNotFoundException;
|
import de.pnreichmuth.timekeep_backend.exceptions.TeamNotFoundException;
|
||||||
@@ -20,7 +19,6 @@ import java.util.UUID;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class TeamService {
|
public class TeamService {
|
||||||
private final TeamRepository teamRepository;
|
private final TeamRepository teamRepository;
|
||||||
private final RacerRepository racerRepository;
|
|
||||||
|
|
||||||
private void checkTeamIsDuplicate(Team team) throws TeamExistsException {
|
private void checkTeamIsDuplicate(Team team) throws TeamExistsException {
|
||||||
List<Team> teams = teamRepository.findAll();
|
List<Team> teams = teamRepository.findAll();
|
||||||
@@ -30,12 +28,14 @@ public class TeamService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Team getTeam(UUID id){
|
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){
|
public Team getTeam(String name){
|
||||||
Team team = teamRepository.getTeamByTeamName(name).orElse(null);
|
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;
|
return team;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user