2025-12-10 19:12:54 +07:00
|
|
|
package ru.soune.nocopy.entity;
|
2025-11-24 10:26:19 +07:00
|
|
|
|
2025-11-24 12:29:32 +07:00
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
|
|
|
import jakarta.persistence.*;
|
|
|
|
|
import jakarta.validation.constraints.Size;
|
2025-11-24 10:26:19 +07:00
|
|
|
import lombok.*;
|
2025-11-24 12:29:32 +07:00
|
|
|
import org.springframework.data.annotation.CreatedDate;
|
|
|
|
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
|
|
|
|
|
2025-11-27 03:05:07 +07:00
|
|
|
import java.time.LocalDate;
|
2025-11-24 12:29:32 +07:00
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
2025-11-24 10:26:19 +07:00
|
|
|
|
|
|
|
|
@Entity
|
2025-11-24 12:29:32 +07:00
|
|
|
@Table(name = "users")
|
2025-11-26 15:49:51 +07:00
|
|
|
@Getter
|
|
|
|
|
@Setter
|
|
|
|
|
@NoArgsConstructor
|
|
|
|
|
@AllArgsConstructor
|
|
|
|
|
@ToString
|
|
|
|
|
@EntityListeners(AuditingEntityListener.class)
|
2025-11-24 10:26:19 +07:00
|
|
|
public class User {
|
2025-11-24 12:29:32 +07:00
|
|
|
|
2025-11-24 10:26:19 +07:00
|
|
|
@Id
|
2025-11-24 12:29:32 +07:00
|
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
2025-11-27 03:05:07 +07:00
|
|
|
private Long Id;
|
2025-11-24 10:26:19 +07:00
|
|
|
|
2025-11-27 03:05:07 +07:00
|
|
|
@Column(name = "full_name", nullable = false)
|
|
|
|
|
private String fullName;
|
2025-11-24 12:29:32 +07:00
|
|
|
|
|
|
|
|
@Size(max = 1024)
|
|
|
|
|
@Column(name = "email", nullable = false, length = 1024, unique = true)
|
|
|
|
|
private String email;
|
|
|
|
|
|
2025-11-27 03:05:07 +07:00
|
|
|
@Column(name = "company")
|
|
|
|
|
private String company;
|
|
|
|
|
|
2025-11-24 12:29:32 +07:00
|
|
|
@Column(nullable = false)
|
2025-11-27 03:05:07 +07:00
|
|
|
@Size(min = 6)
|
2025-11-24 12:29:32 +07:00
|
|
|
@JsonIgnore
|
|
|
|
|
private String password;
|
|
|
|
|
|
2025-11-27 03:05:07 +07:00
|
|
|
@Size(min = 11, max = 14)
|
|
|
|
|
private String phone;
|
|
|
|
|
|
2025-11-26 15:49:51 +07:00
|
|
|
@Enumerated(EnumType.STRING)
|
|
|
|
|
@Column(name = "subscription_type", nullable = false, length = 20)
|
2025-11-27 03:05:07 +07:00
|
|
|
private SubscriptionType subscriptionType = SubscriptionType.DEMO;
|
|
|
|
|
|
|
|
|
|
@Enumerated(EnumType.STRING)
|
|
|
|
|
@Column(name = "gender")
|
|
|
|
|
private GenderType genderType = GenderType.MALE;
|
|
|
|
|
|
|
|
|
|
@Column(name = "birthday")
|
|
|
|
|
private LocalDate birthday;
|
2025-11-24 12:29:32 +07:00
|
|
|
|
|
|
|
|
@CreatedDate
|
|
|
|
|
@Column(name = "created_at", updatable = false, nullable = false)
|
|
|
|
|
private LocalDateTime createdAt;
|
|
|
|
|
|
2025-11-26 15:49:51 +07:00
|
|
|
@Column(name = "last_login_at")
|
|
|
|
|
private LocalDateTime lastLoginAt;
|
|
|
|
|
|
2025-11-24 12:29:32 +07:00
|
|
|
@Column(name = "is_active")
|
2025-11-26 11:33:33 +07:00
|
|
|
private Boolean isActive = true;
|
2025-11-24 10:26:19 +07:00
|
|
|
|
2025-11-26 15:49:51 +07:00
|
|
|
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
|
|
|
@JsonIgnore
|
|
|
|
|
@ToString.Exclude
|
|
|
|
|
private List<AuthToken> tokens = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
|
|
|
@JsonIgnore
|
|
|
|
|
@ToString.Exclude
|
|
|
|
|
private List<UserContent> userContents = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
|
|
|
@JsonIgnore
|
|
|
|
|
@ToString.Exclude
|
|
|
|
|
private List<UserAction> userActions = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
|
|
|
@JsonIgnore
|
|
|
|
|
@ToString.Exclude
|
|
|
|
|
private List<Violation> violations = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
|
|
|
@JsonIgnore
|
|
|
|
|
@ToString.Exclude
|
|
|
|
|
private List<ImageProtection> imageProtections = new ArrayList<>();
|
2025-11-24 10:26:19 +07:00
|
|
|
}
|