Compare commits

..

2 Commits

Author SHA1 Message Date
3baea70356 Added TournamentRegistration.active
All checks were successful
Gitea/swiss-backend/pipeline/head This commit looks good
2025-08-15 09:31:27 +02:00
e154c7e4d7 Send 400 instead of 500 when tournament failes to save 2025-08-15 09:30:25 +02:00
4 changed files with 6 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ import nl.connectedit.swiss.service.*;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.time.format.DateTimeParseException;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@@ -68,7 +69,7 @@ public class TournamentController {
Tournament tournament; Tournament tournament;
try { try {
tournament = tournamentMapper.toEntity(tournamentDto); tournament = tournamentMapper.toEntity(tournamentDto);
} catch (NullPointerException e) { } catch (NullPointerException | DateTimeParseException e) {
return ResponseEntity.badRequest().build(); return ResponseEntity.badRequest().build();
} }
return ResponseEntity.ok(tournamentMapper.toDto(tournamentService.saveTournament(tournament))); return ResponseEntity.ok(tournamentMapper.toDto(tournamentService.saveTournament(tournament)));

View File

@@ -11,7 +11,6 @@ import nl.connectedit.swiss.domain.TournamentStatus;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -37,7 +36,7 @@ public class Tournament extends AbstractEntity {
private TournamentStatus status; private TournamentStatus status;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<Event> events;// = new ArrayList<>(); private List<Event> events;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<TournamentPlayer> tournamentPlayers; private List<TournamentPlayer> tournamentPlayers;

View File

@@ -21,5 +21,7 @@ public class TournamentRegistrationDto extends AbstractDto {
private String status; private String status;
private Boolean active;
private List<EventRegistrationDto> events; private List<EventRegistrationDto> events;
} }

View File

@@ -31,6 +31,7 @@ public class TournamentPlayerRegistrationMapper {
tournamentRegistrationDto.setEditable(tournament.getStatus() == TournamentStatus.UPCOMING); tournamentRegistrationDto.setEditable(tournament.getStatus() == TournamentStatus.UPCOMING);
tournamentRegistrationDto.setDate(tournament.getDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"))); tournamentRegistrationDto.setDate(tournament.getDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")));
tournamentRegistrationDto.setStatus(tournament.getStatus().name()); tournamentRegistrationDto.setStatus(tournament.getStatus().name());
tournamentRegistrationDto.setActive(tournament.getActive());
tournamentRegistrationDto.setEvents( tournamentRegistrationDto.setEvents(
tournament.getEvents() tournament.getEvents()
.stream() .stream()