From ad03d9c11b03bca14fdcf8ff8c4d63d8f24eacdb Mon Sep 17 00:00:00 2001 From: Haebin Date: Fri, 22 Mar 2024 06:30:36 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EB=8F=84=EB=A9=94=EC=9D=B8=20=EC=A3=BC?= =?UTF-8?q?=EB=8F=84=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/dto/request/MemberInfoRequest.kt | 8 --- .../auth/dto/response/MeResponse.kt | 21 ------ .../auth/dto/response/MemberResponse.kt | 9 --- .../auth/dto/response/ResourceIdResponse.kt | 5 -- .../application/disease/DiseaseService.kt | 14 ---- .../dto/request/DiseaseFilterRequest.kt | 7 -- .../disease/dto/response/DiseaseResponse.kt | 21 ------ .../dto/request/DiseaseNameRequest.kt | 5 -- .../application/member/MemberService.kt | 43 ------------ .../application/search/SearchService.kt | 67 ------------------- .../search/dto/DiseaseSearchResponse.kt | 21 ------ .../search/dto/VaccinationSearchResponse.kt | 21 ------ .../vaccine/dto/VaccineResponse.kt | 7 -- .../application/vaccine/dto/VaccineService.kt | 31 --------- .../auth => auth/application}/AuthFactory.kt | 8 +-- .../auth => auth/application}/AuthService.kt | 16 ++--- .../application}/VacgomSignupService.kt | 34 +++++----- .../dto/request/MemberInfoRequest.kt | 8 +++ .../application}/dto/request/SignUpRequest.kt | 2 +- .../dto/request/VaccinationInfoRequest.kt | 2 +- .../application}/dto/request/Vaccine.kt | 2 +- .../application}/dto/response/AuthResponse.kt | 2 +- .../dto/response/HealthConditionResponse.kt | 4 +- .../application/dto/response/MeResponse.kt | 21 ++++++ .../dto/response/MemberResponse.kt | 9 +++ .../dto/response/OauthTokenResponse.kt | 2 +- .../dto/response/ResourceIdResponse.kt | 5 ++ .../dto/response/TokenResponse.kt | 2 +- .../backend/auth/domain/OauthConnector.kt | 11 +++ .../domain}/OauthUriGenerator.kt | 4 +- .../domain}/constants/ProviderType.kt | 2 +- .../auth => auth/domain}/constants/Role.kt | 2 +- .../infrastructure}/kakao/KakaoConnector.kt | 12 ++-- .../kakao/KakaoUriGenerator.kt | 8 +-- .../kakao/model/KakaoProperties.kt | 2 +- .../presentation}/OAuthController.kt | 6 +- .../presentation}/SignUpController.kt | 8 +-- .../disease/application/DiseaseService.kt | 14 ++++ .../application/dto/request/FilterRequest.kt | 6 ++ .../dto/response/DiseaseResponse.kt | 21 ++++++ .../vacgom/backend/disease/domain/Disease.kt | 20 ++++++ .../domain/constants}/AgeCondition.kt | 6 +- .../domain/constants}/HealthCondition.kt | 8 +-- .../persistence/DiseaseRepository.kt | 4 +- .../presentation}/DiseaseController.kt | 8 +-- .../domain/auth/oauth/OauthConnector.kt | 11 --- .../vacgom/backend/domain/disease/Disease.kt | 20 ------ .../backend/domain/inoculation/Inoculation.kt | 36 ---------- .../inoculation/constants/VaccinationType.kt | 6 -- .../global/security/filter/JwtAuthFilter.kt | 2 +- .../backend/global/security/jwt/JwtFactory.kt | 2 +- .../application}/InoculationService.kt | 14 ++-- .../inoculation/application/VaccineService.kt | 32 +++++++++ .../dto/request/DiseaseNameRequest.kt | 5 ++ .../dto/response/InoculationDetailResponse.kt | 2 +- .../dto/response/InoculationSimpleResponse.kt | 2 +- .../dto/response/VaccineResponse.kt | 7 ++ .../backend/inoculation/domain/Inoculation.kt | 36 ++++++++++ .../domain}/Vaccination.kt | 4 +- .../domain/constants/VaccinationType.kt | 6 ++ .../exception}/VaccineError.kt | 2 +- .../persistence/InoculationRepository.kt | 6 +- .../persistence/VaccinationRepository.kt | 6 +- .../member/application/MemberService.kt | 43 ++++++++++++ .../request/UpdateHealthConditionRequest.kt | 5 ++ .../member => member/domain}/HealthProfile.kt | 14 ++-- .../member => member/domain}/Member.kt | 14 ++-- .../member => member/domain}/MemberDetails.kt | 4 +- .../member => member/domain}/Nickname.kt | 4 +- .../member => member/domain}/constants/Sex.kt | 4 +- .../exception}/HealthConditionError.kt | 8 +-- .../exception}/MemberError.kt | 2 +- .../exception}/NicknameError.kt | 2 +- .../persistence/HealthProfileRepository.kt | 4 +- .../persistence/MemberRepository.kt | 8 +-- .../member/presentation/MeController.kt | 61 +++++++++++++++++ .../presentation/disease/dto/FilterRequest.kt | 6 -- .../inoculation/InoculationController.kt | 8 +-- .../presentation/member/MeController.kt | 61 ----------------- .../dto/UpdateHealthConditionRequest.kt | 5 -- .../presentation/search/SearchController.kt | 34 +++++----- .../presentation/vaccine/VaccineController.kt | 8 +-- .../search/application/SearchService.kt | 67 +++++++++++++++++++ .../application/dto/DiseaseSearchResponse.kt | 21 ++++++ .../dto/VaccinationSearchResponse.kt | 21 ++++++ 85 files changed, 568 insertions(+), 574 deletions(-) delete mode 100644 src/main/kotlin/com/vacgom/backend/application/auth/dto/request/MemberInfoRequest.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/application/auth/dto/response/MeResponse.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/application/auth/dto/response/MemberResponse.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/application/auth/dto/response/ResourceIdResponse.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/application/disease/DiseaseService.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/application/disease/dto/request/DiseaseFilterRequest.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/application/disease/dto/response/DiseaseResponse.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/application/inoculation/dto/request/DiseaseNameRequest.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/application/member/MemberService.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/application/search/SearchService.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/application/search/dto/DiseaseSearchResponse.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/application/search/dto/VaccinationSearchResponse.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/application/vaccine/dto/VaccineResponse.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/application/vaccine/dto/VaccineService.kt rename src/main/kotlin/com/vacgom/backend/{application/auth => auth/application}/AuthFactory.kt (79%) rename src/main/kotlin/com/vacgom/backend/{application/auth => auth/application}/AuthService.kt (77%) rename src/main/kotlin/com/vacgom/backend/{application/auth => auth/application}/VacgomSignupService.kt (73%) create mode 100644 src/main/kotlin/com/vacgom/backend/auth/application/dto/request/MemberInfoRequest.kt rename src/main/kotlin/com/vacgom/backend/{application/auth => auth/application}/dto/request/SignUpRequest.kt (68%) rename src/main/kotlin/com/vacgom/backend/{application/auth => auth/application}/dto/request/VaccinationInfoRequest.kt (74%) rename src/main/kotlin/com/vacgom/backend/{application/auth => auth/application}/dto/request/Vaccine.kt (89%) rename src/main/kotlin/com/vacgom/backend/{application/auth => auth/application}/dto/response/AuthResponse.kt (62%) rename src/main/kotlin/com/vacgom/backend/{application/auth => auth/application}/dto/response/HealthConditionResponse.kt (75%) create mode 100644 src/main/kotlin/com/vacgom/backend/auth/application/dto/response/MeResponse.kt create mode 100644 src/main/kotlin/com/vacgom/backend/auth/application/dto/response/MemberResponse.kt rename src/main/kotlin/com/vacgom/backend/{application/auth => auth/application}/dto/response/OauthTokenResponse.kt (81%) create mode 100644 src/main/kotlin/com/vacgom/backend/auth/application/dto/response/ResourceIdResponse.kt rename src/main/kotlin/com/vacgom/backend/{application/auth => auth/application}/dto/response/TokenResponse.kt (52%) create mode 100644 src/main/kotlin/com/vacgom/backend/auth/domain/OauthConnector.kt rename src/main/kotlin/com/vacgom/backend/{domain/auth/oauth => auth/domain}/OauthUriGenerator.kt (53%) rename src/main/kotlin/com/vacgom/backend/{domain/auth/oauth => auth/domain}/constants/ProviderType.kt (90%) rename src/main/kotlin/com/vacgom/backend/{domain/auth => auth/domain}/constants/Role.kt (59%) rename src/main/kotlin/com/vacgom/backend/{infrastructure/auth/oauth => auth/infrastructure}/kakao/KakaoConnector.kt (86%) rename src/main/kotlin/com/vacgom/backend/{infrastructure/auth/oauth => auth/infrastructure}/kakao/KakaoUriGenerator.kt (73%) rename src/main/kotlin/com/vacgom/backend/{infrastructure/auth/oauth => auth/infrastructure}/kakao/model/KakaoProperties.kt (93%) rename src/main/kotlin/com/vacgom/backend/{presentation/auth => auth/presentation}/OAuthController.kt (84%) rename src/main/kotlin/com/vacgom/backend/{presentation/auth => auth/presentation}/SignUpController.kt (78%) create mode 100644 src/main/kotlin/com/vacgom/backend/disease/application/DiseaseService.kt create mode 100644 src/main/kotlin/com/vacgom/backend/disease/application/dto/request/FilterRequest.kt create mode 100644 src/main/kotlin/com/vacgom/backend/disease/application/dto/response/DiseaseResponse.kt create mode 100644 src/main/kotlin/com/vacgom/backend/disease/domain/Disease.kt rename src/main/kotlin/com/vacgom/backend/{domain/disease => disease/domain/constants}/AgeCondition.kt (84%) rename src/main/kotlin/com/vacgom/backend/{domain/disease => disease/domain/constants}/HealthCondition.kt (91%) rename src/main/kotlin/com/vacgom/backend/{infrastructure/disease => disease/infrastructure}/persistence/DiseaseRepository.kt (52%) rename src/main/kotlin/com/vacgom/backend/{presentation/disease => disease/presentation}/DiseaseController.kt (70%) delete mode 100644 src/main/kotlin/com/vacgom/backend/domain/auth/oauth/OauthConnector.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/domain/disease/Disease.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/domain/inoculation/Inoculation.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/domain/inoculation/constants/VaccinationType.kt rename src/main/kotlin/com/vacgom/backend/{application/inoculation/dto => inoculation/application}/InoculationService.kt (85%) create mode 100644 src/main/kotlin/com/vacgom/backend/inoculation/application/VaccineService.kt create mode 100644 src/main/kotlin/com/vacgom/backend/inoculation/application/dto/request/DiseaseNameRequest.kt rename src/main/kotlin/com/vacgom/backend/{application/inoculation => inoculation/application}/dto/response/InoculationDetailResponse.kt (82%) rename src/main/kotlin/com/vacgom/backend/{application/inoculation => inoculation/application}/dto/response/InoculationSimpleResponse.kt (78%) create mode 100644 src/main/kotlin/com/vacgom/backend/inoculation/application/dto/response/VaccineResponse.kt create mode 100644 src/main/kotlin/com/vacgom/backend/inoculation/domain/Inoculation.kt rename src/main/kotlin/com/vacgom/backend/{domain/inoculation => inoculation/domain}/Vaccination.kt (84%) create mode 100644 src/main/kotlin/com/vacgom/backend/inoculation/domain/constants/VaccinationType.kt rename src/main/kotlin/com/vacgom/backend/{exception/inoculation => inoculation/exception}/VaccineError.kt (88%) rename src/main/kotlin/com/vacgom/backend/{infrastructure/inoculation => inoculation/infrastructure}/persistence/InoculationRepository.kt (83%) rename src/main/kotlin/com/vacgom/backend/{infrastructure/inoculation => inoculation/infrastructure}/persistence/VaccinationRepository.kt (62%) create mode 100644 src/main/kotlin/com/vacgom/backend/member/application/MemberService.kt create mode 100644 src/main/kotlin/com/vacgom/backend/member/application/dto/request/UpdateHealthConditionRequest.kt rename src/main/kotlin/com/vacgom/backend/{domain/member => member/domain}/HealthProfile.kt (54%) rename src/main/kotlin/com/vacgom/backend/{domain/member => member/domain}/Member.kt (76%) rename src/main/kotlin/com/vacgom/backend/{domain/member => member/domain}/MemberDetails.kt (87%) rename src/main/kotlin/com/vacgom/backend/{domain/member => member/domain}/Nickname.kt (93%) rename src/main/kotlin/com/vacgom/backend/{domain/member => member/domain}/constants/Sex.kt (77%) rename src/main/kotlin/com/vacgom/backend/{exception/member => member/exception}/HealthConditionError.kt (62%) rename src/main/kotlin/com/vacgom/backend/{exception/member => member/exception}/MemberError.kt (91%) rename src/main/kotlin/com/vacgom/backend/{exception/member => member/exception}/NicknameError.kt (95%) rename src/main/kotlin/com/vacgom/backend/{infrastructure/member => member/infrastructure}/persistence/HealthProfileRepository.kt (57%) rename src/main/kotlin/com/vacgom/backend/{infrastructure/member => member/infrastructure}/persistence/MemberRepository.kt (59%) create mode 100644 src/main/kotlin/com/vacgom/backend/member/presentation/MeController.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/presentation/disease/dto/FilterRequest.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/presentation/member/MeController.kt delete mode 100644 src/main/kotlin/com/vacgom/backend/presentation/member/dto/UpdateHealthConditionRequest.kt create mode 100644 src/main/kotlin/com/vacgom/backend/search/application/SearchService.kt create mode 100644 src/main/kotlin/com/vacgom/backend/search/application/dto/DiseaseSearchResponse.kt create mode 100644 src/main/kotlin/com/vacgom/backend/search/application/dto/VaccinationSearchResponse.kt diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/request/MemberInfoRequest.kt b/src/main/kotlin/com/vacgom/backend/application/auth/dto/request/MemberInfoRequest.kt deleted file mode 100644 index 27df719..0000000 --- a/src/main/kotlin/com/vacgom/backend/application/auth/dto/request/MemberInfoRequest.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.vacgom.backend.application.auth.dto.request - -import com.vacgom.backend.domain.disease.HealthCondition - -data class MemberInfoRequest( - val nickname: String, - val healthConditions: MutableList, -) diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/MeResponse.kt b/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/MeResponse.kt deleted file mode 100644 index 9b87466..0000000 --- a/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/MeResponse.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.vacgom.backend.application.auth.dto.response - -import com.vacgom.backend.domain.member.Member - -class MeResponse( - val id: String, - val nickname: String?, - val level: String, - val healthConditions: List, -) { - companion object { - fun of(member: Member): MeResponse { - return MeResponse( - id = member.id.toString(), - nickname = member.nickname?.nickname, - level = "레벨", - healthConditions = member.healthProfiles.map { HealthConditionResponse.of(it.healthCondition) }, - ) - } - } -} diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/MemberResponse.kt b/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/MemberResponse.kt deleted file mode 100644 index 5422b2b..0000000 --- a/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/MemberResponse.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.vacgom.backend.application.auth.dto.response - -import com.vacgom.backend.domain.auth.constants.Role -import java.util.* - -data class MemberResponse( - val memberId: UUID, - val role: Role -) diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/ResourceIdResponse.kt b/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/ResourceIdResponse.kt deleted file mode 100644 index 6aeac75..0000000 --- a/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/ResourceIdResponse.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.vacgom.backend.application.auth.dto.response - -data class ResourceIdResponse( - val id: Long -) diff --git a/src/main/kotlin/com/vacgom/backend/application/disease/DiseaseService.kt b/src/main/kotlin/com/vacgom/backend/application/disease/DiseaseService.kt deleted file mode 100644 index 8f22c4f..0000000 --- a/src/main/kotlin/com/vacgom/backend/application/disease/DiseaseService.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.vacgom.backend.application.disease - -import com.vacgom.backend.domain.disease.Disease -import com.vacgom.backend.infrastructure.disease.persistence.DiseaseRepository -import org.springframework.stereotype.Service - -@Service -class DiseaseService( - private val diseaseRepository: DiseaseRepository, -) { - fun findAll(): List { - return diseaseRepository.findAll() - } -} diff --git a/src/main/kotlin/com/vacgom/backend/application/disease/dto/request/DiseaseFilterRequest.kt b/src/main/kotlin/com/vacgom/backend/application/disease/dto/request/DiseaseFilterRequest.kt deleted file mode 100644 index 478a2fd..0000000 --- a/src/main/kotlin/com/vacgom/backend/application/disease/dto/request/DiseaseFilterRequest.kt +++ /dev/null @@ -1,7 +0,0 @@ -import com.vacgom.backend.domain.disease.AgeCondition -import com.vacgom.backend.domain.disease.HealthCondition - -class DiseaseFilterRequest( - val age: List, - val condition: List, -) diff --git a/src/main/kotlin/com/vacgom/backend/application/disease/dto/response/DiseaseResponse.kt b/src/main/kotlin/com/vacgom/backend/application/disease/dto/response/DiseaseResponse.kt deleted file mode 100644 index 8a619fa..0000000 --- a/src/main/kotlin/com/vacgom/backend/application/disease/dto/response/DiseaseResponse.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.vacgom.backend.application.disease.dto.response - -import com.vacgom.backend.domain.disease.Disease - -class DiseaseResponse( - val id: Long?, - val name: String, - val iconImage: String?, - val description: String?, -) { - companion object { - fun of(disease: Disease): DiseaseResponse { - return DiseaseResponse( - id = disease.id, - name = disease.name, - iconImage = disease.iconImage, - description = disease.description, - ) - } - } -} diff --git a/src/main/kotlin/com/vacgom/backend/application/inoculation/dto/request/DiseaseNameRequest.kt b/src/main/kotlin/com/vacgom/backend/application/inoculation/dto/request/DiseaseNameRequest.kt deleted file mode 100644 index 42388e6..0000000 --- a/src/main/kotlin/com/vacgom/backend/application/inoculation/dto/request/DiseaseNameRequest.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.vacgom.backend.application.inoculation.dto.request - -data class DiseaseNameRequest( - val name: String -) diff --git a/src/main/kotlin/com/vacgom/backend/application/member/MemberService.kt b/src/main/kotlin/com/vacgom/backend/application/member/MemberService.kt deleted file mode 100644 index 6609d08..0000000 --- a/src/main/kotlin/com/vacgom/backend/application/member/MemberService.kt +++ /dev/null @@ -1,43 +0,0 @@ -package com.vacgom.backend.application.member - -import com.vacgom.backend.domain.disease.HealthCondition -import com.vacgom.backend.domain.member.HealthProfile -import com.vacgom.backend.domain.member.Member -import com.vacgom.backend.exception.member.MemberError -import com.vacgom.backend.global.exception.error.BusinessException -import com.vacgom.backend.infrastructure.member.persistence.MemberRepository -import jakarta.transaction.Transactional -import org.springframework.stereotype.Component -import java.util.* - -@Component -@Transactional -class MemberService( - private val memberRepository: MemberRepository, -) { - fun findMember(id: UUID): Member? { - return memberRepository.findById(id).orElseThrow() - } - - fun updateHealthCondition( - id: UUID, - healthProfiles: List, - ): Member { - val member = - memberRepository.findById(id).orElseThrow { - BusinessException(MemberError.NOT_FOUND) - } - - member.healthProfiles.clear() - member.healthProfiles.addAll(healthProfiles.map { HealthProfile(member, it) }) - return memberRepository.save(member) - } - - fun withdrawMember(id: UUID) { - val member = - memberRepository.findById(id).orElseThrow { - BusinessException(MemberError.NOT_FOUND) - } - memberRepository.delete(member) - } -} diff --git a/src/main/kotlin/com/vacgom/backend/application/search/SearchService.kt b/src/main/kotlin/com/vacgom/backend/application/search/SearchService.kt deleted file mode 100644 index 302e624..0000000 --- a/src/main/kotlin/com/vacgom/backend/application/search/SearchService.kt +++ /dev/null @@ -1,67 +0,0 @@ -package com.vacgom.backend.application.search - -import com.vacgom.backend.application.disease.DiseaseService -import com.vacgom.backend.application.search.dto.DiseaseSearchResponse -import com.vacgom.backend.application.search.dto.VaccinationSearchResponse -import com.vacgom.backend.domain.disease.AgeCondition -import com.vacgom.backend.domain.disease.Disease -import com.vacgom.backend.domain.disease.HealthCondition -import com.vacgom.backend.domain.inoculation.Vaccination -import com.vacgom.backend.infrastructure.inoculation.persistence.VaccinationRepository -import org.springframework.stereotype.Service - -@Service -class SearchService( - val vaccinationRepository: VaccinationRepository, - val diseaseService: DiseaseService, -) { - private fun findAllVaccinations(): List { - return vaccinationRepository.findAll() - } - - fun searchDisease( - age: List, - condition: List, - ): List { - val diseases = diseaseService.findAll() - - return diseases.filter { - isMatched(it, age, condition) - }.map { DiseaseSearchResponse.of(it) } - } - - fun searchVaccination( - age: List, - condition: List, - ): List { - val diseases = this.searchDisease(age, condition) - val vaccinations = findAllVaccinations() - - return vaccinations.filter { - diseases.any { disease -> it.diseaseName.contains(disease.name) } - }.map { VaccinationSearchResponse.of(it) } - } - - fun isMatched( - disease: Disease, - age: List, - condition: List, - ): Boolean { - var conditionValue = 0 - condition.forEach { - conditionValue = conditionValue or it.value - } - - var ageValue = 0 - age.forEach { - ageValue = ageValue or it.value - } - - return disease.ageFilter and ageValue == ageValue || - ( - disease.conditionalAgeFilter and ageValue == ageValue && - disease.healthConditionFilter and conditionValue > 0 && - disease.forbiddenHealthConditionFilter and conditionValue == 0 - ) - } -} diff --git a/src/main/kotlin/com/vacgom/backend/application/search/dto/DiseaseSearchResponse.kt b/src/main/kotlin/com/vacgom/backend/application/search/dto/DiseaseSearchResponse.kt deleted file mode 100644 index f1a58a1..0000000 --- a/src/main/kotlin/com/vacgom/backend/application/search/dto/DiseaseSearchResponse.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.vacgom.backend.application.search.dto - -import com.vacgom.backend.domain.disease.Disease - -class DiseaseSearchResponse( - val id: Long?, - val name: String, - val iconImage: String?, - val description: String?, -) { - companion object { - fun of(disease: Disease): DiseaseSearchResponse { - return DiseaseSearchResponse( - id = disease.id, - name = disease.name, - iconImage = disease.iconImage, - description = disease.description, - ) - } - } -} diff --git a/src/main/kotlin/com/vacgom/backend/application/search/dto/VaccinationSearchResponse.kt b/src/main/kotlin/com/vacgom/backend/application/search/dto/VaccinationSearchResponse.kt deleted file mode 100644 index 5b9b45f..0000000 --- a/src/main/kotlin/com/vacgom/backend/application/search/dto/VaccinationSearchResponse.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.vacgom.backend.application.search.dto - -import com.vacgom.backend.domain.inoculation.Vaccination - -class VaccinationSearchResponse( - val id: String?, - val vaccineName: String, - val diseaseName: String, - val iconImage: String?, -) { - companion object { - fun of(vaccine: Vaccination): VaccinationSearchResponse { - return VaccinationSearchResponse( - id = vaccine.id?.toString(), - vaccineName = vaccine.vaccineName, - diseaseName = vaccine.diseaseName, - iconImage = "iconImage", - ) - } - } -} diff --git a/src/main/kotlin/com/vacgom/backend/application/vaccine/dto/VaccineResponse.kt b/src/main/kotlin/com/vacgom/backend/application/vaccine/dto/VaccineResponse.kt deleted file mode 100644 index d10ee32..0000000 --- a/src/main/kotlin/com/vacgom/backend/application/vaccine/dto/VaccineResponse.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.vacgom.backend.application.vaccine.dto - -class VaccineResponse( - val id: String?, - val name: String, - val diseases: List, -) diff --git a/src/main/kotlin/com/vacgom/backend/application/vaccine/dto/VaccineService.kt b/src/main/kotlin/com/vacgom/backend/application/vaccine/dto/VaccineService.kt deleted file mode 100644 index 1b11d25..0000000 --- a/src/main/kotlin/com/vacgom/backend/application/vaccine/dto/VaccineService.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.vacgom.backend.application.vaccine.dto - -import com.vacgom.backend.application.disease.DiseaseService -import com.vacgom.backend.exception.inoculation.VaccineError -import com.vacgom.backend.global.exception.error.BusinessException -import com.vacgom.backend.infrastructure.inoculation.persistence.VaccinationRepository -import org.springframework.stereotype.Service -import java.util.* - -@Service -class VaccineService( - val vaccineRepository: VaccinationRepository, - val diseaseService: DiseaseService, -) { - fun getVaccine(id: String): VaccineResponse { - val vaccine = - vaccineRepository.findById(UUID.fromString(id)) - .orElseThrow { throw BusinessException(VaccineError.UNKNOWN_VACCINE_REQUESTED) } - - val diseases = diseaseService.findAll() - - return VaccineResponse( - id = vaccine.id?.toString(), - name = vaccine.vaccineName, - diseases = - diseases.filter { vaccine.diseaseName.contains(it.name) } - .mapNotNull { it.id } - .toList(), - ) - } -} diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/AuthFactory.kt b/src/main/kotlin/com/vacgom/backend/auth/application/AuthFactory.kt similarity index 79% rename from src/main/kotlin/com/vacgom/backend/application/auth/AuthFactory.kt rename to src/main/kotlin/com/vacgom/backend/auth/application/AuthFactory.kt index e43a50d..2c9f946 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/AuthFactory.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/application/AuthFactory.kt @@ -1,8 +1,8 @@ -package com.vacgom.backend.application.auth +package com.vacgom.backend.auth.application -import com.vacgom.backend.domain.auth.oauth.OauthConnector -import com.vacgom.backend.domain.auth.oauth.OauthUriGenerator -import com.vacgom.backend.domain.auth.oauth.constants.ProviderType +import com.vacgom.backend.auth.domain.OauthConnector +import com.vacgom.backend.auth.domain.OauthUriGenerator +import com.vacgom.backend.auth.domain.constants.ProviderType import com.vacgom.backend.global.exception.error.BusinessException import com.vacgom.backend.global.security.exception.AuthError import org.springframework.stereotype.Component diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/AuthService.kt b/src/main/kotlin/com/vacgom/backend/auth/application/AuthService.kt similarity index 77% rename from src/main/kotlin/com/vacgom/backend/application/auth/AuthService.kt rename to src/main/kotlin/com/vacgom/backend/auth/application/AuthService.kt index 5a6509f..32c6dd7 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/AuthService.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/application/AuthService.kt @@ -1,13 +1,13 @@ -package com.vacgom.backend.application.auth +package com.vacgom.backend.auth.application -import com.vacgom.backend.application.auth.dto.response.AuthResponse -import com.vacgom.backend.application.auth.dto.response.MemberResponse -import com.vacgom.backend.application.auth.dto.response.TokenResponse -import com.vacgom.backend.domain.auth.constants.Role.ROLE_TEMP_USER -import com.vacgom.backend.domain.auth.oauth.constants.ProviderType -import com.vacgom.backend.domain.member.Member +import com.vacgom.backend.auth.application.dto.response.AuthResponse +import com.vacgom.backend.auth.application.dto.response.MemberResponse +import com.vacgom.backend.auth.application.dto.response.TokenResponse +import com.vacgom.backend.auth.domain.constants.ProviderType +import com.vacgom.backend.auth.domain.constants.Role.ROLE_TEMP_USER import com.vacgom.backend.global.security.jwt.JwtFactory -import com.vacgom.backend.infrastructure.member.persistence.MemberRepository +import com.vacgom.backend.member.domain.Member +import com.vacgom.backend.member.infrastructure.persistence.MemberRepository import jakarta.transaction.Transactional import org.springframework.http.HttpHeaders import org.springframework.stereotype.Component diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/VacgomSignupService.kt b/src/main/kotlin/com/vacgom/backend/auth/application/VacgomSignupService.kt similarity index 73% rename from src/main/kotlin/com/vacgom/backend/application/auth/VacgomSignupService.kt rename to src/main/kotlin/com/vacgom/backend/auth/application/VacgomSignupService.kt index dcb7596..bc76123 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/VacgomSignupService.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/application/VacgomSignupService.kt @@ -1,23 +1,23 @@ -package com.vacgom.backend.application.auth +package com.vacgom.backend.auth.application -import com.vacgom.backend.application.auth.dto.request.SignUpRequest -import com.vacgom.backend.application.auth.dto.response.AuthResponse -import com.vacgom.backend.application.auth.dto.response.MemberResponse -import com.vacgom.backend.application.auth.dto.response.TokenResponse -import com.vacgom.backend.domain.auth.constants.Role -import com.vacgom.backend.domain.inoculation.Inoculation -import com.vacgom.backend.domain.member.HealthProfile -import com.vacgom.backend.domain.member.MemberDetails -import com.vacgom.backend.domain.member.Nickname -import com.vacgom.backend.exception.inoculation.VaccineError -import com.vacgom.backend.exception.member.MemberError -import com.vacgom.backend.exception.member.NicknameError +import com.vacgom.backend.auth.application.dto.request.SignUpRequest +import com.vacgom.backend.auth.application.dto.response.AuthResponse +import com.vacgom.backend.auth.application.dto.response.MemberResponse +import com.vacgom.backend.auth.application.dto.response.TokenResponse +import com.vacgom.backend.auth.domain.constants.Role import com.vacgom.backend.global.exception.error.BusinessException import com.vacgom.backend.global.security.jwt.JwtFactory -import com.vacgom.backend.infrastructure.inoculation.persistence.InoculationRepository -import com.vacgom.backend.infrastructure.inoculation.persistence.VaccinationRepository -import com.vacgom.backend.infrastructure.member.persistence.HealthProfileRepository -import com.vacgom.backend.infrastructure.member.persistence.MemberRepository +import com.vacgom.backend.inoculation.domain.Inoculation +import com.vacgom.backend.inoculation.exception.VaccineError +import com.vacgom.backend.inoculation.infrastructure.persistence.InoculationRepository +import com.vacgom.backend.inoculation.infrastructure.persistence.VaccinationRepository +import com.vacgom.backend.member.domain.HealthProfile +import com.vacgom.backend.member.domain.MemberDetails +import com.vacgom.backend.member.domain.Nickname +import com.vacgom.backend.member.exception.MemberError +import com.vacgom.backend.member.exception.NicknameError +import com.vacgom.backend.member.infrastructure.persistence.HealthProfileRepository +import com.vacgom.backend.member.infrastructure.persistence.MemberRepository import jakarta.transaction.Transactional import org.slf4j.Logger import org.springframework.stereotype.Service diff --git a/src/main/kotlin/com/vacgom/backend/auth/application/dto/request/MemberInfoRequest.kt b/src/main/kotlin/com/vacgom/backend/auth/application/dto/request/MemberInfoRequest.kt new file mode 100644 index 0000000..20b5a2c --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/auth/application/dto/request/MemberInfoRequest.kt @@ -0,0 +1,8 @@ +package com.vacgom.backend.auth.application.dto.request + +import com.vacgom.backend.disease.domain.constants.HealthCondition + +data class MemberInfoRequest( + val nickname: String, + val healthConditions: MutableList, +) diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/request/SignUpRequest.kt b/src/main/kotlin/com/vacgom/backend/auth/application/dto/request/SignUpRequest.kt similarity index 68% rename from src/main/kotlin/com/vacgom/backend/application/auth/dto/request/SignUpRequest.kt rename to src/main/kotlin/com/vacgom/backend/auth/application/dto/request/SignUpRequest.kt index 00fa1b4..6b536d1 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/dto/request/SignUpRequest.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/application/dto/request/SignUpRequest.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.application.auth.dto.request +package com.vacgom.backend.auth.application.dto.request data class SignUpRequest( val memberInfo: MemberInfoRequest, diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/request/VaccinationInfoRequest.kt b/src/main/kotlin/com/vacgom/backend/auth/application/dto/request/VaccinationInfoRequest.kt similarity index 74% rename from src/main/kotlin/com/vacgom/backend/application/auth/dto/request/VaccinationInfoRequest.kt rename to src/main/kotlin/com/vacgom/backend/auth/application/dto/request/VaccinationInfoRequest.kt index b7312b7..eea5612 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/dto/request/VaccinationInfoRequest.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/application/dto/request/VaccinationInfoRequest.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.application.auth.dto.request +package com.vacgom.backend.auth.application.dto.request data class VaccinationInfoRequest( val name: String, diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/request/Vaccine.kt b/src/main/kotlin/com/vacgom/backend/auth/application/dto/request/Vaccine.kt similarity index 89% rename from src/main/kotlin/com/vacgom/backend/application/auth/dto/request/Vaccine.kt rename to src/main/kotlin/com/vacgom/backend/auth/application/dto/request/Vaccine.kt index c21f7bb..d3270bf 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/dto/request/Vaccine.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/application/dto/request/Vaccine.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.application.auth.dto.request +package com.vacgom.backend.auth.application.dto.request import java.time.LocalDate diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/AuthResponse.kt b/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/AuthResponse.kt similarity index 62% rename from src/main/kotlin/com/vacgom/backend/application/auth/dto/response/AuthResponse.kt rename to src/main/kotlin/com/vacgom/backend/auth/application/dto/response/AuthResponse.kt index f6a7497..92cb739 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/AuthResponse.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/AuthResponse.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.application.auth.dto.response +package com.vacgom.backend.auth.application.dto.response data class AuthResponse( val member: MemberResponse, diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/HealthConditionResponse.kt b/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/HealthConditionResponse.kt similarity index 75% rename from src/main/kotlin/com/vacgom/backend/application/auth/dto/response/HealthConditionResponse.kt rename to src/main/kotlin/com/vacgom/backend/auth/application/dto/response/HealthConditionResponse.kt index 35700f4..bd66c67 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/HealthConditionResponse.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/HealthConditionResponse.kt @@ -1,6 +1,6 @@ -package com.vacgom.backend.application.auth.dto.response +package com.vacgom.backend.auth.application.dto.response -import com.vacgom.backend.domain.disease.HealthCondition +import com.vacgom.backend.disease.domain.constants.HealthCondition class HealthConditionResponse( val code: String, diff --git a/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/MeResponse.kt b/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/MeResponse.kt new file mode 100644 index 0000000..fff4a9a --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/MeResponse.kt @@ -0,0 +1,21 @@ +package com.vacgom.backend.auth.application.dto.response + +import com.vacgom.backend.member.domain.Member + +class MeResponse( + val id: String, + val nickname: String?, + val level: String, + val healthConditions: List, +) { + companion object { + fun of(member: Member): MeResponse { + return MeResponse( + id = member.id.toString(), + nickname = member.nickname?.nickname, + level = "레벨", + healthConditions = member.healthProfiles.map { HealthConditionResponse.of(it.healthCondition) }, + ) + } + } +} diff --git a/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/MemberResponse.kt b/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/MemberResponse.kt new file mode 100644 index 0000000..21d6759 --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/MemberResponse.kt @@ -0,0 +1,9 @@ +package com.vacgom.backend.auth.application.dto.response + +import com.vacgom.backend.auth.domain.constants.Role +import java.util.* + +data class MemberResponse( + val memberId: UUID, + val role: Role +) diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/OauthTokenResponse.kt b/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/OauthTokenResponse.kt similarity index 81% rename from src/main/kotlin/com/vacgom/backend/application/auth/dto/response/OauthTokenResponse.kt rename to src/main/kotlin/com/vacgom/backend/auth/application/dto/response/OauthTokenResponse.kt index 83764af..abfe296 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/OauthTokenResponse.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/OauthTokenResponse.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.application.auth.dto.response +package com.vacgom.backend.auth.application.dto.response import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming diff --git a/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/ResourceIdResponse.kt b/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/ResourceIdResponse.kt new file mode 100644 index 0000000..eb06ab0 --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/ResourceIdResponse.kt @@ -0,0 +1,5 @@ +package com.vacgom.backend.auth.application.dto.response + +data class ResourceIdResponse( + val id: Long +) diff --git a/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/TokenResponse.kt b/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/TokenResponse.kt similarity index 52% rename from src/main/kotlin/com/vacgom/backend/application/auth/dto/response/TokenResponse.kt rename to src/main/kotlin/com/vacgom/backend/auth/application/dto/response/TokenResponse.kt index 07545c0..6c35a41 100644 --- a/src/main/kotlin/com/vacgom/backend/application/auth/dto/response/TokenResponse.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/application/dto/response/TokenResponse.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.application.auth.dto.response +package com.vacgom.backend.auth.application.dto.response data class TokenResponse( diff --git a/src/main/kotlin/com/vacgom/backend/auth/domain/OauthConnector.kt b/src/main/kotlin/com/vacgom/backend/auth/domain/OauthConnector.kt new file mode 100644 index 0000000..cdd3231 --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/auth/domain/OauthConnector.kt @@ -0,0 +1,11 @@ +package com.vacgom.backend.auth.domain + +import com.vacgom.backend.auth.application.dto.response.OauthTokenResponse +import com.vacgom.backend.auth.application.dto.response.ResourceIdResponse +import com.vacgom.backend.auth.domain.constants.ProviderType + +interface OauthConnector { + fun isSupported(provider: ProviderType): Boolean + fun fetchOauthToken(code: String): OauthTokenResponse + fun fetchMemberInfo(accessToken: String): ResourceIdResponse +} diff --git a/src/main/kotlin/com/vacgom/backend/domain/auth/oauth/OauthUriGenerator.kt b/src/main/kotlin/com/vacgom/backend/auth/domain/OauthUriGenerator.kt similarity index 53% rename from src/main/kotlin/com/vacgom/backend/domain/auth/oauth/OauthUriGenerator.kt rename to src/main/kotlin/com/vacgom/backend/auth/domain/OauthUriGenerator.kt index df89c50..7212a8c 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/auth/oauth/OauthUriGenerator.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/domain/OauthUriGenerator.kt @@ -1,6 +1,6 @@ -package com.vacgom.backend.domain.auth.oauth +package com.vacgom.backend.auth.domain -import com.vacgom.backend.domain.auth.oauth.constants.ProviderType +import com.vacgom.backend.auth.domain.constants.ProviderType import java.net.URI interface OauthUriGenerator { diff --git a/src/main/kotlin/com/vacgom/backend/domain/auth/oauth/constants/ProviderType.kt b/src/main/kotlin/com/vacgom/backend/auth/domain/constants/ProviderType.kt similarity index 90% rename from src/main/kotlin/com/vacgom/backend/domain/auth/oauth/constants/ProviderType.kt rename to src/main/kotlin/com/vacgom/backend/auth/domain/constants/ProviderType.kt index 904bca5..6d0981f 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/auth/oauth/constants/ProviderType.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/domain/constants/ProviderType.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.domain.auth.oauth.constants +package com.vacgom.backend.auth.domain.constants import com.vacgom.backend.global.exception.error.BusinessException import com.vacgom.backend.global.security.exception.AuthError diff --git a/src/main/kotlin/com/vacgom/backend/domain/auth/constants/Role.kt b/src/main/kotlin/com/vacgom/backend/auth/domain/constants/Role.kt similarity index 59% rename from src/main/kotlin/com/vacgom/backend/domain/auth/constants/Role.kt rename to src/main/kotlin/com/vacgom/backend/auth/domain/constants/Role.kt index 412b84e..78b6d09 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/auth/constants/Role.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/domain/constants/Role.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.domain.auth.constants +package com.vacgom.backend.auth.domain.constants enum class Role { ROLE_GUEST, diff --git a/src/main/kotlin/com/vacgom/backend/infrastructure/auth/oauth/kakao/KakaoConnector.kt b/src/main/kotlin/com/vacgom/backend/auth/infrastructure/kakao/KakaoConnector.kt similarity index 86% rename from src/main/kotlin/com/vacgom/backend/infrastructure/auth/oauth/kakao/KakaoConnector.kt rename to src/main/kotlin/com/vacgom/backend/auth/infrastructure/kakao/KakaoConnector.kt index b90c650..ad81550 100644 --- a/src/main/kotlin/com/vacgom/backend/infrastructure/auth/oauth/kakao/KakaoConnector.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/infrastructure/kakao/KakaoConnector.kt @@ -1,12 +1,12 @@ -package com.vacgom.backend.infrastructure.auth.oauth.kakao +package com.vacgom.backend.auth.infrastructure.kakao -import com.vacgom.backend.application.auth.dto.response.OauthTokenResponse -import com.vacgom.backend.application.auth.dto.response.ResourceIdResponse -import com.vacgom.backend.domain.auth.oauth.OauthConnector -import com.vacgom.backend.domain.auth.oauth.constants.ProviderType +import com.vacgom.backend.auth.application.dto.response.OauthTokenResponse +import com.vacgom.backend.auth.application.dto.response.ResourceIdResponse +import com.vacgom.backend.auth.domain.OauthConnector +import com.vacgom.backend.auth.domain.constants.ProviderType +import com.vacgom.backend.auth.infrastructure.kakao.model.KakaoProperties import com.vacgom.backend.global.exception.error.BusinessException import com.vacgom.backend.global.security.exception.AuthError -import com.vacgom.backend.infrastructure.auth.oauth.kakao.model.KakaoProperties import org.springframework.http.HttpEntity import org.springframework.http.HttpHeaders import org.springframework.http.HttpMethod diff --git a/src/main/kotlin/com/vacgom/backend/infrastructure/auth/oauth/kakao/KakaoUriGenerator.kt b/src/main/kotlin/com/vacgom/backend/auth/infrastructure/kakao/KakaoUriGenerator.kt similarity index 73% rename from src/main/kotlin/com/vacgom/backend/infrastructure/auth/oauth/kakao/KakaoUriGenerator.kt rename to src/main/kotlin/com/vacgom/backend/auth/infrastructure/kakao/KakaoUriGenerator.kt index 76e2272..f7c946c 100644 --- a/src/main/kotlin/com/vacgom/backend/infrastructure/auth/oauth/kakao/KakaoUriGenerator.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/infrastructure/kakao/KakaoUriGenerator.kt @@ -1,8 +1,8 @@ -package com.vacgom.backend.infrastructure.auth.oauth.kakao +package com.vacgom.backend.auth.infrastructure.kakao -import com.vacgom.backend.domain.auth.oauth.OauthUriGenerator -import com.vacgom.backend.domain.auth.oauth.constants.ProviderType -import com.vacgom.backend.infrastructure.auth.oauth.kakao.model.KakaoProperties +import com.vacgom.backend.auth.domain.OauthUriGenerator +import com.vacgom.backend.auth.domain.constants.ProviderType +import com.vacgom.backend.auth.infrastructure.kakao.model.KakaoProperties import org.springframework.stereotype.Component import org.springframework.web.util.UriComponentsBuilder import java.net.URI diff --git a/src/main/kotlin/com/vacgom/backend/infrastructure/auth/oauth/kakao/model/KakaoProperties.kt b/src/main/kotlin/com/vacgom/backend/auth/infrastructure/kakao/model/KakaoProperties.kt similarity index 93% rename from src/main/kotlin/com/vacgom/backend/infrastructure/auth/oauth/kakao/model/KakaoProperties.kt rename to src/main/kotlin/com/vacgom/backend/auth/infrastructure/kakao/model/KakaoProperties.kt index 426447e..f8d8c44 100644 --- a/src/main/kotlin/com/vacgom/backend/infrastructure/auth/oauth/kakao/model/KakaoProperties.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/infrastructure/kakao/model/KakaoProperties.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.infrastructure.auth.oauth.kakao.model +package com.vacgom.backend.auth.infrastructure.kakao.model import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Component diff --git a/src/main/kotlin/com/vacgom/backend/presentation/auth/OAuthController.kt b/src/main/kotlin/com/vacgom/backend/auth/presentation/OAuthController.kt similarity index 84% rename from src/main/kotlin/com/vacgom/backend/presentation/auth/OAuthController.kt rename to src/main/kotlin/com/vacgom/backend/auth/presentation/OAuthController.kt index 42256d2..238f5a2 100644 --- a/src/main/kotlin/com/vacgom/backend/presentation/auth/OAuthController.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/presentation/OAuthController.kt @@ -1,7 +1,7 @@ -package com.vacgom.backend.presentation.auth +package com.vacgom.backend.auth.presentation -import com.vacgom.backend.application.auth.AuthService -import com.vacgom.backend.application.auth.dto.response.AuthResponse +import com.vacgom.backend.auth.application.AuthService +import com.vacgom.backend.auth.application.dto.response.AuthResponse import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* diff --git a/src/main/kotlin/com/vacgom/backend/presentation/auth/SignUpController.kt b/src/main/kotlin/com/vacgom/backend/auth/presentation/SignUpController.kt similarity index 78% rename from src/main/kotlin/com/vacgom/backend/presentation/auth/SignUpController.kt rename to src/main/kotlin/com/vacgom/backend/auth/presentation/SignUpController.kt index 339a4c7..a8912fc 100644 --- a/src/main/kotlin/com/vacgom/backend/presentation/auth/SignUpController.kt +++ b/src/main/kotlin/com/vacgom/backend/auth/presentation/SignUpController.kt @@ -1,8 +1,8 @@ -package com.vacgom.backend.presentation.auth +package com.vacgom.backend.auth.presentation -import com.vacgom.backend.application.auth.VacgomSignupService -import com.vacgom.backend.application.auth.dto.request.SignUpRequest -import com.vacgom.backend.application.auth.dto.response.AuthResponse +import com.vacgom.backend.auth.application.VacgomSignupService +import com.vacgom.backend.auth.application.dto.request.SignUpRequest +import com.vacgom.backend.auth.application.dto.response.AuthResponse import com.vacgom.backend.global.security.annotation.AuthId import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* diff --git a/src/main/kotlin/com/vacgom/backend/disease/application/DiseaseService.kt b/src/main/kotlin/com/vacgom/backend/disease/application/DiseaseService.kt new file mode 100644 index 0000000..d60e2e8 --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/disease/application/DiseaseService.kt @@ -0,0 +1,14 @@ +package com.vacgom.backend.disease.application + +import com.vacgom.backend.disease.domain.Disease +import com.vacgom.backend.disease.infrastructure.persistence.DiseaseRepository +import org.springframework.stereotype.Service + +@Service +class DiseaseService( + private val diseaseRepository: DiseaseRepository, +) { + fun findAll(): List { + return diseaseRepository.findAll() + } +} diff --git a/src/main/kotlin/com/vacgom/backend/disease/application/dto/request/FilterRequest.kt b/src/main/kotlin/com/vacgom/backend/disease/application/dto/request/FilterRequest.kt new file mode 100644 index 0000000..47deeca --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/disease/application/dto/request/FilterRequest.kt @@ -0,0 +1,6 @@ +package com.vacgom.backend.disease.application.dto.request + +class FilterRequest( + val age: List, + val condition: List, +) diff --git a/src/main/kotlin/com/vacgom/backend/disease/application/dto/response/DiseaseResponse.kt b/src/main/kotlin/com/vacgom/backend/disease/application/dto/response/DiseaseResponse.kt new file mode 100644 index 0000000..02309ca --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/disease/application/dto/response/DiseaseResponse.kt @@ -0,0 +1,21 @@ +package com.vacgom.backend.disease.application.dto.response + +import com.vacgom.backend.disease.domain.Disease + +class DiseaseResponse( + val id: Long?, + val name: String, + val iconImage: String?, + val description: String?, +) { + companion object { + fun of(disease: Disease): DiseaseResponse { + return DiseaseResponse( + id = disease.id, + name = disease.name, + iconImage = disease.iconImage, + description = disease.description, + ) + } + } +} diff --git a/src/main/kotlin/com/vacgom/backend/disease/domain/Disease.kt b/src/main/kotlin/com/vacgom/backend/disease/domain/Disease.kt new file mode 100644 index 0000000..7cb55ea --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/disease/domain/Disease.kt @@ -0,0 +1,20 @@ +package com.vacgom.backend.disease.domain + +import com.vacgom.backend.global.auditing.BaseEntity +import jakarta.persistence.* + +@Entity() +@Table(name = "t_disease") +class Disease( + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "disease_id") + val id: Long? = null, + val name: String, + val iconImage: String?, + val description: String?, + val ageFilter: Int, + val conditionalAgeFilter: Int, + val healthConditionFilter: Int, + val forbiddenHealthConditionFilter: Int, +) : BaseEntity() diff --git a/src/main/kotlin/com/vacgom/backend/domain/disease/AgeCondition.kt b/src/main/kotlin/com/vacgom/backend/disease/domain/constants/AgeCondition.kt similarity index 84% rename from src/main/kotlin/com/vacgom/backend/domain/disease/AgeCondition.kt rename to src/main/kotlin/com/vacgom/backend/disease/domain/constants/AgeCondition.kt index 72bea95..73a3b26 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/disease/AgeCondition.kt +++ b/src/main/kotlin/com/vacgom/backend/disease/domain/constants/AgeCondition.kt @@ -1,8 +1,8 @@ -package com.vacgom.backend.domain.disease +package com.vacgom.backend.disease.domain.constants enum class AgeCondition( - val title: String, - val value: Int, + val title: String, + val value: Int, ) { ALL("전체", 0b000000), AGE19TO29("만 19-29세", 0b100000), diff --git a/src/main/kotlin/com/vacgom/backend/domain/disease/HealthCondition.kt b/src/main/kotlin/com/vacgom/backend/disease/domain/constants/HealthCondition.kt similarity index 91% rename from src/main/kotlin/com/vacgom/backend/domain/disease/HealthCondition.kt rename to src/main/kotlin/com/vacgom/backend/disease/domain/constants/HealthCondition.kt index 4e2de24..9796c0f 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/disease/HealthCondition.kt +++ b/src/main/kotlin/com/vacgom/backend/disease/domain/constants/HealthCondition.kt @@ -1,9 +1,9 @@ -package com.vacgom.backend.domain.disease +package com.vacgom.backend.disease.domain.constants enum class HealthCondition( - val code: Long, - val description: String, - val value: Int, + val code: Long, + val description: String, + val value: Int, ) { DIABETES(1, "당뇨병", 0b10000000000000), CHRONIC_CARDIOVASCULAR_DISEASE(2, "만성 심혈관질환", 0b01000000000000), diff --git a/src/main/kotlin/com/vacgom/backend/infrastructure/disease/persistence/DiseaseRepository.kt b/src/main/kotlin/com/vacgom/backend/disease/infrastructure/persistence/DiseaseRepository.kt similarity index 52% rename from src/main/kotlin/com/vacgom/backend/infrastructure/disease/persistence/DiseaseRepository.kt rename to src/main/kotlin/com/vacgom/backend/disease/infrastructure/persistence/DiseaseRepository.kt index c0de32f..3bd5549 100644 --- a/src/main/kotlin/com/vacgom/backend/infrastructure/disease/persistence/DiseaseRepository.kt +++ b/src/main/kotlin/com/vacgom/backend/disease/infrastructure/persistence/DiseaseRepository.kt @@ -1,6 +1,6 @@ -package com.vacgom.backend.infrastructure.disease.persistence +package com.vacgom.backend.disease.infrastructure.persistence -import com.vacgom.backend.domain.disease.Disease +import com.vacgom.backend.disease.domain.Disease import org.springframework.data.jpa.repository.JpaRepository interface DiseaseRepository : JpaRepository diff --git a/src/main/kotlin/com/vacgom/backend/presentation/disease/DiseaseController.kt b/src/main/kotlin/com/vacgom/backend/disease/presentation/DiseaseController.kt similarity index 70% rename from src/main/kotlin/com/vacgom/backend/presentation/disease/DiseaseController.kt rename to src/main/kotlin/com/vacgom/backend/disease/presentation/DiseaseController.kt index efc8de2..ed48af8 100644 --- a/src/main/kotlin/com/vacgom/backend/presentation/disease/DiseaseController.kt +++ b/src/main/kotlin/com/vacgom/backend/disease/presentation/DiseaseController.kt @@ -1,7 +1,7 @@ -package com.vacgom.backend.presentation.disease +package com.vacgom.backend.disease.presentation -import com.vacgom.backend.application.disease.DiseaseService -import com.vacgom.backend.domain.disease.HealthCondition +import com.vacgom.backend.disease.application.DiseaseService +import com.vacgom.backend.disease.domain.constants.HealthCondition import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping @@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/api/v1/diseases") class DiseaseController( - val diseaseService: DiseaseService, + val diseaseService: DiseaseService, ) { @GetMapping("/healthConditions") fun healthConditions(): ResponseEntity>> { diff --git a/src/main/kotlin/com/vacgom/backend/domain/auth/oauth/OauthConnector.kt b/src/main/kotlin/com/vacgom/backend/domain/auth/oauth/OauthConnector.kt deleted file mode 100644 index bededa0..0000000 --- a/src/main/kotlin/com/vacgom/backend/domain/auth/oauth/OauthConnector.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.vacgom.backend.domain.auth.oauth - -import com.vacgom.backend.application.auth.dto.response.OauthTokenResponse -import com.vacgom.backend.application.auth.dto.response.ResourceIdResponse -import com.vacgom.backend.domain.auth.oauth.constants.ProviderType - -interface OauthConnector { - fun isSupported(provider: ProviderType): Boolean - fun fetchOauthToken(code: String): OauthTokenResponse - fun fetchMemberInfo(accessToken: String): ResourceIdResponse -} diff --git a/src/main/kotlin/com/vacgom/backend/domain/disease/Disease.kt b/src/main/kotlin/com/vacgom/backend/domain/disease/Disease.kt deleted file mode 100644 index ec3d270..0000000 --- a/src/main/kotlin/com/vacgom/backend/domain/disease/Disease.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.vacgom.backend.domain.disease - -import com.vacgom.backend.global.auditing.BaseEntity -import jakarta.persistence.* - -@Entity() -@Table(name = "t_disease") -class Disease( - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "disease_id") - val id: Long? = null, - val name: String, - val iconImage: String?, - val description: String?, - val ageFilter: Int, - val conditionalAgeFilter: Int, - val healthConditionFilter: Int, - val forbiddenHealthConditionFilter: Int, -) : BaseEntity() diff --git a/src/main/kotlin/com/vacgom/backend/domain/inoculation/Inoculation.kt b/src/main/kotlin/com/vacgom/backend/domain/inoculation/Inoculation.kt deleted file mode 100644 index 9887f02..0000000 --- a/src/main/kotlin/com/vacgom/backend/domain/inoculation/Inoculation.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.vacgom.backend.domain.inoculation - -import com.fasterxml.jackson.annotation.JsonFormat -import com.vacgom.backend.domain.member.Member -import com.vacgom.backend.global.auditing.BaseEntity -import jakarta.persistence.* -import org.hibernate.annotations.GenericGenerator -import java.time.LocalDate -import java.util.* - -@Entity -@Table(name = "t_inoculation") -class Inoculation( - val inoculationOrder: Long, - val inoculationOrderString: String, - @JsonFormat( - shape = JsonFormat.Shape.STRING, - pattern = "yyyy-MM-dd", - ) - val date: LocalDate, - val agency: String, - val vaccineName: String?, - val vaccineBrandName: String?, - val lotNumber: String?, - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "member_id") - val member: Member, - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "vaccination_id") - val vaccination: Vaccination, -) : BaseEntity() { - @Id - @GenericGenerator(name = "uuid2", strategy = "uuid2") - @Column(columnDefinition = "BINARY(16)", name = "vaccine_id") - val id: UUID = UUID.randomUUID() -} diff --git a/src/main/kotlin/com/vacgom/backend/domain/inoculation/constants/VaccinationType.kt b/src/main/kotlin/com/vacgom/backend/domain/inoculation/constants/VaccinationType.kt deleted file mode 100644 index 02ca46e..0000000 --- a/src/main/kotlin/com/vacgom/backend/domain/inoculation/constants/VaccinationType.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.vacgom.backend.domain.inoculation.constants - -enum class VaccinationType { - NATION, - EXTRA; -} diff --git a/src/main/kotlin/com/vacgom/backend/global/security/filter/JwtAuthFilter.kt b/src/main/kotlin/com/vacgom/backend/global/security/filter/JwtAuthFilter.kt index c5935fd..f87af8f 100644 --- a/src/main/kotlin/com/vacgom/backend/global/security/filter/JwtAuthFilter.kt +++ b/src/main/kotlin/com/vacgom/backend/global/security/filter/JwtAuthFilter.kt @@ -1,6 +1,6 @@ package com.vacgom.backend.global.security.filter -import com.vacgom.backend.domain.auth.constants.Role.ROLE_GUEST +import com.vacgom.backend.auth.domain.constants.Role.ROLE_GUEST import com.vacgom.backend.global.security.jwt.JwtFactory import com.vacgom.backend.global.security.model.CustomUser import jakarta.servlet.FilterChain diff --git a/src/main/kotlin/com/vacgom/backend/global/security/jwt/JwtFactory.kt b/src/main/kotlin/com/vacgom/backend/global/security/jwt/JwtFactory.kt index 3d12f5c..294dc8e 100644 --- a/src/main/kotlin/com/vacgom/backend/global/security/jwt/JwtFactory.kt +++ b/src/main/kotlin/com/vacgom/backend/global/security/jwt/JwtFactory.kt @@ -1,9 +1,9 @@ package com.vacgom.backend.global.security.jwt -import com.vacgom.backend.domain.member.Member import com.vacgom.backend.global.exception.error.BusinessException import com.vacgom.backend.global.security.exception.AuthError import com.vacgom.backend.global.security.model.CustomUser +import com.vacgom.backend.member.domain.Member import io.jsonwebtoken.* import io.jsonwebtoken.io.Decoders import io.jsonwebtoken.security.Keys diff --git a/src/main/kotlin/com/vacgom/backend/application/inoculation/dto/InoculationService.kt b/src/main/kotlin/com/vacgom/backend/inoculation/application/InoculationService.kt similarity index 85% rename from src/main/kotlin/com/vacgom/backend/application/inoculation/dto/InoculationService.kt rename to src/main/kotlin/com/vacgom/backend/inoculation/application/InoculationService.kt index 4e41e0b..d280785 100644 --- a/src/main/kotlin/com/vacgom/backend/application/inoculation/dto/InoculationService.kt +++ b/src/main/kotlin/com/vacgom/backend/inoculation/application/InoculationService.kt @@ -1,13 +1,13 @@ -package com.vacgom.backend.application.inoculation.dto +package com.vacgom.backend.inoculation.application -import com.vacgom.backend.application.inoculation.dto.request.DiseaseNameRequest -import com.vacgom.backend.application.inoculation.dto.response.InoculationDetailResponse -import com.vacgom.backend.application.inoculation.dto.response.InoculationSimpleResponse -import com.vacgom.backend.domain.inoculation.constants.VaccinationType import com.vacgom.backend.global.exception.error.BusinessException import com.vacgom.backend.global.exception.error.GlobalError -import com.vacgom.backend.infrastructure.inoculation.persistence.InoculationRepository -import com.vacgom.backend.infrastructure.inoculation.persistence.VaccinationRepository +import com.vacgom.backend.inoculation.application.dto.request.DiseaseNameRequest +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 +import com.vacgom.backend.inoculation.infrastructure.persistence.InoculationRepository +import com.vacgom.backend.inoculation.infrastructure.persistence.VaccinationRepository import jakarta.transaction.Transactional import org.springframework.stereotype.Service import java.util.* diff --git a/src/main/kotlin/com/vacgom/backend/inoculation/application/VaccineService.kt b/src/main/kotlin/com/vacgom/backend/inoculation/application/VaccineService.kt new file mode 100644 index 0000000..3dea030 --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/inoculation/application/VaccineService.kt @@ -0,0 +1,32 @@ +package com.vacgom.backend.inoculation.application + +import com.vacgom.backend.disease.application.DiseaseService +import com.vacgom.backend.global.exception.error.BusinessException +import com.vacgom.backend.inoculation.application.dto.response.VaccineResponse +import com.vacgom.backend.inoculation.exception.VaccineError +import com.vacgom.backend.inoculation.infrastructure.persistence.VaccinationRepository +import org.springframework.stereotype.Service +import java.util.* + +@Service +class VaccineService( + val vaccineRepository: VaccinationRepository, + val diseaseService: DiseaseService, +) { + fun getVaccine(id: String): VaccineResponse { + val vaccine = + vaccineRepository.findById(UUID.fromString(id)) + .orElseThrow { throw BusinessException(VaccineError.UNKNOWN_VACCINE_REQUESTED) } + + val diseases = diseaseService.findAll() + + return VaccineResponse( + id = vaccine.id?.toString(), + name = vaccine.vaccineName, + diseases = + diseases.filter { vaccine.diseaseName.contains(it.name) } + .mapNotNull { it.id } + .toList(), + ) + } +} diff --git a/src/main/kotlin/com/vacgom/backend/inoculation/application/dto/request/DiseaseNameRequest.kt b/src/main/kotlin/com/vacgom/backend/inoculation/application/dto/request/DiseaseNameRequest.kt new file mode 100644 index 0000000..62fa6a5 --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/inoculation/application/dto/request/DiseaseNameRequest.kt @@ -0,0 +1,5 @@ +package com.vacgom.backend.inoculation.application.dto.request + +data class DiseaseNameRequest( + val name: String +) diff --git a/src/main/kotlin/com/vacgom/backend/application/inoculation/dto/response/InoculationDetailResponse.kt b/src/main/kotlin/com/vacgom/backend/inoculation/application/dto/response/InoculationDetailResponse.kt similarity index 82% rename from src/main/kotlin/com/vacgom/backend/application/inoculation/dto/response/InoculationDetailResponse.kt rename to src/main/kotlin/com/vacgom/backend/inoculation/application/dto/response/InoculationDetailResponse.kt index b3f692b..7885e65 100644 --- a/src/main/kotlin/com/vacgom/backend/application/inoculation/dto/response/InoculationDetailResponse.kt +++ b/src/main/kotlin/com/vacgom/backend/inoculation/application/dto/response/InoculationDetailResponse.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.application.inoculation.dto.response +package com.vacgom.backend.inoculation.application.dto.response import java.time.LocalDate diff --git a/src/main/kotlin/com/vacgom/backend/application/inoculation/dto/response/InoculationSimpleResponse.kt b/src/main/kotlin/com/vacgom/backend/inoculation/application/dto/response/InoculationSimpleResponse.kt similarity index 78% rename from src/main/kotlin/com/vacgom/backend/application/inoculation/dto/response/InoculationSimpleResponse.kt rename to src/main/kotlin/com/vacgom/backend/inoculation/application/dto/response/InoculationSimpleResponse.kt index 043a7b4..0ceaa2a 100644 --- a/src/main/kotlin/com/vacgom/backend/application/inoculation/dto/response/InoculationSimpleResponse.kt +++ b/src/main/kotlin/com/vacgom/backend/inoculation/application/dto/response/InoculationSimpleResponse.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.application.inoculation.dto.response +package com.vacgom.backend.inoculation.application.dto.response data class InoculationSimpleResponse( val diseaseName: String, diff --git a/src/main/kotlin/com/vacgom/backend/inoculation/application/dto/response/VaccineResponse.kt b/src/main/kotlin/com/vacgom/backend/inoculation/application/dto/response/VaccineResponse.kt new file mode 100644 index 0000000..943fe6f --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/inoculation/application/dto/response/VaccineResponse.kt @@ -0,0 +1,7 @@ +package com.vacgom.backend.inoculation.application.dto.response + +class VaccineResponse( + val id: String?, + val name: String, + val diseases: List, +) diff --git a/src/main/kotlin/com/vacgom/backend/inoculation/domain/Inoculation.kt b/src/main/kotlin/com/vacgom/backend/inoculation/domain/Inoculation.kt new file mode 100644 index 0000000..8e7ed9e --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/inoculation/domain/Inoculation.kt @@ -0,0 +1,36 @@ +package com.vacgom.backend.inoculation.domain + +import com.fasterxml.jackson.annotation.JsonFormat +import com.vacgom.backend.global.auditing.BaseEntity +import com.vacgom.backend.member.domain.Member +import jakarta.persistence.* +import org.hibernate.annotations.GenericGenerator +import java.time.LocalDate +import java.util.* + +@Entity +@Table(name = "t_inoculation") +class Inoculation( + val inoculationOrder: Long, + val inoculationOrderString: String, + @JsonFormat( + shape = JsonFormat.Shape.STRING, + pattern = "yyyy-MM-dd", + ) + val date: LocalDate, + val agency: String, + val vaccineName: String?, + val vaccineBrandName: String?, + val lotNumber: String?, + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "member_id") + val member: Member, + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "vaccination_id") + val vaccination: Vaccination, +) : BaseEntity() { + @Id + @GenericGenerator(name = "uuid2", strategy = "uuid2") + @Column(columnDefinition = "BINARY(16)", name = "vaccine_id") + val id: UUID = UUID.randomUUID() +} diff --git a/src/main/kotlin/com/vacgom/backend/domain/inoculation/Vaccination.kt b/src/main/kotlin/com/vacgom/backend/inoculation/domain/Vaccination.kt similarity index 84% rename from src/main/kotlin/com/vacgom/backend/domain/inoculation/Vaccination.kt rename to src/main/kotlin/com/vacgom/backend/inoculation/domain/Vaccination.kt index 9bedceb..a760dea 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/inoculation/Vaccination.kt +++ b/src/main/kotlin/com/vacgom/backend/inoculation/domain/Vaccination.kt @@ -1,7 +1,7 @@ -package com.vacgom.backend.domain.inoculation +package com.vacgom.backend.inoculation.domain -import com.vacgom.backend.domain.inoculation.constants.VaccinationType import com.vacgom.backend.global.auditing.BaseEntity +import com.vacgom.backend.inoculation.domain.constants.VaccinationType import jakarta.persistence.* import org.hibernate.annotations.GenericGenerator import java.util.* diff --git a/src/main/kotlin/com/vacgom/backend/inoculation/domain/constants/VaccinationType.kt b/src/main/kotlin/com/vacgom/backend/inoculation/domain/constants/VaccinationType.kt new file mode 100644 index 0000000..1a326d7 --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/inoculation/domain/constants/VaccinationType.kt @@ -0,0 +1,6 @@ +package com.vacgom.backend.inoculation.domain.constants + +enum class VaccinationType { + NATION, + EXTRA; +} diff --git a/src/main/kotlin/com/vacgom/backend/exception/inoculation/VaccineError.kt b/src/main/kotlin/com/vacgom/backend/inoculation/exception/VaccineError.kt similarity index 88% rename from src/main/kotlin/com/vacgom/backend/exception/inoculation/VaccineError.kt rename to src/main/kotlin/com/vacgom/backend/inoculation/exception/VaccineError.kt index 0bfaeeb..c7ec400 100644 --- a/src/main/kotlin/com/vacgom/backend/exception/inoculation/VaccineError.kt +++ b/src/main/kotlin/com/vacgom/backend/inoculation/exception/VaccineError.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.exception.inoculation +package com.vacgom.backend.inoculation.exception import com.vacgom.backend.global.exception.error.ErrorCode import org.springframework.http.HttpStatus diff --git a/src/main/kotlin/com/vacgom/backend/infrastructure/inoculation/persistence/InoculationRepository.kt b/src/main/kotlin/com/vacgom/backend/inoculation/infrastructure/persistence/InoculationRepository.kt similarity index 83% rename from src/main/kotlin/com/vacgom/backend/infrastructure/inoculation/persistence/InoculationRepository.kt rename to src/main/kotlin/com/vacgom/backend/inoculation/infrastructure/persistence/InoculationRepository.kt index 2d77d88..51d74fc 100644 --- a/src/main/kotlin/com/vacgom/backend/infrastructure/inoculation/persistence/InoculationRepository.kt +++ b/src/main/kotlin/com/vacgom/backend/inoculation/infrastructure/persistence/InoculationRepository.kt @@ -1,7 +1,7 @@ -package com.vacgom.backend.infrastructure.inoculation.persistence +package com.vacgom.backend.inoculation.infrastructure.persistence -import com.vacgom.backend.domain.inoculation.Inoculation -import com.vacgom.backend.domain.inoculation.constants.VaccinationType +import com.vacgom.backend.inoculation.domain.Inoculation +import com.vacgom.backend.inoculation.domain.constants.VaccinationType import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import java.util.* diff --git a/src/main/kotlin/com/vacgom/backend/infrastructure/inoculation/persistence/VaccinationRepository.kt b/src/main/kotlin/com/vacgom/backend/inoculation/infrastructure/persistence/VaccinationRepository.kt similarity index 62% rename from src/main/kotlin/com/vacgom/backend/infrastructure/inoculation/persistence/VaccinationRepository.kt rename to src/main/kotlin/com/vacgom/backend/inoculation/infrastructure/persistence/VaccinationRepository.kt index 7046a57..9a68269 100644 --- a/src/main/kotlin/com/vacgom/backend/infrastructure/inoculation/persistence/VaccinationRepository.kt +++ b/src/main/kotlin/com/vacgom/backend/inoculation/infrastructure/persistence/VaccinationRepository.kt @@ -1,7 +1,7 @@ -package com.vacgom.backend.infrastructure.inoculation.persistence +package com.vacgom.backend.inoculation.infrastructure.persistence -import com.vacgom.backend.domain.inoculation.Vaccination -import com.vacgom.backend.domain.inoculation.constants.VaccinationType +import com.vacgom.backend.inoculation.domain.Vaccination +import com.vacgom.backend.inoculation.domain.constants.VaccinationType import org.springframework.data.jpa.repository.JpaRepository import java.util.* diff --git a/src/main/kotlin/com/vacgom/backend/member/application/MemberService.kt b/src/main/kotlin/com/vacgom/backend/member/application/MemberService.kt new file mode 100644 index 0000000..9de4597 --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/member/application/MemberService.kt @@ -0,0 +1,43 @@ +package com.vacgom.backend.member.application + +import com.vacgom.backend.disease.domain.constants.HealthCondition +import com.vacgom.backend.global.exception.error.BusinessException +import com.vacgom.backend.member.domain.HealthProfile +import com.vacgom.backend.member.domain.Member +import com.vacgom.backend.member.exception.MemberError +import com.vacgom.backend.member.infrastructure.persistence.MemberRepository +import jakarta.transaction.Transactional +import org.springframework.stereotype.Component +import java.util.* + +@Component +@Transactional +class MemberService( + private val memberRepository: MemberRepository, +) { + fun findMember(id: UUID): Member? { + return memberRepository.findById(id).orElseThrow() + } + + fun updateHealthCondition( + id: UUID, + healthProfiles: List, + ): Member { + val member = + memberRepository.findById(id).orElseThrow { + BusinessException(MemberError.NOT_FOUND) + } + + member.healthProfiles.clear() + member.healthProfiles.addAll(healthProfiles.map { HealthProfile(member, it) }) + return memberRepository.save(member) + } + + fun withdrawMember(id: UUID) { + val member = + memberRepository.findById(id).orElseThrow { + BusinessException(MemberError.NOT_FOUND) + } + memberRepository.delete(member) + } +} diff --git a/src/main/kotlin/com/vacgom/backend/member/application/dto/request/UpdateHealthConditionRequest.kt b/src/main/kotlin/com/vacgom/backend/member/application/dto/request/UpdateHealthConditionRequest.kt new file mode 100644 index 0000000..b4624fb --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/member/application/dto/request/UpdateHealthConditionRequest.kt @@ -0,0 +1,5 @@ +package com.vacgom.backend.member.application.dto.request + +class UpdateHealthConditionRequest( + val healthProfiles: List, +) diff --git a/src/main/kotlin/com/vacgom/backend/domain/member/HealthProfile.kt b/src/main/kotlin/com/vacgom/backend/member/domain/HealthProfile.kt similarity index 54% rename from src/main/kotlin/com/vacgom/backend/domain/member/HealthProfile.kt rename to src/main/kotlin/com/vacgom/backend/member/domain/HealthProfile.kt index 526ed37..4536ebc 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/member/HealthProfile.kt +++ b/src/main/kotlin/com/vacgom/backend/member/domain/HealthProfile.kt @@ -1,6 +1,6 @@ -package com.vacgom.backend.domain.member +package com.vacgom.backend.member.domain -import com.vacgom.backend.domain.disease.HealthCondition +import com.vacgom.backend.disease.domain.constants.HealthCondition import jakarta.persistence.* import org.hibernate.annotations.GenericGenerator import java.util.* @@ -8,11 +8,11 @@ import java.util.* @Entity @Table(name = "t_health_profile") class HealthProfile( - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "member_id") - var member: Member, - @Enumerated(value = EnumType.STRING) - var healthCondition: HealthCondition, + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "member_id") + var member: Member, + @Enumerated(value = EnumType.STRING) + var healthCondition: HealthCondition, ) { @Id @GeneratedValue(generator = "uuid2") diff --git a/src/main/kotlin/com/vacgom/backend/domain/member/Member.kt b/src/main/kotlin/com/vacgom/backend/member/domain/Member.kt similarity index 76% rename from src/main/kotlin/com/vacgom/backend/domain/member/Member.kt rename to src/main/kotlin/com/vacgom/backend/member/domain/Member.kt index 40cd5e0..cae0fea 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/member/Member.kt +++ b/src/main/kotlin/com/vacgom/backend/member/domain/Member.kt @@ -1,9 +1,9 @@ -package com.vacgom.backend.domain.member +package com.vacgom.backend.member.domain -import com.vacgom.backend.domain.auth.constants.Role -import com.vacgom.backend.domain.auth.oauth.constants.ProviderType -import com.vacgom.backend.domain.inoculation.Inoculation +import com.vacgom.backend.auth.domain.constants.ProviderType +import com.vacgom.backend.auth.domain.constants.Role import com.vacgom.backend.global.auditing.BaseEntity +import com.vacgom.backend.inoculation.domain.Inoculation import jakarta.persistence.* import org.hibernate.annotations.GenericGenerator import java.util.* @@ -11,9 +11,9 @@ import java.util.* @Entity @Table(name = "t_member") class Member( - var providerId: Long, - @Enumerated(EnumType.STRING) var providerType: ProviderType, - @Enumerated(EnumType.STRING) var role: Role, + var providerId: Long, + @Enumerated(EnumType.STRING) var providerType: ProviderType, + @Enumerated(EnumType.STRING) var role: Role, ) : BaseEntity() { @Id @GenericGenerator(name = "uuid2", strategy = "uuid2") diff --git a/src/main/kotlin/com/vacgom/backend/domain/member/MemberDetails.kt b/src/main/kotlin/com/vacgom/backend/member/domain/MemberDetails.kt similarity index 87% rename from src/main/kotlin/com/vacgom/backend/domain/member/MemberDetails.kt rename to src/main/kotlin/com/vacgom/backend/member/domain/MemberDetails.kt index 6e814b8..4ed4c73 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/member/MemberDetails.kt +++ b/src/main/kotlin/com/vacgom/backend/member/domain/MemberDetails.kt @@ -1,7 +1,7 @@ -package com.vacgom.backend.domain.member +package com.vacgom.backend.member.domain import com.fasterxml.jackson.annotation.JsonFormat -import com.vacgom.backend.domain.member.constants.Sex +import com.vacgom.backend.member.domain.constants.Sex import jakarta.persistence.Embeddable import jakarta.persistence.EnumType import jakarta.persistence.Enumerated diff --git a/src/main/kotlin/com/vacgom/backend/domain/member/Nickname.kt b/src/main/kotlin/com/vacgom/backend/member/domain/Nickname.kt similarity index 93% rename from src/main/kotlin/com/vacgom/backend/domain/member/Nickname.kt rename to src/main/kotlin/com/vacgom/backend/member/domain/Nickname.kt index 03b0ac3..8ec6c04 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/member/Nickname.kt +++ b/src/main/kotlin/com/vacgom/backend/member/domain/Nickname.kt @@ -1,7 +1,7 @@ -package com.vacgom.backend.domain.member +package com.vacgom.backend.member.domain -import com.vacgom.backend.exception.member.NicknameError import com.vacgom.backend.global.exception.error.BusinessException +import com.vacgom.backend.member.exception.NicknameError import jakarta.persistence.Column import jakarta.persistence.Embeddable diff --git a/src/main/kotlin/com/vacgom/backend/domain/member/constants/Sex.kt b/src/main/kotlin/com/vacgom/backend/member/domain/constants/Sex.kt similarity index 77% rename from src/main/kotlin/com/vacgom/backend/domain/member/constants/Sex.kt rename to src/main/kotlin/com/vacgom/backend/member/domain/constants/Sex.kt index 1813b33..bebec64 100644 --- a/src/main/kotlin/com/vacgom/backend/domain/member/constants/Sex.kt +++ b/src/main/kotlin/com/vacgom/backend/member/domain/constants/Sex.kt @@ -1,7 +1,7 @@ -package com.vacgom.backend.domain.member.constants +package com.vacgom.backend.member.domain.constants -import com.vacgom.backend.exception.member.MemberError import com.vacgom.backend.global.exception.error.BusinessException +import com.vacgom.backend.member.exception.MemberError enum class Sex( val value: String diff --git a/src/main/kotlin/com/vacgom/backend/exception/member/HealthConditionError.kt b/src/main/kotlin/com/vacgom/backend/member/exception/HealthConditionError.kt similarity index 62% rename from src/main/kotlin/com/vacgom/backend/exception/member/HealthConditionError.kt rename to src/main/kotlin/com/vacgom/backend/member/exception/HealthConditionError.kt index 363eb1d..f99dcfa 100644 --- a/src/main/kotlin/com/vacgom/backend/exception/member/HealthConditionError.kt +++ b/src/main/kotlin/com/vacgom/backend/member/exception/HealthConditionError.kt @@ -1,12 +1,12 @@ -package com.vacgom.backend.exception.member +package com.vacgom.backend.member.exception import com.vacgom.backend.global.exception.error.ErrorCode import org.springframework.http.HttpStatus enum class HealthConditionError( - override val message: String, - override val status: HttpStatus, - override val code: String, + override val message: String, + override val status: HttpStatus, + override val code: String, ) : ErrorCode { INVALID_HEALTH_CONDITION("올바르지 않은 Health Condition입니다.", HttpStatus.BAD_REQUEST, "HC_001"), } diff --git a/src/main/kotlin/com/vacgom/backend/exception/member/MemberError.kt b/src/main/kotlin/com/vacgom/backend/member/exception/MemberError.kt similarity index 91% rename from src/main/kotlin/com/vacgom/backend/exception/member/MemberError.kt rename to src/main/kotlin/com/vacgom/backend/member/exception/MemberError.kt index 165ed87..ce2e86f 100644 --- a/src/main/kotlin/com/vacgom/backend/exception/member/MemberError.kt +++ b/src/main/kotlin/com/vacgom/backend/member/exception/MemberError.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.exception.member +package com.vacgom.backend.member.exception import com.vacgom.backend.global.exception.error.ErrorCode import org.springframework.http.HttpStatus diff --git a/src/main/kotlin/com/vacgom/backend/exception/member/NicknameError.kt b/src/main/kotlin/com/vacgom/backend/member/exception/NicknameError.kt similarity index 95% rename from src/main/kotlin/com/vacgom/backend/exception/member/NicknameError.kt rename to src/main/kotlin/com/vacgom/backend/member/exception/NicknameError.kt index 1a18ddc..1c637ae 100644 --- a/src/main/kotlin/com/vacgom/backend/exception/member/NicknameError.kt +++ b/src/main/kotlin/com/vacgom/backend/member/exception/NicknameError.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.exception.member +package com.vacgom.backend.member.exception import com.vacgom.backend.global.exception.error.ErrorCode import org.springframework.http.HttpStatus diff --git a/src/main/kotlin/com/vacgom/backend/infrastructure/member/persistence/HealthProfileRepository.kt b/src/main/kotlin/com/vacgom/backend/member/infrastructure/persistence/HealthProfileRepository.kt similarity index 57% rename from src/main/kotlin/com/vacgom/backend/infrastructure/member/persistence/HealthProfileRepository.kt rename to src/main/kotlin/com/vacgom/backend/member/infrastructure/persistence/HealthProfileRepository.kt index c493f1c..2565ab5 100644 --- a/src/main/kotlin/com/vacgom/backend/infrastructure/member/persistence/HealthProfileRepository.kt +++ b/src/main/kotlin/com/vacgom/backend/member/infrastructure/persistence/HealthProfileRepository.kt @@ -1,6 +1,6 @@ -package com.vacgom.backend.infrastructure.member.persistence +package com.vacgom.backend.member.infrastructure.persistence -import com.vacgom.backend.domain.member.HealthProfile +import com.vacgom.backend.member.domain.HealthProfile import org.springframework.data.jpa.repository.JpaRepository import java.util.* diff --git a/src/main/kotlin/com/vacgom/backend/infrastructure/member/persistence/MemberRepository.kt b/src/main/kotlin/com/vacgom/backend/member/infrastructure/persistence/MemberRepository.kt similarity index 59% rename from src/main/kotlin/com/vacgom/backend/infrastructure/member/persistence/MemberRepository.kt rename to src/main/kotlin/com/vacgom/backend/member/infrastructure/persistence/MemberRepository.kt index 362dfb4..af0f157 100644 --- a/src/main/kotlin/com/vacgom/backend/infrastructure/member/persistence/MemberRepository.kt +++ b/src/main/kotlin/com/vacgom/backend/member/infrastructure/persistence/MemberRepository.kt @@ -1,8 +1,8 @@ -package com.vacgom.backend.infrastructure.member.persistence +package com.vacgom.backend.member.infrastructure.persistence -import com.vacgom.backend.domain.auth.oauth.constants.ProviderType -import com.vacgom.backend.domain.member.Member -import com.vacgom.backend.domain.member.Nickname +import com.vacgom.backend.auth.domain.constants.ProviderType +import com.vacgom.backend.member.domain.Member +import com.vacgom.backend.member.domain.Nickname import org.springframework.data.jpa.repository.JpaRepository import java.util.* diff --git a/src/main/kotlin/com/vacgom/backend/member/presentation/MeController.kt b/src/main/kotlin/com/vacgom/backend/member/presentation/MeController.kt new file mode 100644 index 0000000..b2b6b76 --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/member/presentation/MeController.kt @@ -0,0 +1,61 @@ +package com.vacgom.backend.member.presentation + +import com.vacgom.backend.auth.application.dto.response.MeResponse +import com.vacgom.backend.disease.domain.constants.HealthCondition +import com.vacgom.backend.global.exception.error.BusinessException +import com.vacgom.backend.global.security.annotation.AuthId +import com.vacgom.backend.member.application.MemberService +import com.vacgom.backend.member.application.dto.request.UpdateHealthConditionRequest +import com.vacgom.backend.member.exception.HealthConditionError +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.* +import java.util.* + +@RestController +@RequestMapping("/api/v1/me") +class MeController( + private val memberService: MemberService, +) { + @DeleteMapping + fun withdraw( + @AuthId id: UUID, + ): ResponseEntity { + this.memberService.withdrawMember(id) + + return ResponseEntity.ok(true) + } + + @GetMapping + fun findMe( + @AuthId id: UUID, + ): ResponseEntity { + val member = this.memberService.findMember(id) ?: throw Error() + + return ResponseEntity.ok( + MeResponse.of(member), + ) + } + + @PostMapping("/healthCondition") + fun updateHealthCondition( + @AuthId id: UUID, + @RequestBody request: UpdateHealthConditionRequest, + ): ResponseEntity { + val conditions = + runCatching { + request.healthProfiles.map { HealthCondition.valueOf(it) } + }.getOrElse { + throw BusinessException(HealthConditionError.INVALID_HEALTH_CONDITION) + } + + val member = + this.memberService.updateHealthCondition( + id, + conditions, + ) + + return ResponseEntity.ok( + MeResponse.of(member), + ) + } +} diff --git a/src/main/kotlin/com/vacgom/backend/presentation/disease/dto/FilterRequest.kt b/src/main/kotlin/com/vacgom/backend/presentation/disease/dto/FilterRequest.kt deleted file mode 100644 index 37ab707..0000000 --- a/src/main/kotlin/com/vacgom/backend/presentation/disease/dto/FilterRequest.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.vacgom.backend.presentation.disease.dto - -class FilterRequest( - val age: List, - val condition: List, -) diff --git a/src/main/kotlin/com/vacgom/backend/presentation/inoculation/InoculationController.kt b/src/main/kotlin/com/vacgom/backend/presentation/inoculation/InoculationController.kt index b79d9ec..466b040 100644 --- a/src/main/kotlin/com/vacgom/backend/presentation/inoculation/InoculationController.kt +++ b/src/main/kotlin/com/vacgom/backend/presentation/inoculation/InoculationController.kt @@ -1,10 +1,10 @@ package com.vacgom.backend.presentation.inoculation -import com.vacgom.backend.application.inoculation.dto.InoculationService -import com.vacgom.backend.application.inoculation.dto.request.DiseaseNameRequest -import com.vacgom.backend.application.inoculation.dto.response.InoculationDetailResponse -import com.vacgom.backend.application.inoculation.dto.response.InoculationSimpleResponse 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.InoculationDetailResponse +import com.vacgom.backend.inoculation.application.dto.response.InoculationSimpleResponse import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* import java.util.* diff --git a/src/main/kotlin/com/vacgom/backend/presentation/member/MeController.kt b/src/main/kotlin/com/vacgom/backend/presentation/member/MeController.kt deleted file mode 100644 index 0584530..0000000 --- a/src/main/kotlin/com/vacgom/backend/presentation/member/MeController.kt +++ /dev/null @@ -1,61 +0,0 @@ -package com.vacgom.backend.presentation.member - -import com.vacgom.backend.application.auth.dto.response.MeResponse -import com.vacgom.backend.application.member.MemberService -import com.vacgom.backend.domain.disease.HealthCondition -import com.vacgom.backend.exception.member.HealthConditionError -import com.vacgom.backend.global.exception.error.BusinessException -import com.vacgom.backend.global.security.annotation.AuthId -import com.vacgom.backend.presentation.member.dto.UpdateHealthConditionRequest -import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.* -import java.util.* - -@RestController -@RequestMapping("/api/v1/me") -class MeController( - private val memberService: MemberService, -) { - @DeleteMapping - fun withdraw( - @AuthId id: UUID, - ): ResponseEntity { - this.memberService.withdrawMember(id) - - return ResponseEntity.ok(true) - } - - @GetMapping - fun findMe( - @AuthId id: UUID, - ): ResponseEntity { - val member = this.memberService.findMember(id) ?: throw Error() - - return ResponseEntity.ok( - MeResponse.of(member), - ) - } - - @PostMapping("/healthCondition") - fun updateHealthCondition( - @AuthId id: UUID, - @RequestBody request: UpdateHealthConditionRequest, - ): ResponseEntity { - val conditions = - runCatching { - request.healthProfiles.map { HealthCondition.valueOf(it) } - }.getOrElse { - throw BusinessException(HealthConditionError.INVALID_HEALTH_CONDITION) - } - - val member = - this.memberService.updateHealthCondition( - id, - conditions, - ) - - return ResponseEntity.ok( - MeResponse.of(member), - ) - } -} diff --git a/src/main/kotlin/com/vacgom/backend/presentation/member/dto/UpdateHealthConditionRequest.kt b/src/main/kotlin/com/vacgom/backend/presentation/member/dto/UpdateHealthConditionRequest.kt deleted file mode 100644 index 64b3d3f..0000000 --- a/src/main/kotlin/com/vacgom/backend/presentation/member/dto/UpdateHealthConditionRequest.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.vacgom.backend.presentation.member.dto - -class UpdateHealthConditionRequest( - val healthProfiles: List, -) diff --git a/src/main/kotlin/com/vacgom/backend/presentation/search/SearchController.kt b/src/main/kotlin/com/vacgom/backend/presentation/search/SearchController.kt index 04cb56a..5d75836 100644 --- a/src/main/kotlin/com/vacgom/backend/presentation/search/SearchController.kt +++ b/src/main/kotlin/com/vacgom/backend/presentation/search/SearchController.kt @@ -1,11 +1,11 @@ package com.vacgom.backend.presentation.search -import com.vacgom.backend.application.search.SearchService -import com.vacgom.backend.application.search.dto.DiseaseSearchResponse -import com.vacgom.backend.application.search.dto.VaccinationSearchResponse -import com.vacgom.backend.domain.disease.AgeCondition -import com.vacgom.backend.domain.disease.HealthCondition -import com.vacgom.backend.presentation.disease.dto.FilterRequest +import com.vacgom.backend.disease.application.dto.request.FilterRequest +import com.vacgom.backend.disease.domain.constants.AgeCondition +import com.vacgom.backend.disease.domain.constants.HealthCondition +import com.vacgom.backend.search.application.SearchService +import com.vacgom.backend.search.application.dto.DiseaseSearchResponse +import com.vacgom.backend.search.application.dto.VaccinationSearchResponse import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestBody @@ -15,29 +15,29 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/api/v1/search") class SearchController( - val searchService: SearchService, + val searchService: SearchService, ) { @GetMapping("/disease") fun disease( - @RequestBody body: FilterRequest, + @RequestBody body: FilterRequest, ): ResponseEntity> { 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) }, + ), ) } @GetMapping("/vaccination") fun vaccination( - @RequestBody body: FilterRequest, + @RequestBody body: FilterRequest, ): ResponseEntity> { return ResponseEntity.ok( - searchService.searchVaccination( - body.age.map { AgeCondition.valueOf(it) }, - body.condition.map { HealthCondition.valueOf(it) }, - ), + searchService.searchVaccination( + body.age.map { AgeCondition.valueOf(it) }, + body.condition.map { HealthCondition.valueOf(it) }, + ), ) } } diff --git a/src/main/kotlin/com/vacgom/backend/presentation/vaccine/VaccineController.kt b/src/main/kotlin/com/vacgom/backend/presentation/vaccine/VaccineController.kt index 8fa3359..c60c2c5 100644 --- a/src/main/kotlin/com/vacgom/backend/presentation/vaccine/VaccineController.kt +++ b/src/main/kotlin/com/vacgom/backend/presentation/vaccine/VaccineController.kt @@ -1,7 +1,7 @@ package com.vacgom.backend.presentation.vaccine -import com.vacgom.backend.application.vaccine.dto.VaccineResponse -import com.vacgom.backend.application.vaccine.dto.VaccineService +import com.vacgom.backend.inoculation.application.VaccineService +import com.vacgom.backend.inoculation.application.dto.response.VaccineResponse import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable @@ -11,11 +11,11 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/api/v1/vaccine") class VaccineController( - val vaccineService: VaccineService, + val vaccineService: VaccineService, ) { @GetMapping("/{id}") fun getVaccine( - @PathVariable("id") id: String, + @PathVariable("id") id: String, ): ResponseEntity { return ResponseEntity.ok(vaccineService.getVaccine(id)) } diff --git a/src/main/kotlin/com/vacgom/backend/search/application/SearchService.kt b/src/main/kotlin/com/vacgom/backend/search/application/SearchService.kt new file mode 100644 index 0000000..9c7facb --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/search/application/SearchService.kt @@ -0,0 +1,67 @@ +package com.vacgom.backend.search.application + +import com.vacgom.backend.disease.application.DiseaseService +import com.vacgom.backend.disease.domain.Disease +import com.vacgom.backend.disease.domain.constants.AgeCondition +import com.vacgom.backend.disease.domain.constants.HealthCondition +import com.vacgom.backend.inoculation.domain.Vaccination +import com.vacgom.backend.inoculation.infrastructure.persistence.VaccinationRepository +import com.vacgom.backend.search.application.dto.DiseaseSearchResponse +import com.vacgom.backend.search.application.dto.VaccinationSearchResponse +import org.springframework.stereotype.Service + +@Service +class SearchService( + val vaccinationRepository: VaccinationRepository, + val diseaseService: DiseaseService, +) { + private fun findAllVaccinations(): List { + return vaccinationRepository.findAll() + } + + fun searchDisease( + age: List, + condition: List, + ): List { + val diseases = diseaseService.findAll() + + return diseases.filter { + isMatched(it, age, condition) + }.map { DiseaseSearchResponse.of(it) } + } + + fun searchVaccination( + age: List, + condition: List, + ): List { + val diseases = this.searchDisease(age, condition) + val vaccinations = findAllVaccinations() + + return vaccinations.filter { + diseases.any { disease -> it.diseaseName.contains(disease.name) } + }.map { VaccinationSearchResponse.of(it) } + } + + fun isMatched( + disease: Disease, + age: List, + condition: List, + ): Boolean { + var conditionValue = 0 + condition.forEach { + conditionValue = conditionValue or it.value + } + + var ageValue = 0 + age.forEach { + ageValue = ageValue or it.value + } + + return disease.ageFilter and ageValue == ageValue || + ( + disease.conditionalAgeFilter and ageValue == ageValue && + disease.healthConditionFilter and conditionValue > 0 && + disease.forbiddenHealthConditionFilter and conditionValue == 0 + ) + } +} diff --git a/src/main/kotlin/com/vacgom/backend/search/application/dto/DiseaseSearchResponse.kt b/src/main/kotlin/com/vacgom/backend/search/application/dto/DiseaseSearchResponse.kt new file mode 100644 index 0000000..4eb929f --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/search/application/dto/DiseaseSearchResponse.kt @@ -0,0 +1,21 @@ +package com.vacgom.backend.search.application.dto + +import com.vacgom.backend.disease.domain.Disease + +class DiseaseSearchResponse( + val id: Long?, + val name: String, + val iconImage: String?, + val description: String?, +) { + companion object { + fun of(disease: Disease): DiseaseSearchResponse { + return DiseaseSearchResponse( + id = disease.id, + name = disease.name, + iconImage = disease.iconImage, + description = disease.description, + ) + } + } +} diff --git a/src/main/kotlin/com/vacgom/backend/search/application/dto/VaccinationSearchResponse.kt b/src/main/kotlin/com/vacgom/backend/search/application/dto/VaccinationSearchResponse.kt new file mode 100644 index 0000000..f79b29a --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/search/application/dto/VaccinationSearchResponse.kt @@ -0,0 +1,21 @@ +package com.vacgom.backend.search.application.dto + +import com.vacgom.backend.inoculation.domain.Vaccination + +class VaccinationSearchResponse( + val id: String?, + val vaccineName: String, + val diseaseName: String, + val iconImage: String?, +) { + companion object { + fun of(vaccine: Vaccination): VaccinationSearchResponse { + return VaccinationSearchResponse( + id = vaccine.id?.toString(), + vaccineName = vaccine.vaccineName, + diseaseName = vaccine.diseaseName, + iconImage = "iconImage", + ) + } + } +}