This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package ru.soune.nocopy.entity.file;
|
||||
|
||||
public enum AppealStatus {
|
||||
PENDING,
|
||||
IN_REVIEW,
|
||||
APPROVED,
|
||||
REJECTED,
|
||||
EXPIRED
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package ru.soune.nocopy.entity.file;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "file_appeals")
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
public class FileAppeal {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
private String id;
|
||||
|
||||
@Column(name = "file_id", nullable = false)
|
||||
private String fileId;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "file_id", insertable = false, updatable = false)
|
||||
@ToString.Exclude
|
||||
private FileEntity file;
|
||||
|
||||
@Column(name = "user_id", nullable = false)
|
||||
private Long userId;
|
||||
|
||||
@Column(name = "appeal_reason", nullable = false, columnDefinition = "TEXT")
|
||||
private String appealReason;
|
||||
|
||||
@Column(name = "additional_info", columnDefinition = "TEXT")
|
||||
private String additionalInfo;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "status", nullable = false)
|
||||
private AppealStatus status;
|
||||
|
||||
@Column(name = "admin_comment", columnDefinition = "TEXT")
|
||||
private String adminComment;
|
||||
|
||||
@Column(name = "moderator_id")
|
||||
private Long moderatorId;
|
||||
|
||||
@Column(name = "moderation_before_status")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private FileStatus moderationBeforeStatus;
|
||||
|
||||
@Column(name = "moderation_reason_id")
|
||||
private Long moderationReasonId;
|
||||
|
||||
@Column(name = "resolved_at")
|
||||
private LocalDateTime resolvedAt;
|
||||
|
||||
@CreatedDate
|
||||
@Column(name = "created_at", updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@LastModifiedDate
|
||||
@Column(name = "updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@PrePersist
|
||||
public void prePersist() {
|
||||
if (this.status == null) {
|
||||
this.status = AppealStatus.PENDING;
|
||||
}
|
||||
if (this.createdAt == null) {
|
||||
this.createdAt = LocalDateTime.now();
|
||||
}
|
||||
this.updatedAt = LocalDateTime.now();
|
||||
}
|
||||
|
||||
@PreUpdate
|
||||
public void preUpdate() {
|
||||
this.updatedAt = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package ru.soune.nocopy.entity.file.moderation;
|
||||
|
||||
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.FileEntity;
|
||||
import ru.soune.nocopy.entity.file.FileStatus;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "moderation_logs")
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
public class ModerationLog {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
private String id;
|
||||
|
||||
@Column(name = "file_id", nullable = false)
|
||||
private String fileId;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "file_id", insertable = false, updatable = false)
|
||||
@ToString.Exclude
|
||||
private FileEntity file;
|
||||
|
||||
@Column(name = "moderator_id", nullable = false)
|
||||
private Long moderatorId;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "old_status", nullable = false)
|
||||
private FileStatus oldStatus;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "new_status", nullable = false)
|
||||
private FileStatus newStatus;
|
||||
|
||||
@Column(name = "reason", columnDefinition = "TEXT")
|
||||
private String reason;
|
||||
|
||||
@Column(name = "moderation_reason_id")
|
||||
private Long moderationReasonId;
|
||||
|
||||
@Column(name = "comment", columnDefinition = "TEXT")
|
||||
private String comment;
|
||||
|
||||
@CreatedDate
|
||||
@Column(name = "created_at", updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
Reference in New Issue
Block a user