Skip to content

Commit

Permalink
feat: 접종 인증서 이미지 추가 및 AuthResponse 스펙 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
h-beeen committed Mar 23, 2024
1 parent 6719572 commit 65f21f8
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AuthService(
val memberResponse = MemberResponse(member.id!!, member.role)
val tokenResponse = TokenResponse(jwtFactory.createAccessToken(member))

return AuthResponse(memberResponse, tokenResponse)
return AuthResponse(true, memberResponse, tokenResponse)
}

private fun findOrCreateMember(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ class VacgomSignupService(

inoculationRepository.saveAll(inoculations)
member.addInoculations(inoculations)
return AuthResponse(memberResponse, tokenResponse)
return AuthResponse(true, memberResponse, tokenResponse)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.vacgom.backend.auth.application.dto.response

data class AuthResponse(
val success: Boolean,
val member: MemberResponse,
val token: TokenResponse
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.vacgom.backend.inoculation.application
import com.vacgom.backend.global.exception.error.BusinessException
import com.vacgom.backend.global.exception.error.GlobalError
import com.vacgom.backend.inoculation.application.dto.request.DiseaseNameRequest
import com.vacgom.backend.inoculation.application.dto.response.InoculationCertificateResponse
import com.vacgom.backend.inoculation.application.dto.response.InoculationDetailResponse
import com.vacgom.backend.inoculation.application.dto.response.InoculationSimpleResponse
import com.vacgom.backend.inoculation.domain.constants.VaccinationType
Expand Down Expand Up @@ -78,12 +79,16 @@ class InoculationService(
}.toList()
}

fun getCertificates(memberId: UUID) {
val findDistinctLatestInoculationsByMemberId =
inoculationRepository.findDistinctLatestInoculationsByMemberId(memberId)

findDistinctLatestInoculationsByMemberId.forEach { lis ->
log.warn("{}, lis")
}
fun getCertificates(memberId: UUID): List<InoculationCertificateResponse> {
val inoculations = inoculationRepository.findDistinctLatestInoculationsByMemberId(memberId)
val sortedByDescending = inoculations.sortedByDescending { it.date }
return sortedByDescending.map {
InoculationCertificateResponse(
it.vaccination.diseaseName,
it.vaccination.vaccineName,
it.date,
it.vaccination.certificationIcon
)
}.toList()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.vacgom.backend.inoculation.application.dto.response

import java.time.LocalDate

data class InoculationCertificateResponse(
val diseaseName: String,
val vaccineName: String,
val inoculatedDate: LocalDate,
val iconImage: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Vaccination(
val minOrder: Long,
val maxOrder: Long,
val icon: String,
val certificationIcon: String,
@Enumerated(EnumType.STRING) val vaccinationType: VaccinationType,
) : BaseEntity() {
@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ interface InoculationRepository : JpaRepository<Inoculation, UUID> {
): List<Inoculation>?


@Query(
"select i " +
"from Inoculation i " +
"where (i.vaccination.diseaseName, i.inoculationOrder) in " +
"(select iv.vaccination.diseaseName, max(iv.inoculationOrder) from Inoculation iv where iv.member.id = :memberId group by iv.vaccination.diseaseName)"
)
@Query("SELECT i " +
"FROM Inoculation i JOIN i.vaccination v " +
"GROUP BY i.vaccination.id " +
"ORDER BY i.inoculationOrder DESC")
fun findDistinctLatestInoculationsByMemberId(memberId: UUID): List<Inoculation>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.vacgom.backend.inoculation.presentation
import com.vacgom.backend.global.security.annotation.AuthId
import com.vacgom.backend.inoculation.application.InoculationService
import com.vacgom.backend.inoculation.application.dto.request.DiseaseNameRequest
import com.vacgom.backend.inoculation.application.dto.response.InoculationCertificateResponse
import com.vacgom.backend.inoculation.application.dto.response.InoculationDetailResponse
import com.vacgom.backend.inoculation.application.dto.response.InoculationSimpleResponse
import org.springframework.http.ResponseEntity
Expand Down Expand Up @@ -32,4 +33,10 @@ class InoculationController(
val responses = inoculationService.getInoculationDetailResponse(id, request, type)
return ResponseEntity.ok(responses)
}

@GetMapping("/certificate")
fun getInoculationCertificateResponse(@AuthId id: UUID): ResponseEntity<List<InoculationCertificateResponse>> {
val certificates = inoculationService.getCertificates(id)
return ResponseEntity.ok(certificates)
}
}

0 comments on commit 65f21f8

Please sign in to comment.