Skip to content

Commit

Permalink
Merge pull request #262 from swm-standard/rin/swm-201
Browse files Browse the repository at this point in the history
Fix: readExamHistoryList ๋ณธ์ธ ์‹œํ—˜๋งŒ ์กฐํšŒํ•˜๋„๋ก ์ˆ˜์ •
  • Loading branch information
RinRinPARK authored Oct 24, 2024
2 parents 16f9bd1 + a112c9d commit 0a0116e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ class ExamController(
@PathVariable(
required = true,
) workbookId: UUID,
@MemberId memberId: UUID,
): BaseResponse<List<ReadExamHistoryListResponse>> =
BaseResponse(msg = "๋ฌธ์ œํ’€์ด ๊ธฐ๋ก ๋ฆฌ์ŠคํŠธ ์กฐํšŒ ์„ฑ๊ณต", data = examService.readExamHistoryList(workbookId))
BaseResponse(msg = "๋ฌธ์ œํ’€์ด ๊ธฐ๋ก ๋ฆฌ์ŠคํŠธ ์กฐํšŒ ์„ฑ๊ณต", data = examService.readExamHistoryList(workbookId, memberId))

@Operation(summary = "readExamResults", description = "(๊ฐ•์‚ฌ๊ฐ€) ํ•™์ƒ๋“ค์˜ ์‹œํ—˜ ๊ฒฐ๊ณผ ๋ชฉ๋ก์„ ์กฐํšŒ")
@SecurityRequirement(name = "bearer Auth")
Expand Down
12 changes: 7 additions & 5 deletions src/main/kotlin/com/swm_standard/phote/service/ExamService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,14 @@ class ExamService(
)
}

fun readExamHistoryList(workbookId: UUID): List<ReadExamHistoryListResponse> {
fun readExamHistoryList(workbookId: UUID, memberId: UUID): List<ReadExamHistoryListResponse> {
val exams = examRepository.findAllByWorkbookId(workbookId)
return exams.map { exam ->
// FIXME: exam ๋งˆ๋‹ค examResult ๋ฅผ ๋˜ ์กฐํšŒํ•ด์•ผํ•จ ์ฟผ๋ฆฌ ๊ฐœ์„  ํ•„์š”
val examResult =
examResultRepository.findByExamId(exam.id!!) ?: throw NotFoundException(fieldName = "examResult")

return exams.filter { exam ->
!sharedExamRepository.findById(exam.id!!).isPresent
}.map { exam ->
val examResult = examResultRepository.findByExamIdAndMemberId(exam.id!!, memberId)
?: throw NotFoundException(fieldName = "examResult")

ReadExamHistoryListResponse(
examId = exam.id!!,
Expand Down

0 comments on commit 0a0116e

Please sign in to comment.