Skip to content

Commit

Permalink
feat: 추천 백신 조회시 DiseaseList 리턴
Browse files Browse the repository at this point in the history
  • Loading branch information
HyungJu committed Apr 30, 2024
1 parent c58d1f2 commit 1dad8d6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class SearchService(
return this.isInJeolGi(inoculations.first().date)
}

fun searchRecommendVaccination(memberId: UUID): List<VaccinationSearchResponse> {
fun searchRecommendVaccination(memberId: UUID): List<DiseaseSearchResponse> {
val member =
memberRepository.findById(memberId).orElseThrow {
BusinessException(MemberError.NOT_FOUND)
Expand All @@ -92,15 +92,13 @@ class SearchService(

val healthProfiles = member.healthProfiles.map { it.healthCondition }.toList()

val diseases =
this.searchDisease(listOf(ageCondition), healthProfiles).filter { response ->
(
(response.name == "인플루엔자" && this.userVaccinatedIIV(memberId)) ||
response.name != "인플루엔자"
) &&
!inoculatedDiseaseName.contains(response.name)
}.toList()
return filterByDisease(recommendedVaccinations, diseases)
return this.searchDisease(listOf(ageCondition), healthProfiles).filter { response ->
(
(response.name == "인플루엔자" && this.userVaccinatedIIV(memberId)) ||
response.name != "인플루엔자"
) &&
!inoculatedDiseaseName.contains(response.name)
}.toList()
}

private fun filterByDisease(
Expand Down Expand Up @@ -149,4 +147,3 @@ class SearchService(
return SupportVaccineResponse(influenzaPercentage.toLong(), hpvPercentage.toLong())
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,49 @@ import com.vacgom.backend.disease.domain.constants.HealthCondition
import com.vacgom.backend.global.security.annotation.AuthId
import com.vacgom.backend.inoculation.domain.constants.VaccinationType
import com.vacgom.backend.search.application.SearchService
import com.vacgom.backend.search.application.dto.response.DiseaseSearchResponse
import com.vacgom.backend.search.application.dto.response.SupportVaccineResponse
import com.vacgom.backend.search.application.dto.response.VaccinationSearchResponse
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import java.util.*

@RestController
@RequestMapping("/api/v1/search")
class SearchController(
val searchService: SearchService,
val searchService: SearchService,
) {
@GetMapping
fun disease(
@RequestBody body: FilterRequest,
@RequestParam type: String,
@RequestBody body: FilterRequest,
@RequestParam type: String,
): ResponseEntity<List<Any>> {
when (type) {
"essential" -> {
return ResponseEntity.ok(
searchService.searchDisease(
body.age.map { AgeCondition.valueOf(it) },
body.condition.map { HealthCondition.valueOf(it) },
),
searchService.searchDisease(
body.age.map { AgeCondition.valueOf(it) },
body.condition.map { HealthCondition.valueOf(it) },
),
)
}

"nation" -> {
return ResponseEntity.ok(
searchService.searchVaccination(
body.age.map { AgeCondition.valueOf(it) },
body.condition.map { HealthCondition.valueOf(it) },
VaccinationType.NATION,
),
searchService.searchVaccination(
body.age.map { AgeCondition.valueOf(it) },
body.condition.map { HealthCondition.valueOf(it) },
VaccinationType.NATION,
),
)
}

"extra" -> {
return ResponseEntity.ok(
searchService.searchVaccination(
body.age.map { AgeCondition.valueOf(it) },
body.condition.map { HealthCondition.valueOf(it) },
VaccinationType.EXTRA,
),
searchService.searchVaccination(
body.age.map { AgeCondition.valueOf(it) },
body.condition.map { HealthCondition.valueOf(it) },
VaccinationType.EXTRA,
),
)
}

Expand All @@ -59,12 +59,9 @@ class SearchController(
}

@GetMapping("/recommend")
fun recommendVaccination(@AuthId id: UUID): ResponseEntity<List<VaccinationSearchResponse>> {
return ResponseEntity.ok(searchService.searchRecommendVaccination(id))
}

@GetMapping("/certificate")
fun getCertificate(@AuthId id: UUID): ResponseEntity<List<VaccinationSearchResponse>> {
fun recommendVaccination(
@AuthId id: UUID,
): ResponseEntity<List<DiseaseSearchResponse>> {
return ResponseEntity.ok(searchService.searchRecommendVaccination(id))
}

Expand Down

0 comments on commit 1dad8d6

Please sign in to comment.