Skip to content

Commit

Permalink
feat: 인증서에 유저 ID 추가, 백신 ID로 조회 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
HyungJu committed Mar 23, 2024
1 parent b281539 commit cd897e9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<InoculationSimpleResponse> {
val validatedVaccinationType = VaccinationType.valueOf(vaccinationType.uppercase())
val vaccinations = vaccinationRepository.findAllByVaccinationType(validatedVaccinationType)
Expand All @@ -49,23 +49,25 @@ class InoculationService(
vaccination.minOrder,
vaccination.maxOrder,
isCompleted,
vaccineOrders
vaccineOrders,
)
}.toList()
}

fun getInoculationDetailResponse(
memberId: UUID,
request: DiseaseNameRequest,
vaccinationType: String
vaccinationType: String,
): List<InoculationDetailResponse> {
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(
Expand All @@ -75,7 +77,7 @@ class InoculationService(
it.lotNumber,
it.vaccineName,
it.vaccineBrandName,
it.date
it.date,
)
}.toList()
}
Expand All @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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<InoculationCertificateResponse> {
val certificates = inoculationService.getCertificates(id)
return ResponseEntity.ok(certificates.filter { it.vaccineId == vaccineId }.first())
}
}

0 comments on commit cd897e9

Please sign in to comment.