From 78658086e8d41526b6d3a2144c63273aafbd952c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=98=81=EB=A1=9D?= Date: Mon, 5 May 2025 16:14:41 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat=20:=20=EC=BB=A4=ED=94=8C=20=EC=83=9D?= =?UTF-8?q?=EB=85=84=EC=9B=94=EC=9D=BC=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20api=20=EA=B5=AC=ED=98=84=20#85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 ++ .../dto/response/CoupleBirthDayResponse.kt | 19 +++++++++++++++++++ .../backend/couple/facade/CoupleFacade.kt | 6 ++++++ .../backend/couple/presentation/ApiPath.kt | 1 + .../presentation/CoupleInfoController.kt | 10 ++++++++++ 5 files changed, 38 insertions(+) create mode 100644 src/main/kotlin/gomushin/backend/couple/dto/response/CoupleBirthDayResponse.kt diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 60e5b4cd..1711a21b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,6 +3,8 @@ name: Sarang Backend CI/CD on: push: branches: [ main ] + pull_request: + branches: [ main ] jobs: ci: diff --git a/src/main/kotlin/gomushin/backend/couple/dto/response/CoupleBirthDayResponse.kt b/src/main/kotlin/gomushin/backend/couple/dto/response/CoupleBirthDayResponse.kt new file mode 100644 index 00000000..a0a842c3 --- /dev/null +++ b/src/main/kotlin/gomushin/backend/couple/dto/response/CoupleBirthDayResponse.kt @@ -0,0 +1,19 @@ +package gomushin.backend.couple.dto.response + +import gomushin.backend.member.domain.entity.Member +import io.swagger.v3.oas.annotations.media.Schema +import java.time.LocalDate + +data class CoupleBirthDayResponse ( + @Schema(description = "커플 생년월일", example = "2001-04-01") + val coupleBirthDay : LocalDate?, + @Schema(description = "내 생년월일", example = "2001-03-01") + val myBirthDay : LocalDate? +) { + companion object { + fun of(coupleMember : Member, myMember : Member) = CoupleBirthDayResponse( + coupleMember.birthDate, + myMember.birthDate + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/gomushin/backend/couple/facade/CoupleFacade.kt b/src/main/kotlin/gomushin/backend/couple/facade/CoupleFacade.kt index 929d0aea..0f4f819c 100644 --- a/src/main/kotlin/gomushin/backend/couple/facade/CoupleFacade.kt +++ b/src/main/kotlin/gomushin/backend/couple/facade/CoupleFacade.kt @@ -130,4 +130,10 @@ class CoupleFacade( throw BadRequestException("sarangggun.couple.already-init") } } + + fun getCoupleBirthDay(customUserDetails: CustomUserDetails): CoupleBirthDayResponse { + val couple = coupleInfoService.findCoupleMember(customUserDetails.getId()) + val member = memberService.getById(customUserDetails.getId()) + return CoupleBirthDayResponse.of(couple, member) + } } diff --git a/src/main/kotlin/gomushin/backend/couple/presentation/ApiPath.kt b/src/main/kotlin/gomushin/backend/couple/presentation/ApiPath.kt index 5f584856..71854751 100644 --- a/src/main/kotlin/gomushin/backend/couple/presentation/ApiPath.kt +++ b/src/main/kotlin/gomushin/backend/couple/presentation/ApiPath.kt @@ -16,4 +16,5 @@ object ApiPath { const val ANNIVERSARY_GENERATE = "/v1/couple/new-anniversary" const val ANNIVERSARY_MAIN = "/v1/anniversary/main" const val ANNIVERSARIES = "/v1/anniversaries" + const val COUPLE_BIRTHDAY = "/v1/couple/birthday" } diff --git a/src/main/kotlin/gomushin/backend/couple/presentation/CoupleInfoController.kt b/src/main/kotlin/gomushin/backend/couple/presentation/CoupleInfoController.kt index d0acaa44..819227ca 100644 --- a/src/main/kotlin/gomushin/backend/couple/presentation/CoupleInfoController.kt +++ b/src/main/kotlin/gomushin/backend/couple/presentation/CoupleInfoController.kt @@ -71,4 +71,14 @@ class CoupleInfoController ( ):ApiResponse{ return ApiResponse.success(coupleFacade.getCoupleEmotion(customUserDetails)) } + + @ResponseStatus(HttpStatus.OK) + @GetMapping(ApiPath.COUPLE_BIRTHDAY) + @Operation(summary = "커플 생년월일 조회 api", description = "getCoupleBirthDay") + fun getCoupleBirthDay( + @AuthenticationPrincipal customUserDetails: CustomUserDetails + ) :ApiResponse{ + val coupleBirthDay = coupleFacade.getCoupleBirthDay(customUserDetails) + return ApiResponse.success(coupleBirthDay) + } } \ No newline at end of file From 6b060f9bbb65943f58c9bfaa10fae0718e418e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=98=81=EB=A1=9D?= Date: Mon, 5 May 2025 16:15:07 +0900 Subject: [PATCH 2/3] =?UTF-8?q?test=20:=20=EC=BB=A4=ED=94=8C=20=EC=83=9D?= =?UTF-8?q?=EB=85=84=EC=9B=94=EC=9D=BC=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20api=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=9E=91=EC=84=B1=20#85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/couple/facade/CoupleFacadeTest.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/test/kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt b/src/test/kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt index 3f8ef9e4..31dae5a6 100644 --- a/src/test/kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt +++ b/src/test/kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt @@ -62,7 +62,7 @@ class CoupleFacadeTest { name = "곰신", nickname = "곰신닉네임", email = "test1@test.com", - birthDate = null, + birthDate = LocalDate.of(2001, 3, 1), profileImageUrl = null, provider = Provider.KAKAO, role = Role.MEMBER, @@ -73,7 +73,7 @@ class CoupleFacadeTest { name = "꽃신", nickname = "꽃신닉네임", email = "test2@test.com", - birthDate = null, + birthDate = LocalDate.of(2001, 4, 1), profileImageUrl = null, provider = Provider.KAKAO, role = Role.MEMBER, @@ -206,4 +206,18 @@ class CoupleFacadeTest { //then verify(anniversaryService).generateAnniversary(couple, generateAnniversaryRequest) } + + @DisplayName("생년월일 조회 - 정상응답") + @Test + fun getCoupleBirthDay() { + //given + `when`(memberService.getById(customUserDetails.getId())).thenReturn(member1) + `when`(coupleInfoService.findCoupleMember(customUserDetails.getId())).thenReturn(member2) + //when + val result = coupleFacade.getCoupleBirthDay(customUserDetails) + //then + verify(coupleInfoService).findCoupleMember(customUserDetails.getId()) + assertEquals(result.myBirthDay, member1.birthDate) + assertEquals(result.coupleBirthDay, member2.birthDate) + } } From 7023b9378a29996e268dcefbb4cb244e2e685b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=98=81=EB=A1=9D?= Date: Tue, 6 May 2025 00:01:11 +0900 Subject: [PATCH 3/3] =?UTF-8?q?refactor=20:=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=EB=B3=80=EC=88=98=20=EC=88=98=EC=A0=95(coupleBirthday=EB=B3=B4?= =?UTF-8?q?=EB=8B=A4=EB=8A=94=20partnerBirthday=EB=A1=9C=20=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=8C=20=EC=83=81=EB=8C=80=EB=B0=A9(=EC=95=A0?= =?UTF-8?q?=EC=9D=B8)=EC=9D=98=20=EC=83=9D=EC=9D=BC=EC=9E=84=EC=9D=84=20?= =?UTF-8?q?=EB=8D=94=20=EC=9E=98=20=EB=82=98=ED=83=80=EB=82=B4=EC=A3=BC?= =?UTF-8?q?=EB=8A=94=20=EA=B2=83=20=EA=B0=99=EC=95=84=EC=84=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95)=20#85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 -- .../backend/couple/dto/response/CoupleBirthDayResponse.kt | 2 +- .../kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1711a21b..60e5b4cd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,8 +3,6 @@ name: Sarang Backend CI/CD on: push: branches: [ main ] - pull_request: - branches: [ main ] jobs: ci: diff --git a/src/main/kotlin/gomushin/backend/couple/dto/response/CoupleBirthDayResponse.kt b/src/main/kotlin/gomushin/backend/couple/dto/response/CoupleBirthDayResponse.kt index a0a842c3..59a74c5b 100644 --- a/src/main/kotlin/gomushin/backend/couple/dto/response/CoupleBirthDayResponse.kt +++ b/src/main/kotlin/gomushin/backend/couple/dto/response/CoupleBirthDayResponse.kt @@ -6,7 +6,7 @@ import java.time.LocalDate data class CoupleBirthDayResponse ( @Schema(description = "커플 생년월일", example = "2001-04-01") - val coupleBirthDay : LocalDate?, + val partnerBirthday : LocalDate?, @Schema(description = "내 생년월일", example = "2001-03-01") val myBirthDay : LocalDate? ) { diff --git a/src/test/kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt b/src/test/kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt index 31dae5a6..1cc65e2a 100644 --- a/src/test/kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt +++ b/src/test/kotlin/gomushin/backend/couple/facade/CoupleFacadeTest.kt @@ -218,6 +218,6 @@ class CoupleFacadeTest { //then verify(coupleInfoService).findCoupleMember(customUserDetails.getId()) assertEquals(result.myBirthDay, member1.birthDate) - assertEquals(result.coupleBirthDay, member2.birthDate) + assertEquals(result.partnerBirthday, member2.birthDate) } }