2025-11-25 23:09:30 +07:00
|
|
|
package ru.soune.no_copy.entity;
|
|
|
|
|
|
|
|
|
|
import jakarta.persistence.*;
|
|
|
|
|
import lombok.*;
|
2025-11-26 15:49:51 +07:00
|
|
|
import org.springframework.data.annotation.CreatedDate;
|
|
|
|
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
2025-12-15 19:49:09 +07:00
|
|
|
import ru.soune.no_copy.entity.file.FileType;
|
2025-11-25 23:09:30 +07:00
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
|
|
|
|
@Entity
|
2025-11-26 15:49:51 +07:00
|
|
|
@Table(name = "user_content")
|
|
|
|
|
@Getter
|
|
|
|
|
@Setter
|
2025-11-25 23:09:30 +07:00
|
|
|
@NoArgsConstructor
|
|
|
|
|
@AllArgsConstructor
|
2025-11-26 15:49:51 +07:00
|
|
|
@ToString
|
|
|
|
|
@EntityListeners(AuditingEntityListener.class)
|
2025-11-25 23:09:30 +07:00
|
|
|
public class UserContent {
|
|
|
|
|
|
|
|
|
|
@Id
|
|
|
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
2025-11-26 15:49:51 +07:00
|
|
|
private Long contentId;
|
2025-11-25 23:09:30 +07:00
|
|
|
|
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
2025-11-26 15:49:51 +07:00
|
|
|
@JoinColumn(name = "user_id", nullable = false)
|
|
|
|
|
@ToString.Exclude
|
2025-11-25 23:09:30 +07:00
|
|
|
private User user;
|
|
|
|
|
|
2025-11-26 15:49:51 +07:00
|
|
|
@Column(name = "filename", nullable = false, length = 255)
|
2025-11-25 23:09:30 +07:00
|
|
|
private String filename;
|
|
|
|
|
|
2025-11-26 15:49:51 +07:00
|
|
|
@Column(name = "original_filename", nullable = false, length = 255)
|
2025-11-25 23:09:30 +07:00
|
|
|
private String originalFilename;
|
|
|
|
|
|
|
|
|
|
@Enumerated(EnumType.STRING)
|
2025-11-26 15:49:51 +07:00
|
|
|
@Column(name = "file_type", nullable = false, length = 20)
|
2025-11-25 23:09:30 +07:00
|
|
|
private FileType fileType;
|
|
|
|
|
|
2025-11-26 15:49:51 +07:00
|
|
|
@Column(name = "file_extension", nullable = false, length = 10)
|
2025-11-25 23:09:30 +07:00
|
|
|
private String fileExtension;
|
|
|
|
|
|
|
|
|
|
@Column(name = "file_size", nullable = false)
|
|
|
|
|
private Long fileSize;
|
|
|
|
|
|
2025-11-26 15:49:51 +07:00
|
|
|
@Column(name = "file_path", nullable = false, columnDefinition = "TEXT")
|
2025-11-25 23:09:30 +07:00
|
|
|
private String filePath;
|
|
|
|
|
|
|
|
|
|
@Column(name = "protection_level")
|
2025-11-26 15:49:51 +07:00
|
|
|
private Integer protectionLevel = 0;
|
2025-11-25 23:09:30 +07:00
|
|
|
|
|
|
|
|
@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)
|
2025-11-26 15:49:51 +07:00
|
|
|
@Column(name = "status", nullable = false, length = 20)
|
2025-11-25 23:09:30 +07:00
|
|
|
private ContentStatus status = ContentStatus.PROCESSING;
|
|
|
|
|
|
2025-11-26 15:49:51 +07:00
|
|
|
@CreatedDate
|
2025-11-25 23:09:30 +07:00
|
|
|
@Column(name = "upload_date", nullable = false, updatable = false)
|
|
|
|
|
private LocalDateTime uploadDate;
|
2025-11-26 15:49:51 +07:00
|
|
|
|
|
|
|
|
public Double getFileSizeInGB() {
|
|
|
|
|
return fileSize != null ? fileSize / (1024.0 * 1024.0 * 1024.0) : 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Boolean isProtected() {
|
|
|
|
|
return protectionLevel != null && protectionLevel > 0;
|
|
|
|
|
}
|
2025-11-25 23:09:30 +07:00
|
|
|
}
|
|
|
|
|
|