mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-24 07:00:49 +08:00
feat: add notification system
This commit is contained in:
52
src/main/java/com/openisle/model/Notification.java
Normal file
52
src/main/java/com/openisle/model/Notification.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* Entity representing a user notification.
|
||||
*/
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "notifications")
|
||||
public class Notification {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private NotificationType type;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "comment_id")
|
||||
private Comment comment;
|
||||
|
||||
@Column
|
||||
private Boolean approved;
|
||||
|
||||
@Column(nullable = false)
|
||||
private boolean read = false;
|
||||
|
||||
@Column(nullable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@PrePersist
|
||||
protected void onCreate() {
|
||||
this.createdAt = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
15
src/main/java/com/openisle/model/NotificationType.java
Normal file
15
src/main/java/com/openisle/model/NotificationType.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.openisle.model;
|
||||
|
||||
/**
|
||||
* Types of user notifications.
|
||||
*/
|
||||
public enum NotificationType {
|
||||
/** Someone viewed your post */
|
||||
POST_VIEWED,
|
||||
/** Someone replied to your post or comment */
|
||||
COMMENT_REPLY,
|
||||
/** Someone reacted to your post or comment */
|
||||
REACTION,
|
||||
/** Your post under review was approved or rejected */
|
||||
POST_REVIEWED
|
||||
}
|
||||
@@ -5,5 +5,6 @@ package com.openisle.model;
|
||||
*/
|
||||
public enum PostStatus {
|
||||
PUBLISHED,
|
||||
PENDING
|
||||
PENDING,
|
||||
REJECTED
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user