Skip to content

Commit

Permalink
fix: modifiedAt이 업데이트 되지 않는버그를 수정한다
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb committed May 11, 2024
1 parent 1e552a1 commit c5037c2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/kotlin/org/gitanimals/render/domain/AbstractTime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.gitanimals.render.domain

import jakarta.persistence.Column
import jakarta.persistence.MappedSuperclass
import jakarta.persistence.PrePersist
import org.springframework.data.annotation.CreatedDate
import org.springframework.data.annotation.LastModifiedDate
import java.time.Instant
Expand All @@ -14,5 +15,14 @@ abstract class AbstractTime(

@LastModifiedDate
@Column(name = "modified_at")
val modifiedAt: Instant = createdAt,
)
var modifiedAt: Instant? = null,
) {

@PrePersist
fun prePersist() {
modifiedAt = when (modifiedAt == null) {
true -> createdAt
false -> return
}
}
}

0 comments on commit c5037c2

Please sign in to comment.