api sample
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package com.kamco.cd.kamcoback.postgres;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import jakarta.persistence.PrePersist;
|
||||
import jakarta.persistence.PreUpdate;
|
||||
import java.time.ZonedDateTime;
|
||||
import lombok.Getter;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
|
||||
@Getter
|
||||
@MappedSuperclass
|
||||
public class CommonDateEntity {
|
||||
|
||||
@CreatedDate
|
||||
@Column(name = "created_date", updatable = false, nullable = false)
|
||||
private ZonedDateTime createdDate;
|
||||
|
||||
@LastModifiedDate
|
||||
@Column(name = "modified_date", nullable = false)
|
||||
private ZonedDateTime modifiedDate;
|
||||
|
||||
@PrePersist
|
||||
protected void onPersist() {
|
||||
this.createdDate = ZonedDateTime.now();
|
||||
this.modifiedDate = ZonedDateTime.now();
|
||||
}
|
||||
|
||||
@PreUpdate
|
||||
protected void onUpdate() {
|
||||
this.modifiedDate = ZonedDateTime.now();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user