From dc95760fe608c70917c32992c1cad41678a78550 Mon Sep 17 00:00:00 2001 From: RinRinPARK Date: Sat, 19 Oct 2024 17:11:25 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Feat:=20readSharedExamInfo=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../phote/controller/ExamController.kt | 10 ++++++++++ .../kotlin/com/swm_standard/phote/dto/ExamDtos.kt | 10 ++++++++++ .../com/swm_standard/phote/service/ExamService.kt | 15 +++++++++++++++ 3 files changed, 35 insertions(+) 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..5140b1f 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 isWriter: Boolean, +) 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..bda729e 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,20 @@ class ExamService( return examsAsCreator + examsAsExaminee } + fun readSharedExamInfo(examId: UUID, memberId: UUID): ReadSharedExamInfoResponse { + val sharedExam = sharedExamRepository.findById(examId).orElseThrow { NotFoundException(fieldName = "examId") } + val exam = examRepository.findById(examId).orElseThrow { NotFoundException(fieldName = "examId") } + return ReadSharedExamInfoResponse( + examId = examId, + title = sharedExam.title, + startTime = sharedExam.startTime, + endTime = sharedExam.endTime, + capacity = sharedExam.capacity, + workbookId = exam.workbook.id, + isWriter = exam.member.id == memberId, + ) + } + private fun findWorkbook(workbookId: UUID): Workbook = workbookRepository .findById( From 187f927f8f584e943eee0b0843255f1fd9fa422d Mon Sep 17 00:00:00 2001 From: RinRinPARK Date: Sat, 19 Oct 2024 17:18:05 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Fix:=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C?= =?UTF-8?q?=20exam=EC=A1=B0=ED=9A=8C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/swm_standard/phote/service/ExamService.kt | 5 ++--- 1 file changed, 2 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 bda729e..d87f0f0 100644 --- a/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt +++ b/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt @@ -362,15 +362,14 @@ class ExamService( fun readSharedExamInfo(examId: UUID, memberId: UUID): ReadSharedExamInfoResponse { val sharedExam = sharedExamRepository.findById(examId).orElseThrow { NotFoundException(fieldName = "examId") } - val exam = examRepository.findById(examId).orElseThrow { NotFoundException(fieldName = "examId") } return ReadSharedExamInfoResponse( examId = examId, title = sharedExam.title, startTime = sharedExam.startTime, endTime = sharedExam.endTime, capacity = sharedExam.capacity, - workbookId = exam.workbook.id, - isWriter = exam.member.id == memberId, + workbookId = sharedExam.workbook.id, + isWriter = sharedExam.member.id == memberId, ) } From dc9f916f28d346c261c7ef97c16f9bb8a4de530e Mon Sep 17 00:00:00 2001 From: RinRinPARK Date: Sun, 20 Oct 2024 00:07:02 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Fix:=20role=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/swm_standard/phote/dto/ExamDtos.kt | 2 +- src/main/kotlin/com/swm_standard/phote/service/ExamService.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 5140b1f..482131e 100644 --- a/src/main/kotlin/com/swm_standard/phote/dto/ExamDtos.kt +++ b/src/main/kotlin/com/swm_standard/phote/dto/ExamDtos.kt @@ -145,5 +145,5 @@ data class ReadSharedExamInfoResponse( val endTime: LocalDateTime, val capacity: Int, val workbookId: UUID, - val isWriter: Boolean, + 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 d87f0f0..821b579 100644 --- a/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt +++ b/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt @@ -369,7 +369,7 @@ class ExamService( endTime = sharedExam.endTime, capacity = sharedExam.capacity, workbookId = sharedExam.workbook.id, - isWriter = sharedExam.member.id == memberId, + role = if (sharedExam.member.id == memberId) ParticipationType.CREATOR else ParticipationType.EXAMINEE, ) }