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);