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 71633da..4df5a89 100644 --- a/src/main/kotlin/com/swm_standard/phote/controller/ExamController.kt +++ b/src/main/kotlin/com/swm_standard/phote/controller/ExamController.kt @@ -7,6 +7,7 @@ import com.swm_standard.phote.dto.CreateSharedExamResponse import com.swm_standard.phote.dto.GradeExamRequest import com.swm_standard.phote.dto.GradeExamResponse import com.swm_standard.phote.dto.ReadAllSharedExamsResponse +import com.swm_standard.phote.dto.ReadSharedExamInfoResponse import com.swm_standard.phote.dto.ReadExamHistoryDetailResponse import com.swm_standard.phote.dto.ReadExamHistoryListResponse import com.swm_standard.phote.dto.ReadExamResultDetailResponse @@ -121,4 +122,13 @@ class ExamController( @Parameter(hidden = true) @MemberId memberId: UUID, ): BaseResponse> = BaseResponse(data = examService.readAllSharedExams(memberId), msg = "공유용 시험 목록 조회 성공") + + @Operation(summary = "readSharedExamInfo", description = "공유된/공유받은 시험 정보 조회") + @SecurityRequirement(name = "bearer Auth") + @GetMapping("/shared-exam/{examId}") + fun readSharedExamInfo( + @PathVariable(required = true) examId: UUID, + @Parameter(hidden = true) @MemberId memberId: UUID, + ): BaseResponse = + BaseResponse(data = examService.readSharedExamInfo(examId, memberId), msg = "공유용 시험 정보 조회 성공") } diff --git a/src/main/kotlin/com/swm_standard/phote/dto/ExamDtos.kt b/src/main/kotlin/com/swm_standard/phote/dto/ExamDtos.kt index b90e8ec..482131e 100644 --- a/src/main/kotlin/com/swm_standard/phote/dto/ExamDtos.kt +++ b/src/main/kotlin/com/swm_standard/phote/dto/ExamDtos.kt @@ -137,3 +137,13 @@ data class ReadAllSharedExamsResponse( val totalCorrect: Int? = null, val questionQuantity: Int? = null, ) + +data class ReadSharedExamInfoResponse( + val examId: UUID, + val title: String, + val startTime: LocalDateTime, + val endTime: LocalDateTime, + val capacity: Int, + val workbookId: UUID, + val role: ParticipationType, +) 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 0604d56..821b579 100644 --- a/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt +++ b/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt @@ -9,6 +9,7 @@ import com.swm_standard.phote.dto.CreateSharedExamRequest import com.swm_standard.phote.dto.GradeExamRequest import com.swm_standard.phote.dto.GradeExamResponse import com.swm_standard.phote.dto.ReadAllSharedExamsResponse +import com.swm_standard.phote.dto.ReadSharedExamInfoResponse import com.swm_standard.phote.dto.ReadExamHistoryDetail import com.swm_standard.phote.dto.ReadExamHistoryDetailResponse import com.swm_standard.phote.dto.ReadExamHistoryListResponse @@ -359,6 +360,19 @@ class ExamService( return examsAsCreator + examsAsExaminee } + fun readSharedExamInfo(examId: UUID, memberId: UUID): ReadSharedExamInfoResponse { + val sharedExam = sharedExamRepository.findById(examId).orElseThrow { NotFoundException(fieldName = "examId") } + return ReadSharedExamInfoResponse( + examId = examId, + title = sharedExam.title, + startTime = sharedExam.startTime, + endTime = sharedExam.endTime, + capacity = sharedExam.capacity, + workbookId = sharedExam.workbook.id, + role = if (sharedExam.member.id == memberId) ParticipationType.CREATOR else ParticipationType.EXAMINEE, + ) + } + private fun findWorkbook(workbookId: UUID): Workbook = workbookRepository .findById(