package ru.soune.nocopy.entity; import jakarta.persistence.*; import lombok.*; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; import ru.soune.nocopy.entity.file.FileType; import java.time.LocalDateTime; @Entity @Table(name = "user_content") @Getter @Setter @NoArgsConstructor @AllArgsConstructor @ToString @EntityListeners(AuditingEntityListener.class) public class UserContent { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long contentId; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id", nullable = false) @ToString.Exclude private User user; @Column(name = "filename", nullable = false, length = 255) private String filename; @Column(name = "original_filename", nullable = false, length = 255) private String originalFilename; @Enumerated(EnumType.STRING) @Column(name = "file_type", nullable = false, length = 20) private FileType fileType; @Column(name = "file_extension", nullable = false, length = 10) private String fileExtension; @Column(name = "file_size", nullable = false) private Long fileSize; @Column(name = "file_path", nullable = false, columnDefinition = "TEXT") private String filePath; @Column(name = "protection_level") private Integer protectionLevel = 0; @Column(name = "geometric_resistant") private Boolean geometricResistant = false; @Column(name = "watermark_applied") private Boolean watermarkApplied = false; @Column(name = "protection_hash", length = 64) private String protectionHash; @Column(name = "watermark_id", length = 50) private String watermarkId; @Enumerated(EnumType.STRING) @Column(name = "status", nullable = false, length = 20) private ContentStatus status = ContentStatus.PROCESSING; @CreatedDate @Column(name = "upload_date", nullable = false, updatable = false) private LocalDateTime uploadDate; public Double getFileSizeInGB() { return fileSize != null ? fileSize / (1024.0 * 1024.0 * 1024.0) : 0.0; } public Boolean isProtected() { return protectionLevel != null && protectionLevel > 0; } }