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

로그인 시 회원 프로필 이미지 사진 추가 #235

Merged
merged 16 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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 @@ -28,6 +28,7 @@ public Member toEntity() {
.gender(Gender.from(getGender()))
.phoneNumber(getPhoneNumber())
.providerId(getProviderId())
.profileImageUrl(getProfileImageUrl())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class Member extends BaseTimeEntity {
@Column(nullable = false)
private String providerId;

@Column(nullable = false)
private String profileImageUrl;

@Builder.Default
@Column(nullable = false, columnDefinition = "varchar(255)")
@Enumerated(EnumType.STRING)
Expand All @@ -60,12 +63,13 @@ protected Member() {
}

@Builder
public Member(final Long memberId, final Gender gender, final String name, final String phoneNumber, final String providerId) {
public Member(final Long memberId, final Gender gender, final String name, final String phoneNumber, final String providerId, final String profileImageUrl) {
this.memberId = memberId;
this.gender = gender;
this.name = name;
this.phoneNumber = phoneNumber;
this.providerId = providerId;
this.profileImageUrl = profileImageUrl;
}

@Override
Expand All @@ -76,6 +80,7 @@ public String toString() {
", username='" + name + '\'' +
", phoneNumber='" + phoneNumber + '\'' +
", providerId='" + providerId + '\'' +
", profileImageUrl='" + profileImageUrl + '\'' +
", role=" + role +
'}';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.kakaoshare.backend.domain.member.dto.oauth.logout.OAuthLogoutRequest;
import org.kakaoshare.backend.domain.member.dto.oauth.profile.OAuthProfile;
import org.kakaoshare.backend.domain.member.dto.oauth.profile.OAuthProfileFactory;
import org.kakaoshare.backend.domain.member.entity.Member;
import org.kakaoshare.backend.domain.member.entity.MemberDetails;
import org.kakaoshare.backend.domain.member.entity.token.RefreshToken;
import org.kakaoshare.backend.domain.member.exception.MemberErrorCode;
Expand Down Expand Up @@ -76,8 +77,8 @@ private OAuthProfile getProfile(final OAuthLoginRequest request, final ClientReg
}

private UserDetails addOrFindByProfile(final OAuthProfile oAuthProfile) {
return memberRepository.findDetailsByProviderId(oAuthProfile.getProviderId())
.orElseGet(() -> MemberDetails.from(memberRepository.save(oAuthProfile.toEntity())));
final Member member = memberRepository.save(oAuthProfile.toEntity()); // TODO: 5/27/24 dirty checking 을 통해 DB내 Member 테이블 프로필 사진 수정
return MemberDetails.from(member);
}

private UserDetails findUserDetailsByProviderId(final String providerId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

import org.kakaoshare.backend.domain.product.dto.ProductSummaryResponse;

public record PaymentFundingSuccessResponse(Receiver receiver, ProductSummaryResponse product, Long attributeAmount) {
public record PaymentFundingSuccessResponse(PaymentSuccessReceiver receiver, ProductSummaryResponse product, Long attributeAmount) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

import java.util.List;

public record PaymentGiftSuccessResponse(Receiver receiver, List<OrderSummaryResponse> orders) {
public record PaymentGiftSuccessResponse(PaymentSuccessReceiver receiver, List<OrderSummaryResponse> orders) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.kakaoshare.backend.domain.payment.dto.success.response;

import org.kakaoshare.backend.domain.member.entity.Member;

public record PaymentSuccessReceiver(String name, String photoUrl) {
public static PaymentSuccessReceiver from(final Member member) {
return new PaymentSuccessReceiver(member.getName(), member.getProfileImageUrl());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.kakaoshare.backend.domain.payment.dto.success.request.PaymentSuccessRequest;
import org.kakaoshare.backend.domain.payment.dto.success.response.PaymentFundingSuccessResponse;
import org.kakaoshare.backend.domain.payment.dto.success.response.PaymentGiftSuccessResponse;
import org.kakaoshare.backend.domain.payment.dto.success.response.Receiver;
import org.kakaoshare.backend.domain.payment.dto.success.response.PaymentSuccessReceiver;
import org.kakaoshare.backend.domain.payment.entity.Payment;
import org.kakaoshare.backend.domain.payment.entity.PaymentMethod;
import org.kakaoshare.backend.domain.payment.exception.PaymentErrorCode;
Expand Down Expand Up @@ -152,7 +152,7 @@ public PaymentGiftSuccessResponse approve(final String providerId,
saveOrders(payment, receipts);

final List<OrderSummaryResponse> orderSummaries = getOrderSummaries(orderDetails);
return new PaymentGiftSuccessResponse(Receiver.from(receiver), orderSummaries);
return new PaymentGiftSuccessResponse(PaymentSuccessReceiver.from(receiver), orderSummaries);
}

@Transactional
Expand All @@ -178,8 +178,8 @@ public PaymentFundingSuccessResponse approveFunding(final String providerId,

final Product product = funding.getProduct();
final ProductSummaryResponse productSummaryResponse = ProductSummaryResponse.from(product);
final Receiver receiver = Receiver.from(funding.getMember());
return new PaymentFundingSuccessResponse(receiver, productSummaryResponse, amount);
final PaymentSuccessReceiver paymentSuccessReceiver = PaymentSuccessReceiver.from(funding.getMember());
return new PaymentFundingSuccessResponse(paymentSuccessReceiver, productSummaryResponse, amount);
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE member
ADD COLUMN `profile_image_url` VARCHAR(255) NOT NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public void authenticateWhenNewMember() throws Exception {

doReturn(registration).when(clientRegistrationRepository).findByRegistrationId(registrationId);
doReturn(attributes).when(webClientService).getSocialProfile(registration, socialAccessToken);
doReturn(Optional.empty()).when(memberRepository).findDetailsByProviderId(providerId);
doReturn(member).when(memberRepository).save(any());
doReturn(accessToken).when(jwtProvider).createAccessToken(userDetails);
doReturn(refreshToken).when(refreshTokenProvider).createToken(userDetails.getUsername());
Expand All @@ -110,7 +109,7 @@ public void authenticateWhenExistingMember() throws Exception {

doReturn(registration).when(clientRegistrationRepository).findByRegistrationId(registrationId);
doReturn(attributes).when(webClientService).getSocialProfile(registration, socialAccessToken);
doReturn(Optional.of(userDetails)).when(memberRepository).findDetailsByProviderId(providerId);
doReturn(member).when(memberRepository).save(any());
doReturn(accessToken).when(jwtProvider).createAccessToken(userDetails);
doReturn(refreshToken).when(refreshTokenProvider).createToken(userDetails.getUsername());
doReturn(refreshToken).when(refreshTokenRepository).save(any());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.kakaoshare.backend.domain.payment.dto.success.request.PaymentSuccessRequest;
import org.kakaoshare.backend.domain.payment.dto.success.response.PaymentFundingSuccessResponse;
import org.kakaoshare.backend.domain.payment.dto.success.response.PaymentGiftSuccessResponse;
import org.kakaoshare.backend.domain.payment.dto.success.response.Receiver;
import org.kakaoshare.backend.domain.payment.dto.success.response.PaymentSuccessReceiver;
import org.kakaoshare.backend.domain.payment.entity.Payment;
import org.kakaoshare.backend.domain.payment.entity.PaymentMethod;
import org.kakaoshare.backend.domain.payment.repository.PaymentRepository;
Expand Down Expand Up @@ -217,8 +217,8 @@ public void approveToMe() throws Exception {
new OrderSummaryResponse(cakeSummaryResponse, cakeStockQuantity, Collections.emptyList()),
new OrderSummaryResponse(coffeeSummaryResponse, coffeeStockQuantity, Collections.emptyList())
);
final Receiver receiver = Receiver.from(member);
final PaymentGiftSuccessResponse expect = new PaymentGiftSuccessResponse(receiver, orderSummaries);
final PaymentSuccessReceiver paymentSuccessReceiver = PaymentSuccessReceiver.from(member);
final PaymentGiftSuccessResponse expect = new PaymentGiftSuccessResponse(paymentSuccessReceiver, orderSummaries);
final PaymentGiftSuccessResponse actual = paymentService.approve(providerId, paymentSuccessRequest);
assertThat(actual).isEqualTo(expect); // TODO: 3/16/24 equals() 및 hashCode()가 재정의되있으므로 isEqualTo() 사용
}
Expand Down Expand Up @@ -279,8 +279,8 @@ public void approveToOther() throws Exception {
new OrderSummaryResponse(cakeSummaryResponse, cakeStockQuantity, Collections.emptyList()),
new OrderSummaryResponse(coffeeSummaryResponse, coffeeStockQuantity, Collections.emptyList())
);
final Receiver receiver = Receiver.from(receiverMember);
final PaymentGiftSuccessResponse expect = new PaymentGiftSuccessResponse(receiver, orderSummaries);
final PaymentSuccessReceiver paymentSuccessReceiver = PaymentSuccessReceiver.from(receiverMember);
final PaymentGiftSuccessResponse expect = new PaymentGiftSuccessResponse(paymentSuccessReceiver, orderSummaries);
final PaymentGiftSuccessResponse actual = paymentService.approve(providerId, paymentSuccessRequest);
assertThat(actual).isEqualTo(expect); // TODO: 3/16/24 equals() 및 hashCode()가 재정의되있으므로 isEqualTo() 사용
}
Expand Down Expand Up @@ -365,7 +365,7 @@ public void approveFunding() throws Exception {
doReturn(Optional.of(contributor)).when(memberRepository).findMemberByProviderId(providerId);

final ProductSummaryResponse productSummaryResponse = ProductSummaryResponse.from(cake);
final PaymentFundingSuccessResponse expect = new PaymentFundingSuccessResponse(Receiver.from(creator), productSummaryResponse, (long) attributeAmount);
final PaymentFundingSuccessResponse expect = new PaymentFundingSuccessResponse(PaymentSuccessReceiver.from(creator), productSummaryResponse, (long) attributeAmount);
final PaymentFundingSuccessResponse actual = paymentService.approveFunding(providerId, paymentSuccessRequest);

assertThat(actual).isEqualTo(expect);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public enum MemberFixture {
.gender(gender)
.phoneNumber(phoneNumber)
.providerId(providerId)
.profileImageUrl("defaultProfileImageUrl")
.build();
}
}
Loading