diff --git a/src/main/java/ru/soune/nocopy/entity/notification/Notification.java b/src/main/java/ru/soune/nocopy/entity/notification/Notification.java new file mode 100644 index 0000000..e15e349 --- /dev/null +++ b/src/main/java/ru/soune/nocopy/entity/notification/Notification.java @@ -0,0 +1,48 @@ +package ru.soune.nocopy.entity.notification; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import jakarta.persistence.*; +import lombok.*; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import ru.soune.nocopy.entity.user.User; + +import java.time.LocalDateTime; + +@Entity +@NoArgsConstructor +@AllArgsConstructor +@Getter @Setter +@Builder +@Table(name = "notifications", indexes = { + @Index(name = "idx_user_status", columnList = "user_id, status"), + @Index(name = "idx_user_created", columnList = "user_id, created_at DESC") +}) +public class Notification { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "created_at", updatable = false) + @CreatedDate + private LocalDateTime createdAt; + + @LastModifiedDate + @Column(name = "updated_at") + private LocalDateTime updatedAt; + + @Column(name = "message") + private String message; + + @Column(name = "notification_type") + private NotificationType notificationType; + + @Column(name = "status") + private NotificationStatus status = NotificationStatus.NEW; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + @JsonIgnore + private User user; +} diff --git a/src/main/java/ru/soune/nocopy/entity/notification/NotificationStatus.java b/src/main/java/ru/soune/nocopy/entity/notification/NotificationStatus.java new file mode 100644 index 0000000..5c3bb1c --- /dev/null +++ b/src/main/java/ru/soune/nocopy/entity/notification/NotificationStatus.java @@ -0,0 +1,5 @@ +package ru.soune.nocopy.entity.notification; + +public enum NotificationStatus { + NEW, READIED +} diff --git a/src/main/java/ru/soune/nocopy/entity/notification/NotificationType.java b/src/main/java/ru/soune/nocopy/entity/notification/NotificationType.java new file mode 100644 index 0000000..d8ad3ab --- /dev/null +++ b/src/main/java/ru/soune/nocopy/entity/notification/NotificationType.java @@ -0,0 +1,19 @@ +package ru.soune.nocopy.entity.notification; + +public enum NotificationType{ + SEARCH_RESULT, + MONITORING_RESULT, + OPERATION_IMPOSSIBLE, + START_FAILED_NOW, + START_FAILED_NEXT, + PAYOUT_RESULT, + REFERRAL_DEPOSIT, + REFERRAL_REGISTERED, + REFERRAL_ACTIVATED, + COMPLAINT_STATUS_CHANGED, + CASE_STATUS_CHANGED, + INCOMING_MESSAGE, + TARIFF_EXPIRING, + FILE_MODERATION_EVENT, + FILE_ADDED_TO_SYSTEM +}