Skip to content

Commit

Permalink
feat(team-building): 어드민 시작 기능 추가 및 createdDate 필드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
박다예/NSC스튜디오/NE committed Jul 4, 2024
1 parent df87130 commit 030eae8
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,16 @@ public ResponseEntity<Void> 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<Void> startTeamBuilding(@PathVariable(value = "teamBuildingUuid") String teamBuildingUuid) {
adminService.startTeamBuilding(teamBuildingUuid);
return ResponseEntity.ok()
.header("X-Accel-Buffering", "no")
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -32,6 +33,7 @@ public class UserInfo {
private String profileLink;
@Schema(description = "선택받은 라운드")
private RoundStatus selectedRound;
private LocalDateTime createdDate;


public static UserInfo makeUserInfo(User user) {
Expand All @@ -45,6 +47,7 @@ public static UserInfo makeUserInfo(User user) {
.joinedTeamUuid(joinedTeamUuid)
.profileLink(user.getProfileLink())
.selectedRound(user.getSelectedRound())
.createdDate(user.getCreatedDate())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 030eae8

Please sign in to comment.