Перенос кода из ЛР5 в ЛР6 (начало)
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
package ru.mtusi.messenger.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "attachments")
|
||||
public class AttachmentEntity {
|
||||
@Id
|
||||
private UUID id;
|
||||
|
||||
@Column(name = "chat_id", nullable = false)
|
||||
private UUID chatId;
|
||||
|
||||
@Column(name = "owner_id", nullable = false)
|
||||
private UUID ownerId;
|
||||
|
||||
@Column(nullable = false, length = 255)
|
||||
private String filename;
|
||||
|
||||
@Column(name = "content_type", nullable = false, length = 100)
|
||||
private String contentType;
|
||||
|
||||
@Column(name = "size_bytes", nullable = false)
|
||||
private long sizeBytes;
|
||||
|
||||
@Column(nullable = false, length = 64)
|
||||
private String sha256;
|
||||
|
||||
@Column(name = "object_key", nullable = false, length = 255)
|
||||
private String objectKey;
|
||||
|
||||
@Column(name = "created_at", nullable = false)
|
||||
private OffsetDateTime createdAt;
|
||||
|
||||
// === НОВЫЕ ПОЛЯ ===
|
||||
@Column(nullable = false, length = 20)
|
||||
private String status = "queued";
|
||||
|
||||
@Column(name = "error_code", length = 50)
|
||||
private String errorCode;
|
||||
|
||||
@Column(name = "updated_at", nullable = false)
|
||||
private OffsetDateTime updatedAt;
|
||||
// ==================
|
||||
|
||||
// Связь с вариантами (thumbnail)
|
||||
@OneToMany(mappedBy = "attachment", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
|
||||
private List<AttachmentVariantEntity> variants = new ArrayList<>();
|
||||
|
||||
// --- Геттеры и сеттеры ---
|
||||
public UUID getId() { return id; }
|
||||
public void setId(UUID id) { this.id = id; }
|
||||
public UUID getChatId() { return chatId; }
|
||||
public void setChatId(UUID chatId) { this.chatId = chatId; }
|
||||
public UUID getOwnerId() { return ownerId; }
|
||||
public void setOwnerId(UUID ownerId) { this.ownerId = ownerId; }
|
||||
public String getFilename() { return filename; }
|
||||
public void setFilename(String filename) { this.filename = filename; }
|
||||
public String getContentType() { return contentType; }
|
||||
public void setContentType(String contentType) { this.contentType = contentType; }
|
||||
public long getSizeBytes() { return sizeBytes; }
|
||||
public void setSizeBytes(long sizeBytes) { this.sizeBytes = sizeBytes; }
|
||||
public String getSha256() { return sha256; }
|
||||
public void setSha256(String sha256) { this.sha256 = sha256; }
|
||||
public String getObjectKey() { return objectKey; }
|
||||
public void setObjectKey(String objectKey) { this.objectKey = objectKey; }
|
||||
public OffsetDateTime getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(OffsetDateTime createdAt) { this.createdAt = createdAt; }
|
||||
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
public String getErrorCode() { return errorCode; }
|
||||
public void setErrorCode(String errorCode) { this.errorCode = errorCode; }
|
||||
public OffsetDateTime getUpdatedAt() { return updatedAt; }
|
||||
public void setUpdatedAt(OffsetDateTime updatedAt) { this.updatedAt = updatedAt; }
|
||||
public List<AttachmentVariantEntity> getVariants() { return variants; }
|
||||
public void setVariants(List<AttachmentVariantEntity> variants) { this.variants = variants; }
|
||||
}
|
||||
Reference in New Issue
Block a user