Files
nahodka-back/src/main/java/com/krylov/refound/entity/advertising/Impression.java
2026-10-11 23:26:11 +03:00

39 lines
856 B
Java

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();
}
}
}