-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feat: member 엔티티 추가 * Feat: 생성, 변경 일자 auditing class 추가 * Fix: annotation formatting을 여러줄 형식으로 수정
- Loading branch information
1 parent
5562fb6
commit 57ba668
Showing
7 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
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
21 changes: 21 additions & 0 deletions
21
src/main/java/com/dnd/runus/domain/common/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,21 @@ | ||
package com.dnd.runus.domain.common; | ||
|
||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.MappedSuperclass; | ||
import lombok.Getter; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import java.time.Instant; | ||
|
||
@Getter | ||
@MappedSuperclass | ||
@EntityListeners(AuditingEntityListener.class) | ||
public abstract class BaseTimeEntity { | ||
@CreatedDate | ||
private Instant createdAt; | ||
|
||
@LastModifiedDate | ||
private Instant updatedAt; | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/com/dnd/runus/domain/member/entity/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,44 @@ | ||
package com.dnd.runus.domain.member.entity; | ||
|
||
import com.dnd.runus.domain.common.BaseTimeEntity; | ||
import com.dnd.runus.global.constant.MemberRole; | ||
import com.dnd.runus.global.constant.SocialType; | ||
import jakarta.persistence.*; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import static jakarta.persistence.EnumType.STRING; | ||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
@Getter | ||
@Entity | ||
@NoArgsConstructor(access = PROTECTED) | ||
public class Member extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@NotNull | ||
@Enumerated(STRING) | ||
private MemberRole role; | ||
|
||
@NotNull | ||
private String oauthId; | ||
|
||
@NotNull | ||
@Enumerated(STRING) | ||
private SocialType socialType; | ||
|
||
@NotNull | ||
private String oauthEmail; | ||
|
||
@Builder | ||
private Member(MemberRole role, String oauthId, SocialType socialType, String oauthEmail) { | ||
this.role = role; | ||
this.oauthId = oauthId; | ||
this.socialType = socialType; | ||
this.oauthEmail = oauthEmail; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/dnd/runus/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,6 @@ | ||
package com.dnd.runus.domain.member.repository; | ||
|
||
import com.dnd.runus.domain.member.entity.Member; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface MemberRepository extends JpaRepository<Member, Long> {} |
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.dnd.runus.global.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ||
|
||
@EnableJpaAuditing | ||
@Configuration | ||
public class JpaConfig {} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/dnd/runus/global/constant/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,15 @@ | ||
package com.dnd.runus.global.constant; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import static lombok.AccessLevel.PRIVATE; | ||
|
||
@Getter | ||
@RequiredArgsConstructor(access = PRIVATE) | ||
public enum MemberRole { | ||
USER("ROLE_USER"), | ||
ADMIN("ROLE_ADMIN"), | ||
; | ||
private final String value; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/dnd/runus/global/constant/SocialType.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.dnd.runus.global.constant; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import static lombok.AccessLevel.PRIVATE; | ||
|
||
@Getter | ||
@RequiredArgsConstructor(access = PRIVATE) | ||
public enum SocialType { | ||
APPLE("apple"), | ||
; | ||
private final String value; | ||
} |