Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: readSharedExamInfo 구현 #257

Merged
merged 3 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 isWriter: Boolean,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val isWriter: Boolean,
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,
isWriter = sharedExam.member.id == memberId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
isWriter = sharedExam.member.id == memberId,
role =
if (exam.member.id == memberId) {
ParticipationType.CREATOR
} else {
ParticipationType.EXAMINEE
},

이거 readAllSharedExams 기능이랑 통일감있게 이렇게 수정하는 거 어떨까욘 ExamDto 에도 suggestion 넣어둘게

)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서 공유용 시험을 생성한 사람이 조회하는거면 응시자 id , name 도 넘겨줘야할 것 같아요!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

클라에 정확히 머 필요한지 함 물어볼게!!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오오오키오키
readExamResultDetail 이 기능 쓰려면 저 정보가 어딘가엔 응답으로 들어가야할 것 같아스 ~ ~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 api가 따로 있었네연. ㅎ

}

private fun findWorkbook(workbookId: UUID): Workbook =
workbookRepository
.findById(
Expand Down
Loading