change package,change message_code
Test Workflow / test (push) Waiting to run

This commit is contained in:
vladp
2025-12-10 19:12:54 +07:00
parent 76da2e94c9
commit a30b0488e8
60 changed files with 154 additions and 161 deletions
@@ -0,0 +1,48 @@
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 java.time.LocalDateTime;
@Entity
@Table(name = "auth_tokens")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@EntityListeners(AuditingEntityListener.class)
public class AuthToken {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long tokenId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
@ToString.Exclude
private User user;
@Column(nullable = false, unique = true, length = 64)
private String token;
@Column(name = "expires_at", nullable = false)
private LocalDateTime expiresAt = LocalDateTime.now().plusDays(30);
@CreatedDate
@Column(name = "created_at", updatable = false, nullable = false)
private LocalDateTime createdAt;
@Column(name = "last_used_at")
private LocalDateTime lastUsedAt;
@Column(name = "is_active")
private Boolean isActive = true;
public boolean isValid() {
return Boolean.TRUE.equals(isActive) && expiresAt.isAfter(LocalDateTime.now());
}
}
@@ -0,0 +1,29 @@
package ru.soune.nocopy.entity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.time.LocalDateTime;
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
@Getter
@Setter
public abstract class BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@CreatedDate
@Column(name = "created_at", updatable = false, nullable = false)
private LocalDateTime createdAt;
@LastModifiedDate
@Column(name = "updated_at")
private LocalDateTime updatedAt;
}
@@ -0,0 +1,20 @@
package ru.soune.nocopy.entity;
import lombok.Getter;
@Getter
public enum ContentStatus {
PROCESSING("processing"),
COMPLETED("completed"),
ERROR("error");
private final String code;
ContentStatus(String code) {
this.code = code;
}
public String getCode() {
return code;
}
}
@@ -0,0 +1,21 @@
package ru.soune.nocopy.entity;
import lombok.Getter;
@Getter
public enum FileType {
PHOTO("photo"),
VIDEO("video"),
AUDIO("audio"),
DOCUMENT("document");
private final String code;
FileType(String code) {
this.code = code;
}
public String getCode() {
return code;
}
}
@@ -0,0 +1,5 @@
package ru.soune.nocopy.entity;
public enum GenderType {
MALE, FEMALE
}
@@ -0,0 +1,49 @@
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 java.time.LocalDateTime;
@Entity
@Table(name = "image_protection")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@EntityListeners(AuditingEntityListener.class)
public class ImageProtection {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long protectionId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
@ToString.Exclude
private User user;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "content_id", nullable = false)
@ToString.Exclude
private UserContent content;
@Column(name = "protection_method", nullable = false, length = 50)
private String protectionMethod;
@Column(name = "protection_level", nullable = false)
private Integer protectionLevel;
@Column(name = "is_active", nullable = false)
private Boolean isActive = true;
@CreatedDate
@Column(name = "applied_at", nullable = false, updatable = false)
private LocalDateTime appliedAt;
@Column(name = "metadata", columnDefinition = "JSON")
private String metadata;
}
@@ -0,0 +1,8 @@
package ru.soune.nocopy.entity;
import lombok.Getter;
@Getter
public enum SubscriptionType {
START, BASIC, PRO, ENTERPRISE, DEMO;
}
@@ -0,0 +1,92 @@
package ru.soune.nocopy.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import jakarta.validation.constraints.Size;
import lombok.*;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "users")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@EntityListeners(AuditingEntityListener.class)
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long Id;
@Column(name = "full_name", nullable = false)
private String fullName;
@Size(max = 1024)
@Column(name = "email", nullable = false, length = 1024, unique = true)
private String email;
@Column(name = "company")
private String company;
@Column(nullable = false)
@Size(min = 6)
@JsonIgnore
private String password;
@Size(min = 11, max = 14)
private String phone;
@Enumerated(EnumType.STRING)
@Column(name = "subscription_type", nullable = false, length = 20)
private SubscriptionType subscriptionType = SubscriptionType.DEMO;
@Enumerated(EnumType.STRING)
@Column(name = "gender")
private GenderType genderType = GenderType.MALE;
@Column(name = "birthday")
private LocalDate birthday;
@CreatedDate
@Column(name = "created_at", updatable = false, nullable = false)
private LocalDateTime createdAt;
@Column(name = "last_login_at")
private LocalDateTime lastLoginAt;
@Column(name = "is_active")
private Boolean isActive = true;
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonIgnore
@ToString.Exclude
private List<AuthToken> tokens = new ArrayList<>();
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonIgnore
@ToString.Exclude
private List<UserContent> userContents = new ArrayList<>();
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonIgnore
@ToString.Exclude
private List<UserAction> userActions = new ArrayList<>();
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonIgnore
@ToString.Exclude
private List<Violation> violations = new ArrayList<>();
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonIgnore
@ToString.Exclude
private List<ImageProtection> imageProtections = new ArrayList<>();
}
@@ -0,0 +1,44 @@
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 java.time.LocalDateTime;
@Entity
@Table(name = "user_actions")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@EntityListeners(AuditingEntityListener.class)
public class UserAction {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long actionId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
@ToString.Exclude
private User user;
@Column(name = "action", nullable = false, length = 100)
private String action;
@Column(name = "details", columnDefinition = "TEXT")
private String details;
@Column(name = "ip_address", length = 45)
private String ipAddress;
@Column(name = "user_agent", columnDefinition = "TEXT")
private String userAgent;
@CreatedDate
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
}
@@ -0,0 +1,79 @@
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 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;
}
}
@@ -0,0 +1,56 @@
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 java.time.LocalDateTime;
@Entity
@Table(name = "violations")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@EntityListeners(AuditingEntityListener.class)
public class Violation {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long violationId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
@ToString.Exclude
private User user;
@Column(name = "violation_type", nullable = false, length = 50)
private String violationType;
@Column(name = "description", columnDefinition = "TEXT")
private String description;
@Column(name = "content_id")
private Long contentId;
@Column(name = "status", nullable = false, length = 20)
private String status = "new";
@Column(name = "severity", length = 20)
private String severity;
@Column(name = "resolved_at")
private LocalDateTime resolvedAt;
@Column(name = "resolved_by")
private Long resolvedBy;
@Column(name = "resolution_notes", columnDefinition = "TEXT")
private String resolutionNotes;
@CreatedDate
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
}