diff --git a/src/main/java/com/pawwithu/connectdog/ConnectdogApplication.java b/src/main/java/com/pawwithu/connectdog/ConnectdogApplication.java index 6fc2e797..5a99ecd5 100644 --- a/src/main/java/com/pawwithu/connectdog/ConnectdogApplication.java +++ b/src/main/java/com/pawwithu/connectdog/ConnectdogApplication.java @@ -2,7 +2,9 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +@EnableJpaAuditing @SpringBootApplication public class ConnectdogApplication { diff --git a/src/main/java/com/pawwithu/connectdog/common/entity/BaseTimeEntity.java b/src/main/java/com/pawwithu/connectdog/common/entity/BaseTimeEntity.java new file mode 100644 index 00000000..5302582e --- /dev/null +++ b/src/main/java/com/pawwithu/connectdog/common/entity/BaseTimeEntity.java @@ -0,0 +1,22 @@ +package com.pawwithu.connectdog.common.entity; + +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.LocalDateTime; + +@Getter +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +public class BaseTimeEntity { + + @CreatedDate + private LocalDateTime createdDate; + + @LastModifiedDate + private LocalDateTime modifiedDate; +} \ No newline at end of file