diff --git a/application/src/main/java/org/depromeet/spot/application/member/dto/response/MemberResponse.java b/application/src/main/java/org/depromeet/spot/application/member/dto/response/MemberResponse.java index 469e981c..06ab8203 100644 --- a/application/src/main/java/org/depromeet/spot/application/member/dto/response/MemberResponse.java +++ b/application/src/main/java/org/depromeet/spot/application/member/dto/response/MemberResponse.java @@ -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()); } } diff --git a/domain/src/main/java/org/depromeet/spot/domain/member/Member.java b/domain/src/main/java/org/depromeet/spot/domain/member/Member.java index c931dcd9..d7a83b43 100644 --- a/domain/src/main/java/org/depromeet/spot/domain/member/Member.java +++ b/domain/src/main/java/org/depromeet/spot/domain/member/Member.java @@ -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; @@ -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; diff --git a/domain/src/main/java/org/depromeet/spot/domain/member/enums/MemberRole.java b/domain/src/main/java/org/depromeet/spot/domain/member/enums/MemberRole.java new file mode 100644 index 00000000..1f7c25c1 --- /dev/null +++ b/domain/src/main/java/org/depromeet/spot/domain/member/enums/MemberRole.java @@ -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; +} diff --git a/domain/src/main/java/org/depromeet/spot/domain/member/enums/SnsProvider.java b/domain/src/main/java/org/depromeet/spot/domain/member/enums/SnsProvider.java new file mode 100644 index 00000000..f5cc1349 --- /dev/null +++ b/domain/src/main/java/org/depromeet/spot/domain/member/enums/SnsProvider.java @@ -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; +} diff --git a/infrastructure/jpa/src/main/java/org/depromeet/spot/jpa/member/entity/MemberEntity.java b/infrastructure/jpa/src/main/java/org/depromeet/spot/jpa/member/entity/MemberEntity.java index fd59477a..9a9c1592 100644 --- a/infrastructure/jpa/src/main/java/org/depromeet/spot/jpa/member/entity/MemberEntity.java +++ b/infrastructure/jpa/src/main/java/org/depromeet/spot/jpa/member/entity/MemberEntity.java @@ -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; @@ -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) @@ -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( @@ -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() { @@ -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()); }