package at.procon.dip.domain.time.entity.leitstand;

import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
import java.time.OffsetDateTime;
import lombok.Getter;
import lombok.Setter;

@MappedSuperclass
@Getter
@Setter
public abstract class AbstractLeitstandStampedEntity {
    @Column(name = "dbk_uid", length = 7) private String dbkUid;
    @Column(name = "upd", length = 24) private String upd;
    @Column(name = "upd_anz") private Integer updAnz;
    @Column(name = "upd_uid", length = 7) private String updUid;
    @Column(name = "status") private Integer status;
    @Column(name = "created_at", nullable = false, updatable = false) private OffsetDateTime createdAt = OffsetDateTime.now();
    @Column(name = "updated_at", nullable = false) private OffsetDateTime updatedAt = OffsetDateTime.now();
    @PrePersist protected void onCreate() { createdAt = OffsetDateTime.now(); updatedAt = OffsetDateTime.now(); }
    @PreUpdate protected void onUpdate() { updatedAt = OffsetDateTime.now(); }
}
