package com.krylov.refound.entity.advertising; import com.krylov.refound.util.TimeZoneContext; import jakarta.persistence.*; import lombok.Getter; import lombok.Setter; import java.time.LocalDateTime; @Entity @Table(name = "impression") @Getter @Setter public class Impression { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @ManyToOne(fetch = FetchType.LAZY, optional = false) @JoinColumn(name = "advertising_id", nullable = false) private Advertising advertising; @Column(name = "user_id") private Long userId; @Column(name = "session_id", nullable = false, length = 64) private String sessionId; @Column(name = "shown_at", nullable = false) private LocalDateTime shownAt; @PrePersist protected void onCreate() { if (shownAt == null) { shownAt = TimeZoneContext.now(); } } }