From 1439f5ff4d5a8fd33dfda3db54a49d569b6169a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=97=88=EC=88=98=EC=A7=84/=ED=9A=8C=EC=9B=90=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=ED=8C=80?= Date: Thu, 17 Aug 2023 23:02:04 +0900 Subject: [PATCH] =?UTF-8?q?1=EB=9D=BC=EC=9A=B4=EB=93=9C=EC=97=90=EC=84=9C?= =?UTF-8?q?=EB=A7=8C=20=ED=8C=80=EC=9B=90=20=EC=82=AD=EC=A0=9C=20=EA=B0=80?= =?UTF-8?q?=EB=8A=A5=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../moyeomoyeo/common/constant/ExceptionInfo.java | 1 + .../controller/TeamBuildingAdminController.java | 6 +++--- .../service/TeamBuildingAdminService.java | 12 ++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/nexters/moyeomoyeo/common/constant/ExceptionInfo.java b/src/main/java/com/nexters/moyeomoyeo/common/constant/ExceptionInfo.java index 74055a1..5d1ce79 100644 --- a/src/main/java/com/nexters/moyeomoyeo/common/constant/ExceptionInfo.java +++ b/src/main/java/com/nexters/moyeomoyeo/common/constant/ExceptionInfo.java @@ -16,6 +16,7 @@ public enum ExceptionInfo { COMPLETED_TEAM_BUILDING("이미 종료된 팀빌딩입니다.", HttpStatus.BAD_REQUEST), INVALID_ADJUST_REQUEST("조정 라운드에서만 조정 가능합니다.", HttpStatus.BAD_REQUEST), INVALID_FINISH_REQUEST("조정 라운드에서만 팀빌딩을 종료할 수 있습니다.", HttpStatus.BAD_REQUEST), + INVALID_DELETE_REQUEST("1라운드에서만 회원을 삭제할 수 있습니다.", HttpStatus.BAD_REQUEST), DUPLICATED_PICK_REQUEST("이미 선택이 완료된 팀입니다.", HttpStatus.BAD_REQUEST); @Getter private final String message; diff --git a/src/main/java/com/nexters/moyeomoyeo/team_building/controller/TeamBuildingAdminController.java b/src/main/java/com/nexters/moyeomoyeo/team_building/controller/TeamBuildingAdminController.java index a37c215..b6d0809 100644 --- a/src/main/java/com/nexters/moyeomoyeo/team_building/controller/TeamBuildingAdminController.java +++ b/src/main/java/com/nexters/moyeomoyeo/team_building/controller/TeamBuildingAdminController.java @@ -48,7 +48,7 @@ public ResponseEntity createTeamBuilding( """) @PostMapping("/{teamBuildingUuid}/users/{userUuid}") public ResponseEntity adjustUser(@PathVariable(value = "teamBuildingUuid") String teamBuildingUuid, - @PathVariable(value = "userUuid") String userUuid, @RequestBody @Valid UserAdjustRequest userAdjustRequest) { + @PathVariable(value = "userUuid") String userUuid, @RequestBody @Valid UserAdjustRequest userAdjustRequest) { return ResponseEntity.ok(adminService.adjustUser(teamBuildingUuid, userUuid, userAdjustRequest.getTeamUuid())); } @@ -58,8 +58,8 @@ public ResponseEntity adjustUser(@PathVariable(value = "teamBuildingUu """) @DeleteMapping("/{teamBuildingUuid}/users/{userUuid}") public ResponseEntity deleteUser(@PathVariable(value = "teamBuildingUuid") String teamBuildingUuid, - @PathVariable(value = "userUuid") String userUuid) { - userService.deleteUser(teamBuildingUuid, userUuid); + @PathVariable(value = "userUuid") String userUuid) { + adminService.deleteTeamBuildingUser(teamBuildingUuid, userUuid); return ResponseEntity.ok().build(); } diff --git a/src/main/java/com/nexters/moyeomoyeo/team_building/service/TeamBuildingAdminService.java b/src/main/java/com/nexters/moyeomoyeo/team_building/service/TeamBuildingAdminService.java index 4eb52fa..57c2573 100644 --- a/src/main/java/com/nexters/moyeomoyeo/team_building/service/TeamBuildingAdminService.java +++ b/src/main/java/com/nexters/moyeomoyeo/team_building/service/TeamBuildingAdminService.java @@ -15,8 +15,10 @@ import com.nexters.moyeomoyeo.team_building.domain.entity.Team; import com.nexters.moyeomoyeo.team_building.domain.entity.TeamBuilding; import com.nexters.moyeomoyeo.team_building.domain.entity.User; + import java.util.List; import java.util.Objects; + import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -51,6 +53,16 @@ public UserInfo adjustUser(String teamBuildingUuid, String userUuid, String team } + @Transactional + public void deleteTeamBuildingUser(String uuid, String userUuid) { + final TeamBuilding teamBuilding = teamBuildingService.findByUuid(uuid); + + if (RoundStatus.FIRST_ROUND != teamBuilding.getRoundStatus()) { + throw ExceptionInfo.INVALID_DELETE_REQUEST.exception(); + } + userService.deleteUser(uuid, userUuid); + } + @Transactional public void finishTeamBuilding(String uuid) { final TeamBuilding teamBuilding = teamBuildingService.findByUuid(uuid);