Skip to content

Commit

Permalink
feat: BaseEntity 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
belljun3395 committed Dec 18, 2024
1 parent 5b02e96 commit 513d398
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions repo/src/main/kotlin/repo/jpa/BaseEntity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package repo.jpa

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import jakarta.persistence.*
import org.springframework.data.annotation.CreatedDate
import org.springframework.data.annotation.LastModifiedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import java.time.LocalDateTime

@MappedSuperclass
@JsonIgnoreProperties(value = ["createdAt, modifiedAt"], allowGetters = true)
@EntityListeners(AuditingEntityListener::class)
abstract class BaseEntity {
/** 생성일 */
@CreatedDate
@Column(name = "created_at", columnDefinition = "datetime default CURRENT_TIMESTAMP")
@EntityTimeJsonFormat
var createdAt: LocalDateTime = LocalDateTime.now()

/** 수정일 */
@LastModifiedDate
@Column(name = "modified_at", columnDefinition = "datetime default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
@EntityTimeJsonFormat
var modifiedAt: LocalDateTime = LocalDateTime.now()

/** 삭제 여부 */
@Column(name = "deleted", columnDefinition = "boolean default false")
var deleted: Boolean = false
}

0 comments on commit 513d398

Please sign in to comment.