Skip to content

Commit

Permalink
feat: InoculationSimple 조회를 type에서 vaccinations로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
HyungJu committed May 14, 2024
1 parent 18f84b7 commit f5bec5a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.vacgom.backend.inoculation.domain.Inoculation
import com.vacgom.backend.inoculation.domain.constants.VaccinationType
import com.vacgom.backend.inoculation.infrastructure.persistence.InoculationRepository
import com.vacgom.backend.inoculation.infrastructure.persistence.VaccinationRepository
import com.vacgom.backend.inoculation.presentation.dto.InoculationSimpleRequest
import com.vacgom.backend.member.domain.Nickname
import com.vacgom.backend.member.exception.MemberError
import com.vacgom.backend.member.infrastructure.persistence.MemberRepository
Expand All @@ -35,12 +36,19 @@ class InoculationService(
) {
fun getInoculationSimpleResponse(
memberId: UUID,
vaccinationType: String,
request: InoculationSimpleRequest,
): List<InoculationSimpleResponse> {
val validatedVaccinationType = VaccinationType.valueOf(vaccinationType.uppercase())
val vaccinations = vaccinationRepository.findAllByVaccinationType(validatedVaccinationType)
val vaccinations =
if (request.vaccinations.isEmpty()) {
vaccinationRepository.findAll()
} else {
vaccinationRepository.findAll().filter {
it.vaccineName in request.vaccinations
}
}

val inoculations =
inoculationRepository.findInoculationsByMemberIdAndVaccinationType(memberId, validatedVaccinationType)
inoculationRepository.findInoculationsByMemberId(memberId)

val hashMap = HashMap<String, MutableList<Long>>()
inoculations.forEach { inoculation ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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.presentation.dto.InoculationSimpleRequest
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import java.util.*
Expand All @@ -18,9 +19,9 @@ class InoculationController(
@GetMapping("/simple")
fun getInoculationSimpleResponse(
@AuthId id: UUID,
@RequestParam type: String,
@RequestBody request: InoculationSimpleRequest,
): ResponseEntity<List<InoculationSimpleResponse>> {
val responses = inoculationService.getInoculationSimpleResponse(id, type)
val responses = inoculationService.getInoculationSimpleResponse(id, request)
return ResponseEntity.ok(responses)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.vacgom.backend.inoculation.presentation.dto

data class InoculationSimpleRequest(
val vaccinations: List<String>,
)

0 comments on commit f5bec5a

Please sign in to comment.