Skip to content

Commit

Permalink
[BSVR-127] 멤버 Entity 변경 (#37)
Browse files Browse the repository at this point in the history
* refactor : MemberEntity SNS 정보 정책으로 인한 변경

* refactor : MemberEntity KAKAO 정보 정책으로 인한 변경

* fix: Member entity 수정에 따른 이슈 해결

---------

Co-authored-by: EunjiShin <eunji980310@gmail.com>
  • Loading branch information
wjdwnsdnjs13 and EunjiShin authored Jul 17, 2024
1 parent a674d24 commit c75652c
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
public record MemberResponse(Long id, String name) {

public static MemberResponse from(Member member) {
return new MemberResponse(member.getUserId(), member.getName());
return new MemberResponse(member.getId(), member.getName());
}
}
25 changes: 15 additions & 10 deletions domain/src/main/java/org/depromeet/spot/domain/member/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,45 @@

import java.time.LocalDateTime;

import org.depromeet.spot.domain.member.enums.MemberRole;
import org.depromeet.spot.domain.member.enums.SnsProvider;

import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class Member {

private final Long userId;
private final Long id;
private final String email;
private final String name;
private final String nickname;
private final String phoneNumber;
private final Integer level;
private final String profileImage;
private final String snsProvider;
private final SnsProvider snsProvider;
private final String idToken;
private final String myTeam;
private final Integer role;
private final Long teamId;
private final MemberRole role;
private final LocalDateTime createdAt;
private final LocalDateTime deletedAt;

public Member(
Long userId,
Long id,
String email,
String name,
String nickname,
String phoneNumber,
Integer level,
String profileImage,
String snsProvider,
SnsProvider snsProvider,
String idToken,
String myTeam,
Integer role,
Long teamId,
MemberRole role,
LocalDateTime createdAt,
LocalDateTime deletedAt) {
this.userId = userId;
this.id = id;
this.email = email;
this.name = name;
this.nickname = nickname;
Expand All @@ -44,7 +49,7 @@ public Member(
this.profileImage = profileImage;
this.snsProvider = snsProvider;
this.idToken = idToken;
this.myTeam = myTeam;
this.teamId = teamId;
this.role = role;
this.createdAt = createdAt;
this.deletedAt = deletedAt;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.depromeet.spot.domain.member.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum MemberRole {
ROLE_USER("ROLE_USER"),
ROLE_ADMIN("ROLE_ADMIN");

private final String value;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.depromeet.spot.domain.member.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum SnsProvider {
KAKAO("KAKAO");

private final String value;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import jakarta.persistence.Table;

import org.depromeet.spot.domain.member.Member;
import org.depromeet.spot.domain.member.enums.MemberRole;
import org.depromeet.spot.domain.member.enums.SnsProvider;
import org.depromeet.spot.jpa.common.entity.BaseEntity;
import org.hibernate.annotations.ColumnDefault;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
Expand All @@ -16,19 +19,24 @@
@AllArgsConstructor
public class MemberEntity extends BaseEntity {

@Column(name = "email", nullable = false, unique = true, length = 50)
// TODO : email 받아온 후 nullable = false로 바꿔야함.
@Column(name = "email", nullable = true, unique = true, length = 50)
private String email;

@Column(name = "name", nullable = false, length = 20)
// TODO : 이름 받아온 후 nullable = false로 바꿔야함.
@Column(name = "name", nullable = true, length = 20)
private String name;

@Column(name = "nickname", nullable = false, unique = true, length = 10)
private String nickname;

@Column(name = "phone_number", nullable = false, unique = true, length = 13)
// TODO : phone_number 받아온 후 nullable = false로 바꿔야함.
@Column(name = "phone_number", nullable = true, unique = true, length = 13)
private String phoneNumber;

@Column(name = "level", nullable = false)
// TODO : ERD nullable로 변경
@Column(name = "level")
@ColumnDefault("1")
private Integer level;

@Column(name = "profile_image", length = 255)
Expand All @@ -40,11 +48,11 @@ public class MemberEntity extends BaseEntity {
@Column(name = "id_token", nullable = false, unique = true, length = 255)
private String idToken;

@Column(name = "my_team", nullable = false, length = 10)
private String myTeam;
@Column(name = "team_id", nullable = false, length = 10)
private Long teamId;

@Column(name = "role", nullable = false)
private Integer role;
private String role;

public static MemberEntity from(Member member) {
return new MemberEntity(
Expand All @@ -54,10 +62,10 @@ public static MemberEntity from(Member member) {
member.getPhoneNumber(),
member.getLevel(),
member.getProfileImage(),
member.getSnsProvider(),
member.getSnsProvider().getValue(),
member.getIdToken(),
member.getMyTeam(),
member.getRole());
member.getTeamId(),
member.getRole().getValue());
}

public Member toDomain() {
Expand All @@ -69,10 +77,10 @@ public Member toDomain() {
phoneNumber,
level,
profileImage,
snsProvider,
SnsProvider.valueOf(snsProvider),
idToken,
myTeam,
role,
teamId,
MemberRole.valueOf(role),
this.getCreatedAt(),
this.getDeletedAt());
}
Expand Down

0 comments on commit c75652c

Please sign in to comment.