-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat: 회원 엔티티 구현(1차)
- Loading branch information
Showing
13 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
26 changes: 26 additions & 0 deletions
26
src/main/java/com/unit/daybook/domain/common/model/BaseTimeEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.unit.daybook.domain.common.model; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.MappedSuperclass; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@MappedSuperclass | ||
@EntityListeners(AuditingEntityListener.class) | ||
public abstract class BaseTimeEntity { | ||
|
||
@Column(updatable = false) | ||
@CreatedDate | ||
private LocalDateTime createdAt; | ||
|
||
@Column @LastModifiedDate | ||
private LocalDateTime updatedAt; | ||
} | ||
|
Empty file.
74 changes: 74 additions & 0 deletions
74
src/main/java/com/unit/daybook/domain/member/domain/Member.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.unit.daybook.domain.member.domain; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import com.unit.daybook.domain.common.model.BaseTimeEntity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embedded; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Member extends BaseTimeEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "member_id") | ||
private Long id; | ||
|
||
private String nickname; | ||
|
||
@Embedded | ||
private OauthInfo oauthInfo; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private MemberStatus status; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private MemberRole role; | ||
|
||
private LocalDateTime lastLoginAt; | ||
|
||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
private Member( | ||
String nickname, | ||
OauthInfo oauthInfo, | ||
MemberStatus status, | ||
MemberRole role, | ||
LocalDateTime lastLoginAt) { | ||
this.nickname = nickname; | ||
this.oauthInfo = oauthInfo; | ||
this.status = status; | ||
this.role = role; | ||
this.lastLoginAt = lastLoginAt; | ||
} | ||
|
||
public static Member createNormalMember(OauthInfo oauthInfo, String nickname) { | ||
return Member.builder() | ||
.nickname(nickname) | ||
.oauthInfo(oauthInfo) | ||
.status(MemberStatus.NORMAL) | ||
.role(MemberRole.USER) | ||
.build(); | ||
} | ||
|
||
public void updateLastLoginAt() { | ||
this.lastLoginAt = LocalDateTime.now(); | ||
} | ||
|
||
public void updateNickname() { | ||
this.nickname = nickname; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/unit/daybook/domain/member/domain/MemberRole.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.unit.daybook.domain.member.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum MemberRole { | ||
USER("ROLE_USER"), | ||
ADMIN("ROLE_ADMIN"); | ||
|
||
private final String value; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/unit/daybook/domain/member/domain/MemberStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.unit.daybook.domain.member.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum MemberStatus { | ||
NORMAL("NORMAL"), | ||
DELETED("DELETED"), | ||
FORBIDDEN("FORBIDDEN"); | ||
|
||
private final String value; | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/unit/daybook/domain/member/domain/OauthInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.unit.daybook.domain.member.domain; | ||
|
||
import jakarta.persistence.Embeddable; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Embeddable | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class OauthInfo { | ||
|
||
private String oauthId; | ||
private String oauthProvider; | ||
private String oauthEmail; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
private OauthInfo(String oauthId, String oauthProvider, String oauthEmail) { | ||
this.oauthId = oauthId; | ||
this.oauthProvider = oauthProvider; | ||
this.oauthEmail = oauthEmail; | ||
} | ||
|
||
public static OauthInfo createOauthInfo( | ||
String oauthId, String oauthProvider, String oauthEmail) { | ||
return OauthInfo.builder() | ||
.oauthId(oauthId) | ||
.oauthProvider(oauthProvider) | ||
.oauthEmail(oauthEmail) | ||
.build(); | ||
} | ||
} |
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions
8
src/main/java/com/unit/daybook/domain/member/repository/MemberRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.unit.daybook.domain.member.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.unit.daybook.domain.member.domain.Member; | ||
|
||
public interface MemberRepository extends JpaRepository<Member, Long>, MemberRepositoryCustom { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/com/unit/daybook/domain/member/repository/MemberRepositoryCustom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.unit.daybook.domain.member.repository; | ||
|
||
public interface MemberRepositoryCustom { | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/unit/daybook/domain/member/repository/MemberRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.unit.daybook.domain.member.repository; | ||
|
||
import org.springframework.stereotype.Repository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class MemberRepositoryImpl implements MemberRepositoryCustom { | ||
} |