Skip to content

Commit

Permalink
Merge pull request #257 from swm-standard/rin/swm-198
Browse files Browse the repository at this point in the history
Feat: readSharedExamInfo 구현
  • Loading branch information
RinRinPARK authored Oct 20, 2024
2 parents e936691 + dc9f916 commit 1958a79
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -121,4 +122,13 @@ class ExamController(
@Parameter(hidden = true) @MemberId memberId: UUID,
): BaseResponse<List<ReadAllSharedExamsResponse>> =
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<ReadSharedExamInfoResponse> =
BaseResponse(data = examService.readSharedExamInfo(examId, memberId), msg = "공유용 시험 정보 조회 성공")
}
10 changes: 10 additions & 0 deletions src/main/kotlin/com/swm_standard/phote/dto/ExamDtos.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
14 changes: 14 additions & 0 deletions src/main/kotlin/com/swm_standard/phote/service/ExamService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 1958a79

Please sign in to comment.