From 030eae86fbff510077ebcde2502f500570cf5c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EB=8B=A4=EC=98=88/NSC=EC=8A=A4=ED=8A=9C=EB=94=94?= =?UTF-8?q?=EC=98=A4/NE?= Date: Thu, 4 Jul 2024 15:24:04 +0900 Subject: [PATCH] =?UTF-8?q?feat(team-building):=20=EC=96=B4=EB=93=9C?= =?UTF-8?q?=EB=AF=BC=20=EC=8B=9C=EC=9E=91=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20createdDate=20=ED=95=84=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/ExceptionInfo.java | 1 + .../TeamBuildingAdminController.java | 12 +++++++++++ .../controller/dto/response/UserInfo.java | 3 +++ .../service/TeamBuildingAdminService.java | 21 +++++++++++++++++-- .../service/TeamBuildingAdminServiceTest.java | 12 +++++++++++ 5 files changed, 47 insertions(+), 2 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 ddd5bff..f58823b 100644 --- a/src/main/java/com/nexters/moyeomoyeo/common/constant/ExceptionInfo.java +++ b/src/main/java/com/nexters/moyeomoyeo/common/constant/ExceptionInfo.java @@ -14,6 +14,7 @@ public enum ExceptionInfo { BAD_REQUEST_FOR_USER_PICK("유효하지 않은 유저 선택 요청입니다.", HttpStatus.BAD_REQUEST), ALREADY_JOINED_USER("다른 팀에 배정되어 있는 유저입니다.", HttpStatus.BAD_REQUEST), COMPLETED_TEAM_BUILDING("이미 종료된 팀빌딩입니다.", HttpStatus.BAD_REQUEST), + INVALID_START_REQUEST("시작 라운드에서만 팀빌딩을 시작할 수 있습니다.", HttpStatus.BAD_REQUEST), INVALID_ADJUST_REQUEST("조정 라운드에서만 조정 가능합니다.", HttpStatus.BAD_REQUEST), INVALID_FINISH_REQUEST("조정 라운드에서만 팀빌딩을 종료할 수 있습니다.", HttpStatus.BAD_REQUEST), INVALID_DELETE_REQUEST("1라운드에서만 회원을 삭제할 수 있습니다.", HttpStatus.BAD_REQUEST), 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 e875482..aa06c72 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 @@ -77,4 +77,16 @@ public ResponseEntity finishTeamBuilding(@PathVariable(value = "teamBuildi .header("X-Accel-Buffering", "no") .build(); } + + @Operation(summary = "팀 빌딩 시작하기", description = """ + 운영진이 START 단계에서 팀빌딩을 시작합니다. \s + event : start-team-building, data : RoundStatus(FIRST_ROUND) \s + """) + @PutMapping("/{teamBuildingUuid}/start") + public ResponseEntity startTeamBuilding(@PathVariable(value = "teamBuildingUuid") String teamBuildingUuid) { + adminService.startTeamBuilding(teamBuildingUuid); + return ResponseEntity.ok() + .header("X-Accel-Buffering", "no") + .build(); + } } diff --git a/src/main/java/com/nexters/moyeomoyeo/team_building/controller/dto/response/UserInfo.java b/src/main/java/com/nexters/moyeomoyeo/team_building/controller/dto/response/UserInfo.java index 67d5d2b..663a70d 100644 --- a/src/main/java/com/nexters/moyeomoyeo/team_building/controller/dto/response/UserInfo.java +++ b/src/main/java/com/nexters/moyeomoyeo/team_building/controller/dto/response/UserInfo.java @@ -4,6 +4,7 @@ import com.nexters.moyeomoyeo.team_building.domain.constant.RoundStatus; import com.nexters.moyeomoyeo.team_building.domain.entity.User; import io.swagger.v3.oas.annotations.media.Schema; +import java.time.LocalDateTime; import java.util.List; import java.util.Objects; import lombok.AccessLevel; @@ -32,6 +33,7 @@ public class UserInfo { private String profileLink; @Schema(description = "선택받은 라운드") private RoundStatus selectedRound; + private LocalDateTime createdDate; public static UserInfo makeUserInfo(User user) { @@ -45,6 +47,7 @@ public static UserInfo makeUserInfo(User user) { .joinedTeamUuid(joinedTeamUuid) .profileLink(user.getProfileLink()) .selectedRound(user.getSelectedRound()) + .createdDate(user.getCreatedDate()) .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 4d4cb82..fe2c967 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 @@ -73,15 +73,32 @@ public void deleteTeamBuildingUser(String uuid, String userUuid) { @Transactional public void finishTeamBuilding(String uuid) { final TeamBuilding teamBuilding = findByUuid(uuid); - if (RoundStatus.ADJUSTED_ROUND != teamBuilding.getRoundStatus()) { throw ExceptionInfo.INVALID_FINISH_REQUEST.exception(); } - teamBuilding.nextRound(); + moveAllRoundStatus(teamBuilding); notificationService.broadcast(teamBuilding.getUuid(), "finish-team-building", teamBuilding.getRoundStatus()); } + @Transactional + public void startTeamBuilding(String teamBuildingUuid) { + final TeamBuilding teamBuilding = findByUuid(teamBuildingUuid); + if (RoundStatus.START != teamBuilding.getRoundStatus()) { + throw ExceptionInfo.INVALID_FINISH_REQUEST.exception(); + } + + moveAllRoundStatus(teamBuilding); + notificationService.broadcast(teamBuilding.getUuid(), "start-team-building", teamBuilding.getRoundStatus()); + } + + private void moveAllRoundStatus(TeamBuilding teamBuilding) { + teamBuilding.nextRound(); + for (Team team : teamBuilding.getTeams()) { + team.nextRound(); + } + } + @Transactional public TeamBuildingResponse createTeamBuilding(TeamBuildingRequest teamBuildingRequest) { diff --git a/src/test/java/com/nexters/moyeomoyeo/team_building/service/TeamBuildingAdminServiceTest.java b/src/test/java/com/nexters/moyeomoyeo/team_building/service/TeamBuildingAdminServiceTest.java index 73b3f1a..4775bb6 100644 --- a/src/test/java/com/nexters/moyeomoyeo/team_building/service/TeamBuildingAdminServiceTest.java +++ b/src/test/java/com/nexters/moyeomoyeo/team_building/service/TeamBuildingAdminServiceTest.java @@ -125,5 +125,17 @@ void finishTeamBuilding() { sut.finishTeamBuilding(teamBuilding.getUuid()); assertThat(teamBuilding.getRoundStatus()).isEqualTo(RoundStatus.COMPLETE); + assertThat(teamBuilding.getTeams().get(0).getRoundStatus()).isEqualTo(RoundStatus.COMPLETE); + } + + @Test + @Transactional + void startTeamBuilding() { + final TeamBuilding teamBuilding = teamBuildingRepository.save(FixtureTeamBuilding.teamBuilding(RoundStatus.START)); + + sut.startTeamBuilding(teamBuilding.getUuid()); + + assertThat(teamBuilding.getRoundStatus()).isEqualTo(RoundStatus.FIRST_ROUND); + assertThat(teamBuilding.getTeams().get(0).getRoundStatus()).isEqualTo(RoundStatus.FIRST_ROUND); } }