refactor pure objects as request body into WSTOs

This commit is contained in:
2026-02-04 21:14:41 +01:00
parent 41fda9770a
commit a87a5a6198
3 changed files with 30 additions and 23 deletions

View File

@@ -5,6 +5,7 @@ import de.pnreichmuth.timekeep_backend.entities.Team;
import de.pnreichmuth.timekeep_backend.exceptions.ExistsException;
import de.pnreichmuth.timekeep_backend.exceptions.NotFoundException;
import de.pnreichmuth.timekeep_backend.services.TeamService;
import de.pnreichmuth.timekeep_backend.wsto.RacerWSTO;
import de.pnreichmuth.timekeep_backend.wsto.TeamWSTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -23,9 +24,10 @@ public class TeamMemberRestController {
// ///////////////////////////////////////////////BEGIN POST MAPPINGS///////////////////////////////////////////////////
@PostMapping("/addMemberToTeam")
public ResponseEntity<?> addMemberToTeam(@RequestParam("teamName") String teamName, @RequestBody Racer racer) {
public ResponseEntity<?> addMemberToTeam(@RequestParam("teamName") String teamName, @RequestBody RacerWSTO racerWsto) {
Team mockTeam = new Team();
mockTeam.setTeamName(teamName);
Racer racer = RacerWSTO.toEntity(racerWsto);
try{
this.teamService.addMember(mockTeam,racer);
}
@@ -39,9 +41,10 @@ public class TeamMemberRestController {
}
// ///////////////////////////////////////////////BEGIN DELETE MAPPINGS///////////////////////////////////////////////////
@DeleteMapping("/removeMemberFromTeam")
public ResponseEntity<?> removeMemberFromTeam(@RequestParam("teamName") String teamName, @RequestBody Racer racer) {
public ResponseEntity<?> removeMemberFromTeam(@RequestParam("teamName") String teamName, @RequestBody RacerWSTO racerWsto) {
Team mockTeam = new Team();
mockTeam.setTeamName(teamName);
Racer racer = RacerWSTO.toEntity(racerWsto);
try{
this.teamService.removeMember(mockTeam,racer);
}