Skip to content

Commit

Permalink
[Weekly/11/Refactor/all] 소셜로그인 오류 수정 (#148)
Browse files Browse the repository at this point in the history
* refactor: gender enum으로 수정

* hotfix: 소셜로그인 오류 수정
  • Loading branch information
lja3723 committed Nov 15, 2024
1 parent ecf26ff commit f7c6964
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ protected AccountType getAccountType() {
}

@Override
protected OauthRequest getOauthRequestBase() {
return OauthRequest.builder()
public OauthResourcesResponse getOauthMemberResources(String code) {
return requestLoginAndAccessResources(OauthRequest.builder()
.grantType("authorization_code")
.clientId(clientId)
.clientSecret(clientSecret)
.redirectUri(redirectUri)
.build();
.code(code)
.build());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ protected HttpHeaders getAccessRequestHeaders(AccessTokenResponse authentication
}

@Override
protected OauthRequest getOauthRequestBase() {
return OauthRequest.builder()
public OauthResourcesResponse getOauthMemberResources(String code) {
return requestLoginAndAccessResources(OauthRequest.builder()
.grantType("authorization_code")
.clientId(clientId)
.clientSecret(clientSecret)
.redirectUri(redirectUri)
.build();
.code(code)
.build());
}


@Override
protected OauthResourcesResponse requestLoginAndAccessResources(OauthRequest request) {
AccessTokenResponse authenticationResponse = client.post(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,9 @@
@Service
public abstract class OauthRequestService {

private OauthRequest oauthRequestBase;

protected abstract AccountType getAccountType();

protected abstract OauthRequest getOauthRequestBase();

protected abstract OauthResourcesResponse requestLoginAndAccessResources(OauthRequest oauthRequest);

@PostConstruct
private void init() {
oauthRequestBase = getOauthRequestBase();
}

final public OauthResourcesResponse getOauthMemberResources(String code) {
return requestLoginAndAccessResources(oauthRequestBase.toBuilder()
.code(code)
.build());
}
public abstract OauthResourcesResponse getOauthMemberResources(String code);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@Getter
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
@Builder(toBuilder = true)
@Builder
@JsonNaming(SnakeCaseStrategy.class)
public class OauthRequest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.ktc2.cokaen.wouldyouin.like.persist;

import jakarta.persistence.Column;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
Expand Down Expand Up @@ -39,6 +41,7 @@ public abstract class Like<T extends LikeableMember> {

@NotNull
@Column
@Enumerated(EnumType.STRING)
private MemberType likeableMemberType;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.ktc2.cokaen.wouldyouin._common.vo.Area;
import org.ktc2.cokaen.wouldyouin.member.persist.BaseMember;
import org.ktc2.cokaen.wouldyouin.member.persist.Curator;
import org.ktc2.cokaen.wouldyouin.member.persist.Gender;
import org.ktc2.cokaen.wouldyouin.member.persist.Host;
import org.ktc2.cokaen.wouldyouin.member.persist.Member;
import org.ktc2.cokaen.wouldyouin.member.persist.MemberType;
Expand All @@ -26,7 +27,7 @@ public class MemberResponse {
private MemberType memberType;

private Area area;
private String gender;
private Gender gender;

private String intro;
private Integer likes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.ktc2.cokaen.wouldyouin.member.persist.Gender;
import org.ktc2.cokaen.wouldyouin.member.persist.Member;

@Getter
Expand All @@ -16,7 +17,7 @@ public class ReservationMemberResponse {
private String email;
private String nickname;
private String phone;
private String gender;
private Gender gender;

public static ReservationMemberResponse from(Member member) {
return ReservationMemberResponse.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import org.ktc2.cokaen.wouldyouin._common.vo.Area;
import org.ktc2.cokaen.wouldyouin.member.persist.Gender;

@Getter
@EqualsAndHashCode
Expand All @@ -14,5 +15,5 @@ public class MemberAdditionalInfoRequest {

private String phone;
private Area area;
private String gender;
private Gender gender;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.ktc2.cokaen.wouldyouin._common.vo.Area;
import org.ktc2.cokaen.wouldyouin.image.persist.MemberImage;
import org.ktc2.cokaen.wouldyouin.member.persist.AccountType;
import org.ktc2.cokaen.wouldyouin.member.persist.Gender;
import org.ktc2.cokaen.wouldyouin.member.persist.Member;

@Getter
Expand Down Expand Up @@ -36,7 +37,7 @@ public Member toEntity(MemberImage profileImage, String thumbnailImageUrl) {
.accountType(this.accountType)
.socialId(this.socialId)
.area(Area.서울)
.gender("")
.gender(Gender.MAN)
.profileImage(profileImage)
.profileImageThumbnailUrl(thumbnailImageUrl)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class Curator extends Member implements LikeableMember {
private List<Curation> curations = new ArrayList<>();

@Builder(builderMethodName = "curatorBuilder")
public Curator(AccountType accountType, String email, String nickname, String phone, MemberImage profileImage, String profileImageThumbnailUrl, Area area, String gender,
public Curator(AccountType accountType, String email, String nickname, String phone, MemberImage profileImage, String profileImageThumbnailUrl, Area area, Gender gender,
String socialId) {
super(accountType, MemberType.curator, email, nickname, phone, profileImage, profileImageThumbnailUrl, area, gender, socialId);
this.intro = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.ktc2.cokaen.wouldyouin.member.persist;

import lombok.Getter;

@Getter
public enum Gender {
MAN, WOMAN
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@DiscriminatorValue("Host")
@EqualsAndHashCode(callSuper = true)
@ToString()
@ToString
@Entity
public class Host extends BaseMember implements LikeableMember {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public class Member extends BaseMember {
private Area area;

@Column(nullable = false, name = "gender")
private String gender;
@Enumerated(EnumType.STRING)
private Gender gender;

@Column(name = "social_id")
private String socialId; //소셜 타입 식별자 값
Expand All @@ -60,7 +61,7 @@ public class Member extends BaseMember {
private List<Review> reviews = new ArrayList<>();

// for Curator
protected Member(AccountType accountType, MemberType memberType, String email, String nickname, String phone, MemberImage profileImage, String profileImageThumbNailUrl, Area area, String gender, String socialId) {
protected Member(AccountType accountType, MemberType memberType, String email, String nickname, String phone, MemberImage profileImage, String profileImageThumbNailUrl, Area area, Gender gender, String socialId) {
super(accountType, memberType, email, nickname, phone, profileImage, profileImageThumbNailUrl);
this.area = area;
this.gender = gender;
Expand All @@ -69,7 +70,7 @@ protected Member(AccountType accountType, MemberType memberType, String email, S

@Builder
// for public builder
protected Member(AccountType accountType, String email, String nickname, String phone, MemberImage profileImage, String profileImageThumbnailUrl, Area area, String gender, String socialId) {
protected Member(AccountType accountType, String email, String nickname, String phone, MemberImage profileImage, String profileImageThumbnailUrl, Area area, Gender gender, String socialId) {
this(accountType, MemberType.welcome, email, nickname, phone, profileImage, profileImageThumbnailUrl, area, gender, socialId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.ktc2.cokaen.wouldyouin.member.api.dto.relationResponse.ReservationMemberResponse;
import org.ktc2.cokaen.wouldyouin.member.persist.AccountType;
import org.ktc2.cokaen.wouldyouin.member.persist.Curator;
import org.ktc2.cokaen.wouldyouin.member.persist.Gender;
import org.ktc2.cokaen.wouldyouin.member.persist.Host;
import org.ktc2.cokaen.wouldyouin.member.persist.Member;
import org.ktc2.cokaen.wouldyouin.member.persist.MemberType;
Expand Down Expand Up @@ -56,7 +57,7 @@ public static List<Review> reviews() {
public static final String profileImageUrl = ImageData.R.member.normal.url;
public static final String profileImageThumbnailUrl = ImageData.getThumbnailUrl(profileImage);
public static final Area area = Area.광주;
public static final String gender = "Men";
public static final Gender gender = Gender.MAN;
public static final String socialId = "100100100100100";
public static final MemberType memberType = MemberType.normal;
}
Expand All @@ -81,7 +82,7 @@ public static List<Curation> curations() {
public static final String profileImageUrl = ImageData.R.member.curator.url;
public static final String profileImageThumbnailUrl = ImageData.getThumbnailUrl(profileImage);
public static final Area area = Area.광주;
public static final String gender = "Women";
public static final Gender gender = Gender.WOMAN;
public static final String socialId = "200200200200200";
public static final String intro = "큐레이터 자기소개입니다.";
public static final List<String> hashtags = List.of("#큐레이터", "#해시태그", "#입니다");
Expand Down Expand Up @@ -122,7 +123,7 @@ public static class welcome1 {
public static final String profileImageUrl = ImageData.R.member.welcome.url;
public static final String profileImageThumbnailUrl = ImageData.getThumbnailUrl(profileImage);
public static final Area area = Area.서울;
public static final String gender = "Men";
public static final Gender gender = Gender.MAN;
public static final String socialId = "456456456456";

}
Expand Down

0 comments on commit f7c6964

Please sign in to comment.