Skip to content

Commit a736603

Browse files
authored
♻️ refactor: 퀴즈 정보 조회 메서드 수정 (#90)
* ♻️ refactor: saveRoom, 퀴즈 정보 조회 메서드 수정 * chore: Java 스타일 수정 --------- Co-authored-by: github-actions <>
1 parent ceca5e6 commit a736603

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

backend/src/main/java/io/f1/backend/domain/game/app/RoomService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import io.f1.backend.domain.game.dto.response.RoomResponse;
2525
import io.f1.backend.domain.game.dto.response.RoomSettingResponse;
2626
import io.f1.backend.domain.game.dto.response.SystemNoticeResponse;
27+
import io.f1.backend.domain.game.event.RoomCreatedEvent;
2728
import io.f1.backend.domain.game.model.GameSetting;
2829
import io.f1.backend.domain.game.model.Player;
2930
import io.f1.backend.domain.game.model.Room;
@@ -67,7 +68,8 @@ public class RoomService {
6768
public RoomCreateResponse saveRoom(RoomCreateRequest request) {
6869

6970
QuizMinData quizMinData = quizService.getQuizMinData();
70-
// Quiz quiz = quizService.getQuizWithQuestionsById(quizMinId);
71+
72+
Quiz quiz = quizService.findQuizById(quizMinData.quizMinId());
7173

7274
GameSetting gameSetting = toGameSetting(quizMinData);
7375

@@ -83,7 +85,7 @@ public RoomCreateResponse saveRoom(RoomCreateRequest request) {
8385

8486
roomRepository.saveRoom(room);
8587

86-
// eventPublisher.publishEvent(new RoomCreatedEvent(room, quiz));
88+
eventPublisher.publishEvent(new RoomCreatedEvent(room, quiz));
8789

8890
return new RoomCreateResponse(newId);
8991
}

backend/src/main/java/io/f1/backend/domain/quiz/app/QuizService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,11 @@ public List<Question> getRandomQuestionsWithoutAnswer(Long quizId, Integer round
277277

278278
return quizRepository.findRandQuestionsByQuizId(quizId, round);
279279
}
280+
281+
@Transactional(readOnly = true)
282+
public Quiz findQuizById(Long quizId) {
283+
return quizRepository
284+
.findById(quizId)
285+
.orElseThrow(() -> new CustomException(QuizErrorCode.QUIZ_NOT_FOUND));
286+
}
280287
}

0 commit comments

Comments
 (0)