From e71454f3d420d675df3ee6636141515f3a363349 Mon Sep 17 00:00:00 2001 From: Akito123321 Date: Mon, 17 Jun 2024 22:19:34 +0200 Subject: [PATCH] fix playerType profile endpoint --- .../valoStrats/rest/controller/GroupRestAPI.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/akito123321/valoStrats/rest/controller/GroupRestAPI.java b/src/main/java/me/akito123321/valoStrats/rest/controller/GroupRestAPI.java index 522f46f..8808d38 100644 --- a/src/main/java/me/akito123321/valoStrats/rest/controller/GroupRestAPI.java +++ b/src/main/java/me/akito123321/valoStrats/rest/controller/GroupRestAPI.java @@ -563,7 +563,7 @@ public class GroupRestAPI { return ResponseEntity.ok(group); } - @PutMapping("/{id}/strat/{stratId}/player-type/{playerTypeId}profile/{profileId}") //TODO remove privius from playerType and create new and add to group if not existend in group + @PutMapping("/{id}/strat/{stratId}/player-type/{playerTypeId}profile/{profileId}") public ResponseEntity editProfile(@PathVariable String id, @PathVariable String stratId, @PathVariable String playerTypeId, @PathVariable String profileId, @RequestBody ProfileRequest newProfile) { StratsUser user = getUser(); @@ -582,13 +582,8 @@ public class GroupRestAPI { return ResponseEntity.badRequest().build(); } - profile.setName(newProfile.name()); - profile.setImage(newProfile.image()); - - profileService.saveProfile(profile); - playerTypeService.savePlayerType(playerType); - stratService.saveStrat(strat); - groupService.saveGroup(group); + removeProfile(id, stratId, playerTypeId, profileId); + addProfile(id, stratId, playerTypeId, newProfile); return ResponseEntity.ok(group); }