From c64c2268b95521f07f92f8f79af60f552a974c51 Mon Sep 17 00:00:00 2001 From: HyungJu Date: Fri, 22 Mar 2024 23:21:09 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=EC=9C=A0=EC=A0=80=20=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=B9=B4=EC=9A=B4=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/response/MeResponse.kt | 14 +++--- .../member/application/MemberService.kt | 22 +++++---- .../dto/response/JoinCountResponse.kt | 6 +++ .../vacgom/backend/member/domain/Member.kt | 6 +-- .../persistence/MemberRepository.kt | 8 +++- .../member/presentation/MeController.kt | 47 ++++++++++++------- 6 files changed, 65 insertions(+), 38 deletions(-) create mode 100644 src/main/kotlin/com/vacgom/backend/member/application/dto/response/JoinCountResponse.kt 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 index fff4a9a..22c3e35 100644 --- 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 @@ -3,18 +3,16 @@ 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, + val id: String, + val nickname: 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) }, + id = member.id.toString(), + nickname = member.nickname?.nickname, + healthConditions = member.healthProfiles.map { HealthConditionResponse.of(it.healthCondition) }, ) } } diff --git a/src/main/kotlin/com/vacgom/backend/member/application/MemberService.kt b/src/main/kotlin/com/vacgom/backend/member/application/MemberService.kt index 9de4597..17854d9 100644 --- a/src/main/kotlin/com/vacgom/backend/member/application/MemberService.kt +++ b/src/main/kotlin/com/vacgom/backend/member/application/MemberService.kt @@ -13,20 +13,24 @@ import java.util.* @Component @Transactional class MemberService( - private val memberRepository: MemberRepository, + private val memberRepository: MemberRepository, ) { + fun getJoinCount(id: UUID): Number { + return memberRepository.getJoinCount(id) + } + fun findMember(id: UUID): Member? { return memberRepository.findById(id).orElseThrow() } fun updateHealthCondition( - id: UUID, - healthProfiles: List, + id: UUID, + healthProfiles: List, ): Member { val member = - memberRepository.findById(id).orElseThrow { - BusinessException(MemberError.NOT_FOUND) - } + memberRepository.findById(id).orElseThrow { + BusinessException(MemberError.NOT_FOUND) + } member.healthProfiles.clear() member.healthProfiles.addAll(healthProfiles.map { HealthProfile(member, it) }) @@ -35,9 +39,9 @@ class MemberService( fun withdrawMember(id: UUID) { val member = - memberRepository.findById(id).orElseThrow { - BusinessException(MemberError.NOT_FOUND) - } + memberRepository.findById(id).orElseThrow { + BusinessException(MemberError.NOT_FOUND) + } memberRepository.delete(member) } } diff --git a/src/main/kotlin/com/vacgom/backend/member/application/dto/response/JoinCountResponse.kt b/src/main/kotlin/com/vacgom/backend/member/application/dto/response/JoinCountResponse.kt new file mode 100644 index 0000000..56bf3c4 --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/member/application/dto/response/JoinCountResponse.kt @@ -0,0 +1,6 @@ +package com.vacgom.backend.member.application.dto.response + +class JoinCountResponse( + val userId: String, + val joinCount: Number, +) diff --git a/src/main/kotlin/com/vacgom/backend/member/domain/Member.kt b/src/main/kotlin/com/vacgom/backend/member/domain/Member.kt index cae0fea..668418e 100644 --- a/src/main/kotlin/com/vacgom/backend/member/domain/Member.kt +++ b/src/main/kotlin/com/vacgom/backend/member/domain/Member.kt @@ -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/member/infrastructure/persistence/MemberRepository.kt b/src/main/kotlin/com/vacgom/backend/member/infrastructure/persistence/MemberRepository.kt index af0f157..5053a9a 100644 --- a/src/main/kotlin/com/vacgom/backend/member/infrastructure/persistence/MemberRepository.kt +++ b/src/main/kotlin/com/vacgom/backend/member/infrastructure/persistence/MemberRepository.kt @@ -4,13 +4,17 @@ 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 org.springframework.data.jpa.repository.Query import java.util.* interface MemberRepository : JpaRepository { fun findByProviderIdAndProviderType( - providerId: Long, - providerType: ProviderType + providerId: Long, + providerType: ProviderType, ): Member? fun existsMemberByNickname(nickname: Nickname): Boolean + + @Query("SELECT COUNT(m)+1 FROM Member m WHERE m.createdDate <= (SELECT m.createdDate FROM Member m WHERE m.id = :uuid)") + fun getJoinCount(uuid: UUID): Number } diff --git a/src/main/kotlin/com/vacgom/backend/member/presentation/MeController.kt b/src/main/kotlin/com/vacgom/backend/member/presentation/MeController.kt index b2b6b76..7e84f14 100644 --- a/src/main/kotlin/com/vacgom/backend/member/presentation/MeController.kt +++ b/src/main/kotlin/com/vacgom/backend/member/presentation/MeController.kt @@ -6,6 +6,7 @@ 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.application.dto.response.JoinCountResponse import com.vacgom.backend.member.exception.HealthConditionError import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* @@ -14,11 +15,25 @@ import java.util.* @RestController @RequestMapping("/api/v1/me") class MeController( - private val memberService: MemberService, + private val memberService: MemberService, ) { + @GetMapping("/joinCount") + fun getJoinCount( + @AuthId id: UUID, + ): ResponseEntity { + val joinCount = this.memberService.getJoinCount(id) + + return ResponseEntity.ok( + JoinCountResponse( + userId = id.toString(), + joinCount = joinCount, + ), + ) + } + @DeleteMapping fun withdraw( - @AuthId id: UUID, + @AuthId id: UUID, ): ResponseEntity { this.memberService.withdrawMember(id) @@ -27,35 +42,35 @@ class MeController( @GetMapping fun findMe( - @AuthId id: UUID, + @AuthId id: UUID, ): ResponseEntity { val member = this.memberService.findMember(id) ?: throw Error() return ResponseEntity.ok( - MeResponse.of(member), + MeResponse.of(member), ) } @PostMapping("/healthCondition") fun updateHealthCondition( - @AuthId id: UUID, - @RequestBody request: UpdateHealthConditionRequest, + @AuthId id: UUID, + @RequestBody request: UpdateHealthConditionRequest, ): ResponseEntity { val conditions = - runCatching { - request.healthProfiles.map { HealthCondition.valueOf(it) } - }.getOrElse { - throw BusinessException(HealthConditionError.INVALID_HEALTH_CONDITION) - } + runCatching { + request.healthProfiles.map { HealthCondition.valueOf(it) } + }.getOrElse { + throw BusinessException(HealthConditionError.INVALID_HEALTH_CONDITION) + } val member = - this.memberService.updateHealthCondition( - id, - conditions, - ) + this.memberService.updateHealthCondition( + id, + conditions, + ) return ResponseEntity.ok( - MeResponse.of(member), + MeResponse.of(member), ) } } From cff3f420d05773397f5e3beb47e770069c72a6c6 Mon Sep 17 00:00:00 2001 From: HyungJu Date: Sat, 23 Mar 2024 00:07:47 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20search=20disease=20=EA=B0=9C?= =?UTF-8?q?=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/search/SearchController.kt | 59 +++++++++++-------- .../search/application/SearchService.kt | 33 ++++++----- .../dto/VaccinationSearchResponse.kt | 16 ++--- 3 files changed, 62 insertions(+), 46 deletions(-) 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 5d75836..da79fee 100644 --- a/src/main/kotlin/com/vacgom/backend/presentation/search/SearchController.kt +++ b/src/main/kotlin/com/vacgom/backend/presentation/search/SearchController.kt @@ -3,41 +3,54 @@ package com.vacgom.backend.presentation.search 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.inoculation.domain.constants.VaccinationType 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 -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController +import org.springframework.web.bind.annotation.* @RestController @RequestMapping("/api/v1/search") class SearchController( - val searchService: SearchService, + val searchService: SearchService, ) { - @GetMapping("/disease") + @GetMapping() fun disease( - @RequestBody body: FilterRequest, - ): ResponseEntity> { - return ResponseEntity.ok( - searchService.searchDisease( + @RequestBody body: FilterRequest, + @RequestParam type: String, + ): ResponseEntity> { + when (type) { + "essential" -> { + return ResponseEntity.ok( + searchService.searchDisease( body.age.map { AgeCondition.valueOf(it) }, body.condition.map { HealthCondition.valueOf(it) }, - ), - ) - } + ), + ) + } - @GetMapping("/vaccination") - fun vaccination( - @RequestBody body: FilterRequest, - ): ResponseEntity> { - return ResponseEntity.ok( - searchService.searchVaccination( + "nation" -> { + return ResponseEntity.ok( + searchService.searchVaccination( body.age.map { AgeCondition.valueOf(it) }, body.condition.map { HealthCondition.valueOf(it) }, - ), - ) + VaccinationType.NATION, + ), + ) + } + + "extra" -> { + return ResponseEntity.ok( + searchService.searchVaccination( + body.age.map { AgeCondition.valueOf(it) }, + body.condition.map { HealthCondition.valueOf(it) }, + VaccinationType.EXTRA, + ), + ) + } + + else -> { + throw IllegalArgumentException("Invalid type") + } + } } } diff --git a/src/main/kotlin/com/vacgom/backend/search/application/SearchService.kt b/src/main/kotlin/com/vacgom/backend/search/application/SearchService.kt index 9c7facb..4a3eec4 100644 --- a/src/main/kotlin/com/vacgom/backend/search/application/SearchService.kt +++ b/src/main/kotlin/com/vacgom/backend/search/application/SearchService.kt @@ -5,6 +5,7 @@ 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.domain.constants.VaccinationType import com.vacgom.backend.inoculation.infrastructure.persistence.VaccinationRepository import com.vacgom.backend.search.application.dto.DiseaseSearchResponse import com.vacgom.backend.search.application.dto.VaccinationSearchResponse @@ -12,16 +13,16 @@ import org.springframework.stereotype.Service @Service class SearchService( - val vaccinationRepository: VaccinationRepository, - val diseaseService: DiseaseService, + val vaccinationRepository: VaccinationRepository, + val diseaseService: DiseaseService, ) { private fun findAllVaccinations(): List { return vaccinationRepository.findAll() } fun searchDisease( - age: List, - condition: List, + age: List, + condition: List, ): List { val diseases = diseaseService.findAll() @@ -31,21 +32,23 @@ class SearchService( } fun searchVaccination( - age: List, - condition: List, + age: List, + condition: List, + type: VaccinationType, ): List { val diseases = this.searchDisease(age, condition) val vaccinations = findAllVaccinations() return vaccinations.filter { - diseases.any { disease -> it.diseaseName.contains(disease.name) } + diseases.any { disease -> it.diseaseName.contains(disease.name) } && + it.vaccinationType == type }.map { VaccinationSearchResponse.of(it) } } fun isMatched( - disease: Disease, - age: List, - condition: List, + disease: Disease, + age: List, + condition: List, ): Boolean { var conditionValue = 0 condition.forEach { @@ -58,10 +61,10 @@ class SearchService( } return disease.ageFilter and ageValue == ageValue || - ( - disease.conditionalAgeFilter and ageValue == ageValue && - disease.healthConditionFilter and conditionValue > 0 && - disease.forbiddenHealthConditionFilter and conditionValue == 0 - ) + ( + 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/VaccinationSearchResponse.kt b/src/main/kotlin/com/vacgom/backend/search/application/dto/VaccinationSearchResponse.kt index f79b29a..e15a0ed 100644 --- a/src/main/kotlin/com/vacgom/backend/search/application/dto/VaccinationSearchResponse.kt +++ b/src/main/kotlin/com/vacgom/backend/search/application/dto/VaccinationSearchResponse.kt @@ -3,18 +3,18 @@ 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?, + 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", + id = vaccine.id?.toString(), + vaccineName = vaccine.vaccineName, + diseaseName = vaccine.diseaseName, + iconImage = vaccine.icon, ) } } From 093a84d7c9d8a705a92e06c8ac3cf94cbfab1009 Mon Sep 17 00:00:00 2001 From: HyungJu Date: Sat, 23 Mar 2024 00:47:35 +0900 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=EC=A7=88=EB=B3=91=EC=97=90=20qna?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vacgom/backend/disease/domain/Disease.kt | 25 +++++++++++-------- .../com/vacgom/backend/disease/domain/Qna.kt | 17 +++++++++++++ .../application/dto/DiseaseSearchResponse.kt | 20 +++++++++------ .../search/application/dto/QnaResponse.kt | 18 +++++++++++++ 4 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 src/main/kotlin/com/vacgom/backend/disease/domain/Qna.kt create mode 100644 src/main/kotlin/com/vacgom/backend/search/application/dto/QnaResponse.kt diff --git a/src/main/kotlin/com/vacgom/backend/disease/domain/Disease.kt b/src/main/kotlin/com/vacgom/backend/disease/domain/Disease.kt index 7cb55ea..6aa85cc 100644 --- a/src/main/kotlin/com/vacgom/backend/disease/domain/Disease.kt +++ b/src/main/kotlin/com/vacgom/backend/disease/domain/Disease.kt @@ -6,15 +6,18 @@ 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, + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "disease_id") + val id: Long? = null, + val name: String, + val iconImage: String?, + val mainImage: String?, + val description: String?, + val ageFilter: Int, + val conditionalAgeFilter: Int, + val healthConditionFilter: Int, + val forbiddenHealthConditionFilter: Int, + @OneToMany(mappedBy = "disease", fetch = FetchType.EAGER, cascade = [CascadeType.ALL]) + val qnaList: List, ) : BaseEntity() diff --git a/src/main/kotlin/com/vacgom/backend/disease/domain/Qna.kt b/src/main/kotlin/com/vacgom/backend/disease/domain/Qna.kt new file mode 100644 index 0000000..79a1bc7 --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/disease/domain/Qna.kt @@ -0,0 +1,17 @@ +package com.vacgom.backend.disease.domain + +import jakarta.persistence.* + +@Entity() +@Table(name = "t_qna") +class Qna( + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "qna_id") + val id: Long? = null, + val question: String, + val answer: String, + @ManyToOne(fetch = FetchType.EAGER) + @JoinColumn(name = "disease_id") + val disease: Disease, +) 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 index 4eb929f..df27b3c 100644 --- a/src/main/kotlin/com/vacgom/backend/search/application/dto/DiseaseSearchResponse.kt +++ b/src/main/kotlin/com/vacgom/backend/search/application/dto/DiseaseSearchResponse.kt @@ -3,18 +3,22 @@ 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?, + val id: Long?, + val name: String, + val mainImage: String?, + val iconImage: String?, + val description: String?, + val qnaList: List = listOf(), ) { companion object { fun of(disease: Disease): DiseaseSearchResponse { return DiseaseSearchResponse( - id = disease.id, - name = disease.name, - iconImage = disease.iconImage, - description = disease.description, + id = disease.id, + name = disease.name, + mainImage = disease.mainImage, + iconImage = disease.iconImage, + description = disease.description, + qnaList = disease.qnaList.map { QnaResponse.of(it.question, it.answer) }, ) } } diff --git a/src/main/kotlin/com/vacgom/backend/search/application/dto/QnaResponse.kt b/src/main/kotlin/com/vacgom/backend/search/application/dto/QnaResponse.kt new file mode 100644 index 0000000..45e579f --- /dev/null +++ b/src/main/kotlin/com/vacgom/backend/search/application/dto/QnaResponse.kt @@ -0,0 +1,18 @@ +package com.vacgom.backend.search.application.dto + +class QnaResponse( + val question: String, + val answer: String, +) { + companion object { + fun of( + question: String, + answer: String, + ): QnaResponse { + return QnaResponse( + question = question, + answer = answer, + ) + } + } +} From f39232f5c5cc6085f30de226f3f74edf39466c49 Mon Sep 17 00:00:00 2001 From: HyungJu Date: Sat, 23 Mar 2024 00:50:57 +0900 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20disease=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../disease/application/DiseaseService.kt | 6 +++++- .../dto/response/DiseaseResponse.kt | 21 ++++++++++++------- .../disease/presentation/DiseaseController.kt | 13 +++++++++++- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/com/vacgom/backend/disease/application/DiseaseService.kt b/src/main/kotlin/com/vacgom/backend/disease/application/DiseaseService.kt index d60e2e8..90ce304 100644 --- a/src/main/kotlin/com/vacgom/backend/disease/application/DiseaseService.kt +++ b/src/main/kotlin/com/vacgom/backend/disease/application/DiseaseService.kt @@ -6,8 +6,12 @@ import org.springframework.stereotype.Service @Service class DiseaseService( - private val diseaseRepository: DiseaseRepository, + private val diseaseRepository: DiseaseRepository, ) { + fun findById(id: Long): Disease { + return diseaseRepository.findById(id).orElseThrow { IllegalArgumentException("Disease not found") } + } + fun findAll(): List { return diseaseRepository.findAll() } 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 index 02309ca..9271b85 100644 --- 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 @@ -1,20 +1,25 @@ package com.vacgom.backend.disease.application.dto.response import com.vacgom.backend.disease.domain.Disease +import com.vacgom.backend.search.application.dto.QnaResponse class DiseaseResponse( - val id: Long?, - val name: String, - val iconImage: String?, - val description: String?, + val id: Long?, + val name: String, + val mainImage: String?, + val iconImage: String?, + val description: String?, + val qnaList: List = listOf(), ) { companion object { fun of(disease: Disease): DiseaseResponse { return DiseaseResponse( - id = disease.id, - name = disease.name, - iconImage = disease.iconImage, - description = disease.description, + id = disease.id, + name = disease.name, + mainImage = disease.mainImage, + iconImage = disease.iconImage, + description = disease.description, + qnaList = disease.qnaList.map { QnaResponse.of(it.question, it.answer) }, ) } } diff --git a/src/main/kotlin/com/vacgom/backend/disease/presentation/DiseaseController.kt b/src/main/kotlin/com/vacgom/backend/disease/presentation/DiseaseController.kt index ed48af8..eb53906 100644 --- a/src/main/kotlin/com/vacgom/backend/disease/presentation/DiseaseController.kt +++ b/src/main/kotlin/com/vacgom/backend/disease/presentation/DiseaseController.kt @@ -1,19 +1,30 @@ package com.vacgom.backend.disease.presentation import com.vacgom.backend.disease.application.DiseaseService +import com.vacgom.backend.disease.application.dto.response.DiseaseResponse 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.PathVariable import org.springframework.web.bind.annotation.RequestMapping 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>> { return ResponseEntity.ok(HealthCondition.entries.map { Pair(it.name, it.description) }) } + + @GetMapping("/{id}") + fun getDisease( + @PathVariable id: Long, + ): ResponseEntity { + val disease = diseaseService.findById(id) + + return ResponseEntity.ok(DiseaseResponse.of(disease)) + } } From 4f0826eae89099911cbbca4f1a020c8e097599cf Mon Sep 17 00:00:00 2001 From: HyungJu Date: Sat, 23 Mar 2024 00:52:41 +0900 Subject: [PATCH 5/5] =?UTF-8?q?chore:=20presentation=20=EB=AF=B8=EC=95=84?= =?UTF-8?q?=20=ED=8C=A8=ED=82=A4=EC=A7=80=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation}/InoculationController.kt | 14 +++++++------- .../presentation}/SearchController.kt | 2 +- .../presentation}/VaccineController.kt | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) rename src/main/kotlin/com/vacgom/backend/{presentation/inoculation => inoculation/presentation}/InoculationController.kt (78%) rename src/main/kotlin/com/vacgom/backend/{presentation/search => search/presentation}/SearchController.kt (97%) rename src/main/kotlin/com/vacgom/backend/{presentation/vaccine => vaccine/presentation}/VaccineController.kt (83%) diff --git a/src/main/kotlin/com/vacgom/backend/presentation/inoculation/InoculationController.kt b/src/main/kotlin/com/vacgom/backend/inoculation/presentation/InoculationController.kt similarity index 78% rename from src/main/kotlin/com/vacgom/backend/presentation/inoculation/InoculationController.kt rename to src/main/kotlin/com/vacgom/backend/inoculation/presentation/InoculationController.kt index 466b040..1508eea 100644 --- a/src/main/kotlin/com/vacgom/backend/presentation/inoculation/InoculationController.kt +++ b/src/main/kotlin/com/vacgom/backend/inoculation/presentation/InoculationController.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.presentation.inoculation +package com.vacgom.backend.inoculation.presentation import com.vacgom.backend.global.security.annotation.AuthId import com.vacgom.backend.inoculation.application.InoculationService @@ -12,12 +12,12 @@ import java.util.* @RestController @RequestMapping("/api/v1/inoculation") class InoculationController( - private val inoculationService: InoculationService + private val inoculationService: InoculationService, ) { @GetMapping("/simple") fun getInoculationSimpleResponse( - @AuthId id: UUID, - @RequestParam type: String + @AuthId id: UUID, + @RequestParam type: String, ): ResponseEntity> { val responses = inoculationService.getInoculationSimpleResponse(id, type) return ResponseEntity.ok(responses) @@ -25,9 +25,9 @@ class InoculationController( @GetMapping("/detail") fun getInoculationDetailResponse( - @AuthId id: UUID, - @RequestBody request: DiseaseNameRequest, - @RequestParam type: String + @AuthId id: UUID, + @RequestBody request: DiseaseNameRequest, + @RequestParam type: String, ): ResponseEntity> { val responses = inoculationService.getInoculationDetailResponse(id, request, type) return ResponseEntity.ok(responses) diff --git a/src/main/kotlin/com/vacgom/backend/presentation/search/SearchController.kt b/src/main/kotlin/com/vacgom/backend/search/presentation/SearchController.kt similarity index 97% rename from src/main/kotlin/com/vacgom/backend/presentation/search/SearchController.kt rename to src/main/kotlin/com/vacgom/backend/search/presentation/SearchController.kt index da79fee..7d24342 100644 --- a/src/main/kotlin/com/vacgom/backend/presentation/search/SearchController.kt +++ b/src/main/kotlin/com/vacgom/backend/search/presentation/SearchController.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.presentation.search +package com.vacgom.backend.search.presentation import com.vacgom.backend.disease.application.dto.request.FilterRequest import com.vacgom.backend.disease.domain.constants.AgeCondition diff --git a/src/main/kotlin/com/vacgom/backend/presentation/vaccine/VaccineController.kt b/src/main/kotlin/com/vacgom/backend/vaccine/presentation/VaccineController.kt similarity index 83% rename from src/main/kotlin/com/vacgom/backend/presentation/vaccine/VaccineController.kt rename to src/main/kotlin/com/vacgom/backend/vaccine/presentation/VaccineController.kt index c60c2c5..20f2511 100644 --- a/src/main/kotlin/com/vacgom/backend/presentation/vaccine/VaccineController.kt +++ b/src/main/kotlin/com/vacgom/backend/vaccine/presentation/VaccineController.kt @@ -1,4 +1,4 @@ -package com.vacgom.backend.presentation.vaccine +package com.vacgom.backend.vaccine.presentation import com.vacgom.backend.inoculation.application.VaccineService import com.vacgom.backend.inoculation.application.dto.response.VaccineResponse @@ -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)) }