From 6408ddd128de327258f2df6538cd47c547254b9a Mon Sep 17 00:00:00 2001 From: ParkSangHyun Date: Tue, 26 Jul 2022 18:21:45 +0900 Subject: [PATCH] =?UTF-8?q?[#4]=20FEAT=20:=20Base=20Entity=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mergedoc/backend/Base/BaseEntity.java | 23 ++++++++++++++++++ .../mergedoc/backend/Base/BaseTimeEntity.java | 24 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/main/java/com/mergedoc/backend/Base/BaseEntity.java create mode 100644 src/main/java/com/mergedoc/backend/Base/BaseTimeEntity.java diff --git a/src/main/java/com/mergedoc/backend/Base/BaseEntity.java b/src/main/java/com/mergedoc/backend/Base/BaseEntity.java new file mode 100644 index 0000000..8d351bc --- /dev/null +++ b/src/main/java/com/mergedoc/backend/Base/BaseEntity.java @@ -0,0 +1,23 @@ +package com.mergedoc.backend.Base; + +import lombok.Getter; +import org.springframework.data.annotation.CreatedBy; +import org.springframework.data.annotation.LastModifiedBy; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import javax.persistence.Column; +import javax.persistence.EntityListeners; +import javax.persistence.MappedSuperclass; + +@Getter +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +public class BaseEntity extends BaseTimeEntity{ + + @CreatedBy + @Column(updatable = false) + private String createdBy; + + @LastModifiedBy + private String lastModifiedBy; +} diff --git a/src/main/java/com/mergedoc/backend/Base/BaseTimeEntity.java b/src/main/java/com/mergedoc/backend/Base/BaseTimeEntity.java new file mode 100644 index 0000000..c81a4b1 --- /dev/null +++ b/src/main/java/com/mergedoc/backend/Base/BaseTimeEntity.java @@ -0,0 +1,24 @@ +package com.mergedoc.backend.Base; + +import lombok.Getter; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import javax.persistence.Column; +import javax.persistence.EntityListeners; +import javax.persistence.MappedSuperclass; +import java.time.LocalDateTime; + +@Getter +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +public class BaseTimeEntity { + + @CreatedDate + @Column(updatable = false) + private LocalDateTime createdDate; + + @LastModifiedDate + private LocalDateTime lastModifiedDate; +}