예외 적용하기
Delete
@DeleteMapping("/{id}")
public void deleteTeam(@PathVariable long id) {
TeamDTO teamDTO = teamService.getTeamById(id);
if(teamDTO == null) {
throw new TeamNotFoundException("Team not found with id: " + id);
}
teamService.deleteTeam(id);
}
Update
@PutMapping("/{id}")
public TeamDTO updateTeam(@PathVariable long id, TeamDTO team) {
TeamDTO teamDTO = teamService.getTeamById(id);
if(teamDTO == null) {
throw new TeamNotFoundException("Team not found with id: " + id);
}
return teamService.updateTeam(id, team);
}
Delete
@DeleteMapping("/{id}")
public void deleteTeam(@PathVariable long id) {
TeamDTO teamDTO = teamService.getTeamById(id);
if(teamDTO == null) {
throw new TeamNotFoundException("Team not found with id: " + id);
}
teamService.deleteTeam(id);
}
- 다음과 같이 조회를 한 후, 예외를 적용하였다.