diff --git a/src/main/kotlin/com/vacgom/backend/inoculation/application/InoculationService.kt b/src/main/kotlin/com/vacgom/backend/inoculation/application/InoculationService.kt index 2cdfbd0..a081d0f 100644 --- a/src/main/kotlin/com/vacgom/backend/inoculation/application/InoculationService.kt +++ b/src/main/kotlin/com/vacgom/backend/inoculation/application/InoculationService.kt @@ -19,11 +19,11 @@ import java.util.* class InoculationService( private val inoculationRepository: InoculationRepository, private val vaccinationRepository: VaccinationRepository, - private val log: Logger + private val log: Logger, ) { fun getInoculationSimpleResponse( memberId: UUID, - vaccinationType: String + vaccinationType: String, ): List { val validatedVaccinationType = VaccinationType.valueOf(vaccinationType.uppercase()) val vaccinations = vaccinationRepository.findAllByVaccinationType(validatedVaccinationType) @@ -49,7 +49,7 @@ class InoculationService( vaccination.minOrder, vaccination.maxOrder, isCompleted, - vaccineOrders + vaccineOrders, ) }.toList() } @@ -57,15 +57,17 @@ class InoculationService( fun getInoculationDetailResponse( memberId: UUID, request: DiseaseNameRequest, - vaccinationType: String + vaccinationType: String, ): List { val validatedVaccinationType = VaccinationType.valueOf(vaccinationType.uppercase()) - val inoculations = (inoculationRepository.findInoculationsByMemberIdAndVaccinationTypeAndDiseaseName( - memberId, - validatedVaccinationType, - request.name + val inoculations = ( + inoculationRepository.findInoculationsByMemberIdAndVaccinationTypeAndDiseaseName( + memberId, + validatedVaccinationType, + request.name, + ) + ?: throw BusinessException(GlobalError.GLOBAL_NOT_FOUND) ) - ?: throw BusinessException(GlobalError.GLOBAL_NOT_FOUND)) return inoculations.map { InoculationDetailResponse( @@ -75,7 +77,7 @@ class InoculationService( it.lotNumber, it.vaccineName, it.vaccineBrandName, - it.date + it.date, ) }.toList() } @@ -85,10 +87,12 @@ class InoculationService( val sortedByDescending = inoculations.sortedByDescending { it.date } return sortedByDescending.map { InoculationCertificateResponse( + memberId.toString(), + it.vaccination.id.toString(), it.vaccination.diseaseName, it.vaccination.vaccineName, it.date, - it.vaccination.certificationIcon + it.vaccination.certificationIcon, ) }.toList() } diff --git a/src/main/kotlin/com/vacgom/backend/inoculation/application/dto/response/InoculationCertificateResponse.kt b/src/main/kotlin/com/vacgom/backend/inoculation/application/dto/response/InoculationCertificateResponse.kt index e6a0f04..dc5c2b2 100644 --- a/src/main/kotlin/com/vacgom/backend/inoculation/application/dto/response/InoculationCertificateResponse.kt +++ b/src/main/kotlin/com/vacgom/backend/inoculation/application/dto/response/InoculationCertificateResponse.kt @@ -3,8 +3,10 @@ package com.vacgom.backend.inoculation.application.dto.response import java.time.LocalDate data class InoculationCertificateResponse( + val userId: String, + val vaccineId: String, val diseaseName: String, val vaccineName: String, val inoculatedDate: LocalDate, - val iconImage: String + val iconImage: String, ) diff --git a/src/main/kotlin/com/vacgom/backend/inoculation/presentation/InoculationController.kt b/src/main/kotlin/com/vacgom/backend/inoculation/presentation/InoculationController.kt index 3c3b7dc..dbb042e 100644 --- a/src/main/kotlin/com/vacgom/backend/inoculation/presentation/InoculationController.kt +++ b/src/main/kotlin/com/vacgom/backend/inoculation/presentation/InoculationController.kt @@ -41,4 +41,13 @@ class InoculationController( val certificates = inoculationService.getCertificates(id) return ResponseEntity.ok(certificates) } + + @GetMapping("/certificate/{vaccineId}") + fun getCertificateByVaccineId( + @AuthId id: UUID, + @PathVariable("vaccineId") vaccineId: String, + ): ResponseEntity { + val certificates = inoculationService.getCertificates(id) + return ResponseEntity.ok(certificates.filter { it.vaccineId == vaccineId }.first()) + } }