diff --git a/build.gradle b/build.gradle index 905bfdb..674a9c4 100644 --- a/build.gradle +++ b/build.gradle @@ -25,6 +25,7 @@ dependencies { testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' implementation 'org.springdoc:springdoc-openapi-ui:1.6.12' + runtimeOnly 'com.h2database:h2' } tasks.named('test') { diff --git a/src/main/java/com/hyunsolution/dangu/participant/service/ParticipantService.java b/src/main/java/com/hyunsolution/dangu/participant/service/ParticipantService.java index 597dd02..deefe78 100644 --- a/src/main/java/com/hyunsolution/dangu/participant/service/ParticipantService.java +++ b/src/main/java/com/hyunsolution/dangu/participant/service/ParticipantService.java @@ -7,7 +7,6 @@ import com.hyunsolution.dangu.workspace.domain.WorkspaceRepository; import java.util.List; import java.util.NoSuchElementException; -import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -23,23 +22,29 @@ public class ParticipantService { public void changeMatching(Long id, Long workspaceId) { // 상태 변경 Participant participantOptional = - participantRepository.findByUserIdAndWorkspaceId(id, workspaceId) - .orElseThrow(()-> new NoSuchElementException("Participant not found")); + participantRepository + .findByUserIdAndWorkspaceId(id, workspaceId) + .orElseThrow(() -> new NoSuchElementException("Participant not found")); participantOptional.accept(); // participant테이블에서 roomNumber로 들어온 숫자를 통해 누가 있는지 파악 - List participantIds = participantRepository.findParticipantIdByWorkspaceId(workspaceId); + List participantIds = + participantRepository.findParticipantIdByWorkspaceId(workspaceId); // 방안에 모든 참가자가 "확정"버튼을 눌렀는지 확인 for (Long participant : participantIds) { - boolean mathingCheck = participantRepository.existsByIdAndParticipantMatchTrue(participant); + boolean mathingCheck = + participantRepository.existsByIdAndParticipantMatchTrue(participant); if (!mathingCheck) { return; } } // 게임방 테이블 속 매칭 결과를 true로 바꿈 - Workspace workspace1 = workspaceRepository.findById(workspaceId).orElseThrow(()-> new NoSuchElementException("Workspace not found")); + Workspace workspace1 = + workspaceRepository + .findById(workspaceId) + .orElseThrow(() -> new NoSuchElementException("Workspace not found")); workspace1.acceptFinal(); } } diff --git a/src/main/java/com/hyunsolution/dangu/user/domain/UserRepository.java b/src/main/java/com/hyunsolution/dangu/user/domain/UserRepository.java index e1d05ec..d4383dd 100644 --- a/src/main/java/com/hyunsolution/dangu/user/domain/UserRepository.java +++ b/src/main/java/com/hyunsolution/dangu/user/domain/UserRepository.java @@ -1,8 +1,7 @@ package com.hyunsolution.dangu.user.domain; -import org.springframework.data.jpa.repository.JpaRepository; - import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; public interface UserRepository extends JpaRepository { Optional findByUid(String uid); diff --git a/src/main/java/com/hyunsolution/dangu/workspace/domain/Workspace.java b/src/main/java/com/hyunsolution/dangu/workspace/domain/Workspace.java index 9815859..0bd51b6 100644 --- a/src/main/java/com/hyunsolution/dangu/workspace/domain/Workspace.java +++ b/src/main/java/com/hyunsolution/dangu/workspace/domain/Workspace.java @@ -1,6 +1,7 @@ package com.hyunsolution.dangu.workspace.domain; import com.hyunsolution.dangu.user.domain.User; +import java.time.LocalDateTime; import javax.persistence.*; import lombok.AccessLevel; import lombok.Builder; @@ -9,8 +10,6 @@ import org.hibernate.annotations.ColumnDefault; import org.springframework.data.annotation.CreatedDate; -import java.time.LocalDateTime; - @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) diff --git a/src/main/java/com/hyunsolution/dangu/workspace/service/WorkspaceService.java b/src/main/java/com/hyunsolution/dangu/workspace/service/WorkspaceService.java index 43dab8b..db9a121 100644 --- a/src/main/java/com/hyunsolution/dangu/workspace/service/WorkspaceService.java +++ b/src/main/java/com/hyunsolution/dangu/workspace/service/WorkspaceService.java @@ -6,11 +6,8 @@ import com.hyunsolution.dangu.workspace.domain.Workspace; import com.hyunsolution.dangu.workspace.domain.WorkspaceRepository; import com.hyunsolution.dangu.workspace.dto.response.GetWorkspacesResponse; - -import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; - import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -30,8 +27,13 @@ public List getWorkspaces() { LocalDateTime dateFilter = LocalDateTime.now().minusDays(1); return workSpaceRepository.findAll().stream() .filter(workspace -> !workspace.isMatched()) - .filter(workspace -> workspace.getCreatedAt().isAfter(dateFilter)) //게임방 조회: 유지 시간은 24h - .map(workspace ->GetWorkspacesResponse.of(workspace.getId(), workspace.getCreator().getUid())) + .filter( + workspace -> + workspace.getCreatedAt().isAfter(dateFilter)) // 게임방 조회: 유지 시간은 24h + .map( + workspace -> + GetWorkspacesResponse.of( + workspace.getId(), workspace.getCreator().getUid())) .toList(); } }