mirror of
https://github.com/PaulReichmuth/timekeep-backend.git
synced 2026-02-06 04:53:25 +00:00
fix duplicate teams still being allowed
This commit is contained in:
@@ -37,11 +37,13 @@ public class TeamRestController {
|
||||
|
||||
@PostMapping("createTeamDebug")
|
||||
public ResponseEntity<@NonNull TeamWSTO> createTeam(){
|
||||
Team team = teamService.createTeam();
|
||||
try {
|
||||
Team team = teamService.createTeam();
|
||||
team.setTeamName("DEBUG");
|
||||
teamService.updateTeam(team);
|
||||
return new ResponseEntity<>(TeamWSTO.of(team), HttpStatus.CREATED);
|
||||
} catch (TeamExistsException e) {
|
||||
teamService.deleteTeam(team.getId());
|
||||
return ResponseEntity.of(ProblemDetail.forStatusAndDetail(HttpStatus.CONFLICT,"This team already exists")).build();
|
||||
}
|
||||
}
|
||||
@@ -76,8 +78,8 @@ public class TeamRestController {
|
||||
}
|
||||
catch(TeamNotFoundException e){
|
||||
if(id != null) return ResponseEntity.of(ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND,"Team with id "+ id +" not found")).build();
|
||||
else if (name != null) return ResponseEntity.of(ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND,"Team with name "+ name +" not found")).build();
|
||||
else return ResponseEntity.of(ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, "Must provide either id or name.")).build();
|
||||
if (name != null) return ResponseEntity.of(ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND,"Team with name "+ name +" not found")).build();
|
||||
return ResponseEntity.of(ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, "Must provide either id or name.")).build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user