Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : 기존 유저정보 조회 API 수정 #554

Merged
merged 5 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -43,7 +45,7 @@ public ResponseEntity<ApiSpec<MemberDetailResponse>> getMemberDetail(
return ResponseEntity.ok(
ApiSpec.success(
SuccessCode.SUCCESS,
MemberDetailResponse.createOf(detailDto)
MemberDetailResponse.createOf(detailDto, aesEncryptionManager::decryptWithPrefixIV)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -15,18 +17,33 @@ public record MemberDetailResponse(
@Schema(description = "검색 태그")
String tag,

@Schema(description = "소셜 타입")
SocialType socialType,

@Schema(description = "이메일")
String email,

@Schema(description = "전화번호")
String phone,

@Schema(description = "친구수")
Long friendCount,

@Schema(description = "그룹수")
Long groupCount
) {

public static MemberDetailResponse createOf(MemberDetailDto detailDto) {
public static MemberDetailResponse createOf(
final MemberDetailDto detailDto,
final Function<byte[], String> phoneDecryption
) {
return new MemberDetailResponse(
detailDto.nickname(),
detailDto.profileUrl(),
detailDto.tag(),
detailDto.socialType(),
detailDto.email(),
phoneDecryption.apply(detailDto.phone().data()),
detailDto.friendCount(),
detailDto.groupCount()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public Optional<MemberDetailDto> 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)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}로 설정된 멤버 엔티티를 생성한다.
Expand Down Expand Up @@ -48,17 +50,16 @@ 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 + "[email protected]")
.authId(dataPrefix + "test")
.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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
Loading