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] #27 회원가입 시 마케팅 활용 정보 동의 필드 추가 #39

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -33,7 +33,13 @@ public AppJoinResponse join(AppJoinRequest request) {
throw new BusinessException(AuthError.DUPLICATE_NICKNAME);

SimpleMember entity = simpleMemberRepository.save(
SimpleMember.of(request.email(), encoder.encode(request.password()), request.nickname(), RoleType.ROLE_USER)
SimpleMember.of(
request.email(),
encoder.encode(request.password()),
request.nickname(),
RoleType.ROLE_USER,
request.acceptsMarketing()
)
);
return AppJoinResponse.of(entity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ private OAuthMember getOAuthMember(ProviderType providerType, UserInfoResponse u
providerType,
userInfoResponse.id(),
providerType + "_" + userInfoResponse.id(),
RoleType.ROLE_TEMP_USER
RoleType.ROLE_TEMP_USER,
null
)
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public record AppJoinRequest(
String email,
String password,
String nickname
String nickname,
Boolean acceptsMarketing
) {
}
12 changes: 9 additions & 3 deletions src/main/java/com/tteokguk/tteokguk/member/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,30 @@ public class Member extends BaseEntity {
@Column(name = "role")
private RoleType role;

@Column(name = "accepts_marketing")
private Boolean acceptsMarketing;

protected Member(
Ingredient primaryIngredient,
String nickname,
List<Item> items
List<Item> items,
Boolean acceptsMarketing
) {
this(primaryIngredient, nickname, items, RoleType.ROLE_USER);
this(primaryIngredient, nickname, items, RoleType.ROLE_USER, acceptsMarketing);
}

protected Member(
Ingredient primaryIngredient,
String nickname,
List<Item> items,
RoleType role
RoleType role,
Boolean acceptsMarketing
) {
this.primaryIngredient = primaryIngredient;
this.nickname = nickname;
this.items = items;
this.role = role;
this.acceptsMarketing = acceptsMarketing;
}

// Initialize Item
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/com/tteokguk/tteokguk/member/domain/OAuthMember.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,25 @@ private OAuthMember(
String nickname,
Ingredient primaryIngredient,
List<Item> items,
RoleType role
RoleType role,
Boolean acceptsMarketing
) {
super(primaryIngredient, nickname, items, role);
super(primaryIngredient, nickname, items, role, acceptsMarketing);
this.providerType = providerType;
this.resourceId = resourceId;
}

public static OAuthMember of(ProviderType providerType, String resourceId, String nickname, RoleType role) {
public static OAuthMember of(
ProviderType providerType,
String resourceId,
String nickname,
RoleType role,
Boolean acceptsMarketing
) {
Ingredient primaryIngredient = Ingredient.random();

OAuthMember member = new OAuthMember(
providerType, resourceId, nickname, primaryIngredient, new ArrayList<>(), role
providerType, resourceId, nickname, primaryIngredient, new ArrayList<>(), role, acceptsMarketing
);

member.initializeItem(primaryIngredient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,25 @@ private SimpleMember(
String nickname,
Ingredient primaryIngredient,
List<Item> items,
RoleType role
RoleType role,
Boolean acceptsMarketing
) {
super(primaryIngredient, nickname, items, role);
super(primaryIngredient, nickname, items, role, acceptsMarketing);
this.email = email;
this.password = password;
}

public static SimpleMember of(String email, String password, String nickname, RoleType role) {
public static SimpleMember of(
String email,
String password,
String nickname,
RoleType role,
Boolean acceptsMarketing
) {
Ingredient primaryIngredient = Ingredient.random();

SimpleMember member = new SimpleMember(
email, password, nickname, primaryIngredient, new ArrayList<>(), role
email, password, nickname, primaryIngredient, new ArrayList<>(), role, acceptsMarketing
);

member.initializeItem(primaryIngredient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ public record WebJoinRequest(
message = "영문, 숫자, 특수문자가 반드시 조합되어야 합니다.")
String password,
@Length(min = 2, max = 6, message = "닉네임을 2 ~ 6글자로 입력해주세요.")
String nickname
String nickname,
@NotNull(message = "해당 필드는 필수값입니다.")
@Pattern(regexp = "true|false", message = "true 혹은 false로 입력해주세요.")
String acceptsMarketing
) {

public AppJoinRequest convert() {
return new AppJoinRequest(email, password, nickname);
return new AppJoinRequest(email, password, nickname, Boolean.valueOf(acceptsMarketing));
}
}
Loading