feat: add BaseEntity

This commit is contained in:
2026-09-08 19:45:54 +07:00
parent bcb3878c8b
commit a8a1dca641
@@ -0,0 +1,45 @@
package aplp.backend.core.common.entity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Getter
@Setter
@MappedSuperclass
public abstract class BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@Column(name = "created_by", length = 50, updatable = false)
private String createdBy;
@Column(name = "updated_at")
private LocalDateTime updatedAt;
@Column(name = "updated_by", length = 50)
private String updatedBy;
@Column(name = "deleted_at")
private LocalDateTime deletedAt;
@Column(name = "deleted_by", length = 50)
private String deletedBy;
@PrePersist
protected void onCreate() {
this.createdAt = LocalDateTime.now();
}
@PreUpdate
protected void onUpdate() {
this.updatedAt = LocalDateTime.now();
}
}