Skip to content

Commit fabda6c

Browse files
committed
♻️ refactor: saveRoom, 퀴즈 정보 조회 메서드 수정
1 parent f364aec commit fabda6c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-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
@@ -26,6 +26,7 @@
2626
import io.f1.backend.domain.game.dto.response.RoomResponse;
2727
import io.f1.backend.domain.game.dto.response.RoomSettingResponse;
2828
import io.f1.backend.domain.game.dto.response.SystemNoticeResponse;
29+
import io.f1.backend.domain.game.event.RoomCreatedEvent;
2930
import io.f1.backend.domain.game.model.GameSetting;
3031
import io.f1.backend.domain.game.model.Player;
3132
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,10 @@ public List<Question> getRandomQuestionsWithoutAnswer(Long quizId, Integer round
261261

262262
return randomQuestions;
263263
}
264+
265+
@Transactional(readOnly = true)
266+
public Quiz findQuizById(Long quizId) {
267+
return quizRepository.findById(quizId)
268+
.orElseThrow(() -> new CustomException(QuizErrorCode.QUIZ_NOT_FOUND));
269+
}
264270
}

0 commit comments

Comments
 (0)