Files
no-copy/src/main/java/ru/soune/nocopy/entity/violation/ViolationNotion.java
T

55 lines
1.4 KiB
Java
Raw Normal View History

2026-03-17 16:35:27 +07:00
package ru.soune.nocopy.entity.violation;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import ru.soune.nocopy.entity.user.User;
import java.time.LocalDateTime;
@Entity
@Getter @Setter
@Table(name = "violation_notions")
@NoArgsConstructor
@EntityListeners(AuditingEntityListener.class)
public class ViolationNotion {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
@JsonIgnore
private User user;
2026-03-17 22:23:19 +07:00
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "violation_id", nullable = false)
@JsonIgnore
private Violation violation;
2026-03-17 16:35:27 +07:00
@CreatedDate
@Column(name = "created_at", updatable = false, nullable = false)
private LocalDateTime createdAt;
@LastModifiedDate
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@Column(name = "message")
private String message;
2026-04-06 12:37:49 +07:00
@PrePersist
public void prePersist() {
if (this.createdAt == null) {
this.createdAt = LocalDateTime.now();
}
this.updatedAt = LocalDateTime.now();
}
2026-03-17 16:35:27 +07:00
}