From 19e8b0294082fde6f21aa093733619893c5b25ec Mon Sep 17 00:00:00 2001 From: RinRinPARK Date: Wed, 23 Oct 2024 22:34:38 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Fix:=20readExamHistoryList=20=EB=B3=B8?= =?UTF-8?q?=EC=9D=B8=20=EC=8B=9C=ED=97=98=EB=A7=8C=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/swm_standard/phote/controller/ExamController.kt | 3 ++- .../kotlin/com/swm_standard/phote/service/ExamService.kt | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/swm_standard/phote/controller/ExamController.kt b/src/main/kotlin/com/swm_standard/phote/controller/ExamController.kt index 4df5a89..1cd9db7 100644 --- a/src/main/kotlin/com/swm_standard/phote/controller/ExamController.kt +++ b/src/main/kotlin/com/swm_standard/phote/controller/ExamController.kt @@ -52,8 +52,9 @@ class ExamController( @PathVariable( required = true, ) workbookId: UUID, + @MemberId memberId: UUID, ): BaseResponse> = - BaseResponse(msg = "문제풀이 기록 리스트 조회 성공", data = examService.readExamHistoryList(workbookId)) + BaseResponse(msg = "문제풀이 기록 리스트 조회 성공", data = examService.readExamHistoryList(workbookId, memberId)) @Operation(summary = "readExamResults", description = "(강사가) 학생들의 시험 결과 목록을 조회") @SecurityRequirement(name = "bearer Auth") diff --git a/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt b/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt index 821b579..227798a 100644 --- a/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt +++ b/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt @@ -108,12 +108,11 @@ class ExamService( ) } - fun readExamHistoryList(workbookId: UUID): List { + fun readExamHistoryList(workbookId: UUID, memberId: UUID): List { val exams = examRepository.findAllByWorkbookId(workbookId) return exams.map { exam -> - // FIXME: exam 마다 examResult 를 또 조회해야함 쿼리 개선 필요 val examResult = - examResultRepository.findByExamId(exam.id!!) ?: throw NotFoundException(fieldName = "examResult") + examResultRepository.findByExamIdAndMemberId(exam.id!!, memberId) ReadExamHistoryListResponse( examId = exam.id!!, From 92138dcc184e29073a1b4157a6dbd5db551991fc Mon Sep 17 00:00:00 2001 From: RinRinPARK Date: Thu, 24 Oct 2024 00:21:18 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Fix:=20sharedExam=20=ED=95=84=ED=84=B0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/swm_standard/phote/service/ExamService.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt b/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt index 227798a..8246529 100644 --- a/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt +++ b/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt @@ -110,9 +110,11 @@ class ExamService( fun readExamHistoryList(workbookId: UUID, memberId: UUID): List { val exams = examRepository.findAllByWorkbookId(workbookId) - return exams.map { exam -> - val examResult = - examResultRepository.findByExamIdAndMemberId(exam.id!!, memberId) + + return exams.filter { exam -> + !sharedExamRepository.findById(exam.id!!).isPresent + }.map { exam -> + val examResult = examResultRepository.findByExamIdAndMemberId(exam.id!!, memberId) ReadExamHistoryListResponse( examId = exam.id!!, From a112c9dd56e481baa528b5e383da9f7a63c028c4 Mon Sep 17 00:00:00 2001 From: RinRinPARK Date: Thu, 24 Oct 2024 00:23:06 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Fix:=20404=20=EC=97=90=EB=9F=AC=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/swm_standard/phote/service/ExamService.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt b/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt index 8246529..212b8a2 100644 --- a/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt +++ b/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt @@ -115,6 +115,7 @@ class ExamService( !sharedExamRepository.findById(exam.id!!).isPresent }.map { exam -> val examResult = examResultRepository.findByExamIdAndMemberId(exam.id!!, memberId) + ?: throw NotFoundException(fieldName = "examResult") ReadExamHistoryListResponse( examId = exam.id!!,