2025-11-24 10:26:19 +07:00
|
|
|
package ru.soune.no_copy.entity;
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
2025-11-24 10:26:19 +07:00
|
|
|
|
|
|
|
|
@Entity
|
|
|
|
|
@AllArgsConstructor
|
|
|
|
|
@NoArgsConstructor
|
|
|
|
|
@ToString
|
2025-11-24 12:29:32 +07:00
|
|
|
@EqualsAndHashCode
|
2025-11-24 10:26:19 +07:00
|
|
|
@Getter @Setter
|
2025-11-24 12:29:32 +07:00
|
|
|
@EntityListeners(AuditingEntityListener.class)
|
|
|
|
|
@Table(name = "users")
|
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-24 10:26:19 +07:00
|
|
|
private Long userId;
|
|
|
|
|
|
2025-11-24 12:29:32 +07:00
|
|
|
@Size(max = 64)
|
|
|
|
|
@Column(name = "firstName", nullable = false, length = 64)
|
|
|
|
|
private String firstName;
|
|
|
|
|
|
|
|
|
|
@Size(max = 64)
|
|
|
|
|
@Column(name = "lastName", nullable = false, length = 64)
|
|
|
|
|
private String lastName;
|
|
|
|
|
|
|
|
|
|
@Size(max = 64)
|
|
|
|
|
@Column(name = "secondName", length = 64)
|
|
|
|
|
private String secondName;
|
|
|
|
|
|
|
|
|
|
@Size(max = 1024)
|
|
|
|
|
@Column(name = "email", nullable = false, length = 1024, unique = true)
|
|
|
|
|
private String email;
|
|
|
|
|
|
|
|
|
|
@Column(nullable = false)
|
|
|
|
|
@JsonIgnore
|
|
|
|
|
private String password;
|
|
|
|
|
|
|
|
|
|
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
|
|
|
private List<AuthToken> tokens = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
@CreatedDate
|
|
|
|
|
@Column(name = "created_at", updatable = false, nullable = false)
|
|
|
|
|
private LocalDateTime createdAt;
|
|
|
|
|
|
|
|
|
|
@Column(name = "is_active")
|
2025-11-26 11:33:33 +07:00
|
|
|
private Boolean isActive = true;
|
2025-11-24 10:26:19 +07:00
|
|
|
|
|
|
|
|
}
|