Skip to content

Commit

Permalink
fix: 인증서 이미지에서 해당 사용자의 접종 내역만 조회하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
HyungJu committed May 2, 2024
1 parent 28febe5 commit d9b4317
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class InoculationService(
inoculationId: String,
): ByteArray {
val inoculation =
inoculationRepository.findFirstByVaccinationId(UUID.fromString(inoculationId))
inoculationRepository.findLastUserInoculation(UUID.fromString(inoculationId), userId)
?: throw BusinessException(GlobalError.GLOBAL_NOT_FOUND)

if (inoculation.member.id != userId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,14 @@ interface InoculationRepository : JpaRepository<Inoculation, UUID> {
)
fun findInoculationsByDiseaseName(diseaseName: String): List<Inoculation>

fun findFirstByVaccinationId(vaccinationId: UUID): Inoculation?
@Query(
"SELECT i from Inoculation i " +
"where i.vaccination.id = :vaccinationId " +
"and i.member.id = :memberId " +
"ORDER BY i.date DESC, i.inoculationOrder DESC LIMIT 1",
)
fun findLastUserInoculation(
vaccinationId: UUID,
memberId: UUID,
): Inoculation?
}

0 comments on commit d9b4317

Please sign in to comment.