Skip to content

Commit bd85299

Browse files
authored
Merge pull request #68 from DropThe8bit/feature/quiz
[refactor] 다른 사용자가 생성한 story의 quiz에 접근 가능하도록 변경
2 parents 88e0e91 + 77d71b9 commit bd85299

3 files changed

Lines changed: 4 additions & 7 deletions

File tree

src/main/java/everTale/everTale_be/domain/quiz/repository/QuizRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
public interface QuizRepository extends JpaRepository<Quiz, Long> {
1414
@EntityGraph(attributePaths = {"scene", "scene.story"})
15-
List<Quiz> findAllByScene_Story_IdAndScene_Story_Profile_Id(Long storyId, Long profileId);
15+
List<Quiz> findAllByScene_Story_Id(Long storyId);
1616

1717
@Modifying
1818
@Transactional

src/main/java/everTale/everTale_be/domain/quiz/service/QuizService.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ public class QuizService {
3030

3131
@Transactional
3232
public QuizResponseDTO.QuizGenerateResponseDTO generateQuizForRandomScene(Long storyId) {
33-
Long profileId = profileHelper.getAuthenticatedProfileId();
34-
35-
List<Scene> scenes = sceneRepository.findAllByStoryIdAndStoryProfileIdAndQuizIsNull(storyId, profileId);
33+
List<Scene> scenes = sceneRepository.findAllByStoryIdAndQuizIsNull(storyId);
3634
if (scenes.isEmpty()) {
3735
throw new NotFoundHandler(ErrorStatus.SCENE_NOT_FOUND);
3836
}
@@ -58,8 +56,7 @@ public QuizResponseDTO.QuizGenerateResponseDTO generateQuizForRandomScene(Long s
5856
// quiz 조회
5957
@Transactional(readOnly = true)
6058
public List<QuizResponseDTO.QuizGetResponseDTO> getAllQuizzesByStoryId(Long storyId) {
61-
Long profileId = profileHelper.getAuthenticatedProfileId();
62-
List<Quiz> quizzes = quizRepository.findAllByScene_Story_IdAndScene_Story_Profile_Id(storyId, profileId);
59+
List<Quiz> quizzes = quizRepository.findAllByScene_Story_Id(storyId);
6360

6461
return quizzes.stream()
6562
.map(QuizResponseDTO.QuizGetResponseDTO::from)

src/main/java/everTale/everTale_be/domain/story/repository/SceneRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public interface SceneRepository extends JpaRepository<Scene, Long> {
2020

2121
List<Scene> findByStoryIdOrderByPageAsc(Long storyId);
2222

23-
List<Scene> findAllByStoryIdAndStoryProfileIdAndQuizIsNull(Long storyId, Long profileId);
23+
List<Scene> findAllByStoryIdAndQuizIsNull(Long storyId);
2424

2525
Optional<Scene> findByIdAndStoryId(Long sceneId, Long storyId);
2626
}

0 commit comments

Comments
 (0)