From 11db59e06beb69ef58b3a361a35aca875b7c8160 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 5 Jul 2024 19:42:20 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat=20:=20=EB=A9=A4=EB=B2=84=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=9D=91=EB=8B=B5=20=ED=83=80=EC=9E=85=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/api/MemberApiController.java | 4 +++- .../member/data/dto/MemberDetailDto.java | 5 +++++ .../data/response/MemberDetailResponse.java | 19 ++++++++++++++++++- .../repository/MemberQueryRepositoryImpl.java | 6 ++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/api/MemberApiController.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/api/MemberApiController.java index cda22a6f4..12683e871 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/api/MemberApiController.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/api/MemberApiController.java @@ -24,6 +24,7 @@ import site.timecapsulearchive.core.global.common.argument.AccessToken; import site.timecapsulearchive.core.global.common.response.ApiSpec; import site.timecapsulearchive.core.global.common.response.SuccessCode; +import site.timecapsulearchive.core.global.security.encryption.AESEncryptionManager; @RestController @RequiredArgsConstructor @@ -32,6 +33,7 @@ public class MemberApiController implements MemberApi { private final MemberFacade memberFacade; private final MemberService memberService; + private final AESEncryptionManager aesEncryptionManager; @GetMapping(produces = {"application/json"}) @Override @@ -43,7 +45,7 @@ public ResponseEntity> getMemberDetail( return ResponseEntity.ok( ApiSpec.success( SuccessCode.SUCCESS, - MemberDetailResponse.createOf(detailDto) + MemberDetailResponse.createOf(detailDto, aesEncryptionManager::decryptWithPrefixIV) ) ); } diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/data/dto/MemberDetailDto.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/data/dto/MemberDetailDto.java index 36b1133ca..1a1a464dc 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/data/dto/MemberDetailDto.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/data/dto/MemberDetailDto.java @@ -1,12 +1,17 @@ package site.timecapsulearchive.core.domain.member.data.dto; import lombok.Builder; +import site.timecapsulearchive.core.domain.member.entity.SocialType; +import site.timecapsulearchive.core.global.common.wrapper.ByteArrayWrapper; @Builder public record MemberDetailDto( String nickname, String profileUrl, String tag, + SocialType socialType, + String email, + ByteArrayWrapper phone, Long friendCount, Long groupCount ) { diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/data/response/MemberDetailResponse.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/data/response/MemberDetailResponse.java index 4e01fed7e..466cbc180 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/data/response/MemberDetailResponse.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/data/response/MemberDetailResponse.java @@ -1,7 +1,9 @@ package site.timecapsulearchive.core.domain.member.data.response; import io.swagger.v3.oas.annotations.media.Schema; +import java.util.function.Function; import site.timecapsulearchive.core.domain.member.data.dto.MemberDetailDto; +import site.timecapsulearchive.core.domain.member.entity.SocialType; @Schema(description = "회원 상세 정보") public record MemberDetailResponse( @@ -15,6 +17,15 @@ public record MemberDetailResponse( @Schema(description = "검색 태그") String tag, + @Schema(description = "소셜 타입") + SocialType socialType, + + @Schema(description = "이메일") + String email, + + @Schema(description = "전화번호") + String phone, + @Schema(description = "친구수") Long friendCount, @@ -22,11 +33,17 @@ public record MemberDetailResponse( Long groupCount ) { - public static MemberDetailResponse createOf(MemberDetailDto detailDto) { + public static MemberDetailResponse createOf( + final MemberDetailDto detailDto, + final Function phoneDecryption + ) { return new MemberDetailResponse( detailDto.nickname(), detailDto.profileUrl(), detailDto.tag(), + detailDto.socialType(), + detailDto.email(), + phoneDecryption.apply(detailDto.phone().data()), detailDto.friendCount(), detailDto.groupCount() ); diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/repository/MemberQueryRepositoryImpl.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/repository/MemberQueryRepositoryImpl.java index d7db6d538..a3395dfa2 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/repository/MemberQueryRepositoryImpl.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/member/repository/MemberQueryRepositoryImpl.java @@ -64,6 +64,12 @@ public Optional findMemberDetailResponseDtoById(final Long memb member.nickname, member.profileUrl, member.tag, + member.socialType, + member.email, + Projections.constructor( + ByteArrayWrapper.class, + member.phone + ), countDistinct(memberFriend.id), countDistinct(memberGroup.id) ) From 575db15eec04624e0346c6c71914f0d93d270411 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 5 Jul 2024 19:53:47 +0900 Subject: [PATCH 2/2] =?UTF-8?q?test=20:=20=EB=A9=A4=EB=B2=84=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=BF=BC=EB=A6=AC=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/common/fixture/domain/MemberFixture.java | 7 ++++--- .../member/repository/MemberQueryRepositoryTest.java | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/domain/MemberFixture.java b/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/domain/MemberFixture.java index c9a347d04..925009fee 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/domain/MemberFixture.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/domain/MemberFixture.java @@ -9,11 +9,13 @@ import site.timecapsulearchive.core.domain.member.entity.Member; import site.timecapsulearchive.core.domain.member.entity.SocialType; import site.timecapsulearchive.core.global.common.wrapper.ByteArrayWrapper; +import site.timecapsulearchive.core.global.security.encryption.AESEncryptionManager; import site.timecapsulearchive.core.global.security.encryption.HashEncryptionManager; public class MemberFixture { private static final HashEncryptionManager hashEncryptionManager = UnitTestDependency.hashEncryptionManager(); + private static final AESEncryptionManager aesEncryptionManager = UnitTestDependency.aesEncryptionManager(); /** * 테스트 픽스처 - {@code Member}의 {@code id}가 주어진 {@code memberId}로 설정된 멤버 엔티티를 생성한다. @@ -48,7 +50,7 @@ private static void setFieldValue(Object instance, String fieldName, Object valu public static Member member(int dataPrefix) { byte[] number = getPhoneBytes(dataPrefix); - Member member = Member.builder() + return Member.builder() .socialType(SocialType.GOOGLE) .nickname(dataPrefix + "testNickname") .email(dataPrefix + "test@google.com") @@ -56,9 +58,8 @@ public static Member member(int dataPrefix) { .profileUrl(dataPrefix + "test.com") .tag(dataPrefix + "testTag") .phone_hash(hashEncryptionManager.encrypt(number)) + .phone(aesEncryptionManager.encryptWithPrefixIV(number)) .build(); - - return member; } public static ByteArrayWrapper getPhoneByteWrapper(int dataPrefix) { diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/domain/member/repository/MemberQueryRepositoryTest.java b/backend/core/src/test/java/site/timecapsulearchive/core/domain/member/repository/MemberQueryRepositoryTest.java index 0b9a7115c..64a7e5cd0 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/domain/member/repository/MemberQueryRepositoryTest.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/domain/member/repository/MemberQueryRepositoryTest.java @@ -69,6 +69,9 @@ void setup(@Autowired EntityManager entityManager) { softly.assertThat(detailDto.tag()).isNotBlank(); softly.assertThat(detailDto.nickname()).isNotBlank(); softly.assertThat(detailDto.profileUrl()).isNotBlank(); + softly.assertThat(detailDto.socialType()).isNotNull(); + softly.assertThat(detailDto.email()).isNotBlank(); + softly.assertThat(detailDto.phone()).isNotNull(); softly.assertThat(detailDto.friendCount()).isNotNull(); softly.assertThat(detailDto.groupCount()).isNotNull(); });