Skip to content

Commit 842a1fa

Browse files
committed
refactor: TimeBaseEntity가 TimeUtil을 사용하도록 수정하고 null-able을 없앤다
1 parent 35907de commit 842a1fa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: src/main/kotlin/me/nalab/api/core/TimeBaseEntity.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ abstract class TimeBaseEntity {
1515
nullable = false,
1616
updatable = false,
1717
)
18-
protected var createdAt: Instant? = null
18+
protected lateinit var createdAt: Instant
1919

2020
@Column(name = "updated_at", columnDefinition = "TIMESTAMP(6)", nullable = false)
21-
protected var updatedAt: Instant? = null
21+
protected lateinit var updatedAt: Instant
2222

2323
@PrePersist
2424
fun prePersist() {
25-
val now = Instant.now()
26-
createdAt = if (createdAt != null) createdAt else now
27-
updatedAt = if (updatedAt != null) updatedAt else now
25+
val now = TimeUtil.now()
26+
createdAt = now
27+
updatedAt = now
2828
}
2929

3030
@PreUpdate
3131
fun preUpdate() {
32-
updatedAt = Instant.now()
32+
updatedAt = TimeUtil.now()
3333
}
3434
}
3535

0 commit comments

Comments
 (0)