mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-26 16:10:49 +08:00
fix: 后端代码格式化
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/** Generic activity entity. */
|
||||
@Entity
|
||||
@Getter
|
||||
@@ -17,34 +16,37 @@ import java.util.Set;
|
||||
@NoArgsConstructor
|
||||
@Table(name = "activities")
|
||||
public class Activity {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String icon;
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
|
||||
private String content;
|
||||
private String icon;
|
||||
|
||||
@Column(name = "start_time", nullable = false)
|
||||
@CreationTimestamp
|
||||
private LocalDateTime startTime;
|
||||
private String content;
|
||||
|
||||
@Column(name = "end_time")
|
||||
private LocalDateTime endTime;
|
||||
@Column(name = "start_time", nullable = false)
|
||||
@CreationTimestamp
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private ActivityType type = ActivityType.NORMAL;
|
||||
@Column(name = "end_time")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "activity_participants",
|
||||
joinColumns = @JoinColumn(name = "activity_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "user_id"))
|
||||
private Set<User> participants = new HashSet<>();
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private ActivityType type = ActivityType.NORMAL;
|
||||
|
||||
@Column(nullable = false)
|
||||
private boolean ended = false;
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "activity_participants",
|
||||
joinColumns = @JoinColumn(name = "activity_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "user_id")
|
||||
)
|
||||
private Set<User> participants = new HashSet<>();
|
||||
|
||||
@Column(nullable = false)
|
||||
private boolean ended = false;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.openisle.model;
|
||||
|
||||
/** Activity type enumeration. */
|
||||
public enum ActivityType {
|
||||
NORMAL,
|
||||
MILK_TEA,
|
||||
INVITE_POINTS
|
||||
NORMAL,
|
||||
MILK_TEA,
|
||||
INVITE_POINTS,
|
||||
}
|
||||
|
||||
@@ -1,31 +1,33 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/** Daily count of AI markdown formatting usage for a user. */
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "ai_format_usage",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = {"user_id", "use_date"}))
|
||||
@Table(
|
||||
name = "ai_format_usage",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "user_id", "use_date" })
|
||||
)
|
||||
public class AiFormatUsage {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "use_date", nullable = false)
|
||||
private LocalDate useDate;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@Column(nullable = false)
|
||||
private int count;
|
||||
@Column(name = "use_date", nullable = false)
|
||||
private LocalDate useDate;
|
||||
|
||||
@Column(nullable = false)
|
||||
private int count;
|
||||
}
|
||||
|
||||
@@ -11,19 +11,20 @@ import lombok.Setter;
|
||||
@NoArgsConstructor
|
||||
@Table(name = "categories")
|
||||
public class Category {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
private String name;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String icon;
|
||||
@Column(nullable = false, unique = true)
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
private String smallIcon;
|
||||
@Column(nullable = false)
|
||||
private String icon;
|
||||
|
||||
@Column(name = "description", nullable = false)
|
||||
private String description;
|
||||
@Column
|
||||
private String smallIcon;
|
||||
|
||||
@Column(name = "description", nullable = false)
|
||||
private String description;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@@ -8,8 +9,6 @@ import org.hibernate.annotations.CreationTimestamp;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -18,34 +17,37 @@ import java.time.LocalDateTime;
|
||||
@SQLDelete(sql = "UPDATE comments SET deleted_at = CURRENT_TIMESTAMP(6) WHERE id = ?")
|
||||
@Where(clause = "deleted_at IS NULL")
|
||||
public class Comment {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, columnDefinition = "TEXT")
|
||||
private String content;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false, updatable = false,
|
||||
columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6)")
|
||||
private LocalDateTime createdAt;
|
||||
@Column(nullable = false, columnDefinition = "TEXT")
|
||||
private String content;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "author_id")
|
||||
private User author;
|
||||
@CreationTimestamp
|
||||
@Column(
|
||||
nullable = false,
|
||||
updatable = false,
|
||||
columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6)"
|
||||
)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "author_id")
|
||||
private User author;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "parent_id")
|
||||
private Comment parent;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
|
||||
@Column
|
||||
private LocalDateTime pinnedAt;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "parent_id")
|
||||
private Comment parent;
|
||||
|
||||
@Column(name = "deleted_at")
|
||||
private LocalDateTime deletedAt;
|
||||
@Column
|
||||
private LocalDateTime pinnedAt;
|
||||
|
||||
@Column(name = "deleted_at")
|
||||
private LocalDateTime deletedAt;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package com.openisle.model;
|
||||
* Sort options for comments.
|
||||
*/
|
||||
public enum CommentSort {
|
||||
NEWEST,
|
||||
OLDEST,
|
||||
MOST_INTERACTIONS
|
||||
NEWEST,
|
||||
OLDEST,
|
||||
MOST_INTERACTIONS,
|
||||
}
|
||||
|
||||
@@ -10,18 +10,21 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "comment_subscriptions",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = {"user_id", "comment_id"}))
|
||||
@Table(
|
||||
name = "comment_subscriptions",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "user_id", "comment_id" })
|
||||
)
|
||||
public class CommentSubscription {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "comment_id")
|
||||
private Comment comment;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "comment_id")
|
||||
private Comment comment;
|
||||
}
|
||||
|
||||
@@ -11,17 +11,17 @@ import lombok.Setter;
|
||||
@NoArgsConstructor
|
||||
@Table(name = "contributor_configs")
|
||||
public class ContributorConfig {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
private String userIname;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
private String githubId;
|
||||
@Column(nullable = false, unique = true)
|
||||
private String userIname;
|
||||
|
||||
@Column(nullable = false)
|
||||
private long contributionLines = 0;
|
||||
@Column(nullable = false, unique = true)
|
||||
private String githubId;
|
||||
|
||||
@Column(nullable = false)
|
||||
private long contributionLines = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "drafts", uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = {"author_id"})
|
||||
})
|
||||
@Table(name = "drafts", uniqueConstraints = { @UniqueConstraint(columnNames = { "author_id" }) })
|
||||
public class Draft {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String title;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(columnDefinition = "LONGTEXT")
|
||||
private String content;
|
||||
private String title;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "author_id")
|
||||
private User author;
|
||||
@Column(columnDefinition = "LONGTEXT")
|
||||
private String content;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "category_id")
|
||||
private Category category;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "author_id")
|
||||
private User author;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "draft_tags",
|
||||
joinColumns = @JoinColumn(name = "draft_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "tag_id"))
|
||||
private Set<Tag> tags = new HashSet<>();
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "category_id")
|
||||
private Category category;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "draft_tags",
|
||||
joinColumns = @JoinColumn(name = "draft_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "tag_id")
|
||||
)
|
||||
private Set<Tag> tags = new HashSet<>();
|
||||
}
|
||||
|
||||
@@ -1,37 +1,39 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/** Daily experience gain counts for a user. */
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "experience_logs",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = {"user_id", "log_date"}))
|
||||
@Table(
|
||||
name = "experience_logs",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "user_id", "log_date" })
|
||||
)
|
||||
public class ExperienceLog {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "log_date", nullable = false)
|
||||
private LocalDate logDate;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@Column(name = "post_count", nullable = false)
|
||||
private int postCount;
|
||||
@Column(name = "log_date", nullable = false)
|
||||
private LocalDate logDate;
|
||||
|
||||
@Column(name = "comment_count", nullable = false)
|
||||
private int commentCount;
|
||||
@Column(name = "post_count", nullable = false)
|
||||
private int postCount;
|
||||
|
||||
@Column(name = "reaction_count", nullable = false)
|
||||
private int reactionCount;
|
||||
@Column(name = "comment_count", nullable = false)
|
||||
private int commentCount;
|
||||
|
||||
@Column(name = "reaction_count", nullable = false)
|
||||
private int reactionCount;
|
||||
}
|
||||
|
||||
@@ -14,13 +14,14 @@ import lombok.Setter;
|
||||
@NoArgsConstructor
|
||||
@Table(name = "images")
|
||||
public class Image {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, unique = true, length = 512)
|
||||
private String url;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private long refCount = 0;
|
||||
@Column(nullable = false, unique = true, length = 512)
|
||||
private String url;
|
||||
|
||||
@Column(nullable = false)
|
||||
private long refCount = 0;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Invite token entity tracking usage counts.
|
||||
@@ -11,20 +10,21 @@ import java.time.LocalDate;
|
||||
@Data
|
||||
@Entity
|
||||
public class InviteToken {
|
||||
@Id
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* Short token used in invite links. Existing records may have this field null
|
||||
* and fall back to {@link #token} for backward compatibility.
|
||||
*/
|
||||
@Column(unique = true)
|
||||
private String shortToken;
|
||||
@Id
|
||||
private String token;
|
||||
|
||||
@ManyToOne
|
||||
private User inviter;
|
||||
/**
|
||||
* Short token used in invite links. Existing records may have this field null
|
||||
* and fall back to {@link #token} for backward compatibility.
|
||||
*/
|
||||
@Column(unique = true)
|
||||
private String shortToken;
|
||||
|
||||
private LocalDate createdDate;
|
||||
@ManyToOne
|
||||
private User inviter;
|
||||
|
||||
private int usageCount;
|
||||
private LocalDate createdDate;
|
||||
|
||||
private int usageCount;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "lottery_posts")
|
||||
@@ -17,33 +16,37 @@ import java.util.Set;
|
||||
@PrimaryKeyJoinColumn(name = "post_id")
|
||||
public class LotteryPost extends Post {
|
||||
|
||||
@Column
|
||||
private String prizeDescription;
|
||||
@Column
|
||||
private String prizeDescription;
|
||||
|
||||
@Column
|
||||
private String prizeIcon;
|
||||
@Column
|
||||
private String prizeIcon;
|
||||
|
||||
@Column(nullable = false)
|
||||
private int prizeCount;
|
||||
@Column(nullable = false)
|
||||
private int prizeCount;
|
||||
|
||||
@Column(nullable = false)
|
||||
private int pointCost;
|
||||
@Column(nullable = false)
|
||||
private int pointCost;
|
||||
|
||||
@Column
|
||||
private LocalDateTime startTime;
|
||||
@Column
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Column
|
||||
private LocalDateTime endTime;
|
||||
@Column
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(name = "lottery_participants",
|
||||
joinColumns = @JoinColumn(name = "post_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "user_id"))
|
||||
private Set<User> participants = new HashSet<>();
|
||||
@ManyToMany
|
||||
@JoinTable(
|
||||
name = "lottery_participants",
|
||||
joinColumns = @JoinColumn(name = "post_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "user_id")
|
||||
)
|
||||
private Set<User> participants = new HashSet<>();
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(name = "lottery_winners",
|
||||
joinColumns = @JoinColumn(name = "post_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "user_id"))
|
||||
private Set<User> winners = new HashSet<>();
|
||||
@ManyToMany
|
||||
@JoinTable(
|
||||
name = "lottery_winners",
|
||||
joinColumns = @JoinColumn(name = "post_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "user_id")
|
||||
)
|
||||
private Set<User> winners = new HashSet<>();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.openisle.model;
|
||||
|
||||
public enum MedalType {
|
||||
COMMENT,
|
||||
POST,
|
||||
FEATURED,
|
||||
CONTRIBUTOR,
|
||||
SEED,
|
||||
PIONEER
|
||||
COMMENT,
|
||||
POST,
|
||||
FEATURED,
|
||||
CONTRIBUTOR,
|
||||
SEED,
|
||||
PIONEER,
|
||||
}
|
||||
|
||||
@@ -2,40 +2,40 @@ package com.openisle.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "messages")
|
||||
public class Message {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "conversation_id")
|
||||
@JsonBackReference
|
||||
private MessageConversation conversation;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "sender_id")
|
||||
private User sender;
|
||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "conversation_id")
|
||||
@JsonBackReference
|
||||
private MessageConversation conversation;
|
||||
|
||||
@Column(nullable = false, columnDefinition = "TEXT")
|
||||
private String content;
|
||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "sender_id")
|
||||
private User sender;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "reply_to_id")
|
||||
private Message replyTo;
|
||||
@Column(nullable = false, columnDefinition = "TEXT")
|
||||
private String content;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "reply_to_id")
|
||||
private Message replyTo;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
|
||||
@@ -3,50 +3,50 @@ package com.openisle.model;
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "message_conversations")
|
||||
public class MessageConversation {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
// Indicates whether this conversation represents a public channel
|
||||
@Column(nullable = false)
|
||||
private boolean channel = false;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
// Channel metadata
|
||||
private String name;
|
||||
// Indicates whether this conversation represents a public channel
|
||||
@Column(nullable = false)
|
||||
private boolean channel = false;
|
||||
|
||||
@Column(columnDefinition = "TEXT")
|
||||
private String description;
|
||||
// Channel metadata
|
||||
private String name;
|
||||
|
||||
private String avatar;
|
||||
@Column(columnDefinition = "TEXT")
|
||||
private String description;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
private String avatar;
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "last_message_id")
|
||||
private Message lastMessage;
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@OneToMany(mappedBy = "conversation", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JsonBackReference
|
||||
private Set<MessageParticipant> participants = new HashSet<>();
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "last_message_id")
|
||||
private Message lastMessage;
|
||||
|
||||
@OneToMany(mappedBy = "conversation", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JsonBackReference
|
||||
private Set<Message> messages = new HashSet<>();
|
||||
}
|
||||
@OneToMany(mappedBy = "conversation", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JsonBackReference
|
||||
private Set<MessageParticipant> participants = new HashSet<>();
|
||||
|
||||
@OneToMany(mappedBy = "conversation", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JsonBackReference
|
||||
private Set<Message> messages = new HashSet<>();
|
||||
}
|
||||
|
||||
@@ -2,31 +2,31 @@ package com.openisle.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "message_participants")
|
||||
public class MessageParticipant {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "conversation_id")
|
||||
@JsonBackReference
|
||||
private MessageConversation conversation;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "conversation_id")
|
||||
@JsonBackReference
|
||||
private MessageConversation conversation;
|
||||
|
||||
@Column
|
||||
private LocalDateTime lastReadAt;
|
||||
}
|
||||
@ManyToOne(optional = false, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@Column
|
||||
private LocalDateTime lastReadAt;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* Entity representing a user notification.
|
||||
*/
|
||||
@@ -17,45 +16,49 @@ import java.time.LocalDateTime;
|
||||
@NoArgsConstructor
|
||||
@Table(name = "notifications")
|
||||
public class Notification {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false, length = 50)
|
||||
private NotificationType type;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false, length = 50)
|
||||
private NotificationType type;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "comment_id")
|
||||
private Comment comment;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "from_user_id")
|
||||
private User fromUser;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "comment_id")
|
||||
private Comment comment;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "reaction_type")
|
||||
private ReactionType reactionType;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "from_user_id")
|
||||
private User fromUser;
|
||||
|
||||
@Column(length = 1000)
|
||||
private String content;
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "reaction_type")
|
||||
private ReactionType reactionType;
|
||||
|
||||
@Column
|
||||
private Boolean approved;
|
||||
@Column(length = 1000)
|
||||
private String content;
|
||||
|
||||
@Column(name = "is_read", nullable = false)
|
||||
private boolean read = false;
|
||||
@Column
|
||||
private Boolean approved;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false, updatable = false,
|
||||
columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6)")
|
||||
private LocalDateTime createdAt;
|
||||
@Column(name = "is_read", nullable = false)
|
||||
private boolean read = false;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(
|
||||
nullable = false,
|
||||
updatable = false,
|
||||
columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6)"
|
||||
)
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
|
||||
@@ -4,50 +4,50 @@ 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,
|
||||
/** A new post is waiting for review */
|
||||
POST_REVIEW_REQUEST,
|
||||
/** Your post under review was approved or rejected */
|
||||
POST_REVIEWED,
|
||||
/** An administrator deleted your post */
|
||||
POST_DELETED,
|
||||
/** A subscribed post received a new comment */
|
||||
POST_UPDATED,
|
||||
/** Someone subscribed to your post */
|
||||
POST_SUBSCRIBED,
|
||||
/** Someone unsubscribed from your post */
|
||||
POST_UNSUBSCRIBED,
|
||||
/** Someone you follow published a new post */
|
||||
FOLLOWED_POST,
|
||||
/** Someone started following you */
|
||||
USER_FOLLOWED,
|
||||
/** Someone unfollowed you */
|
||||
USER_UNFOLLOWED,
|
||||
/** A user you subscribe to created a post or comment */
|
||||
USER_ACTIVITY,
|
||||
/** A user requested registration approval */
|
||||
REGISTER_REQUEST,
|
||||
/** A user redeemed an activity reward */
|
||||
ACTIVITY_REDEEM,
|
||||
/** A user redeemed a point good */
|
||||
POINT_REDEEM,
|
||||
/** You won a lottery post */
|
||||
LOTTERY_WIN,
|
||||
/** Your lottery post was drawn */
|
||||
LOTTERY_DRAW,
|
||||
/** Someone participated in your poll */
|
||||
POLL_VOTE,
|
||||
/** Your poll post has concluded */
|
||||
POLL_RESULT_OWNER,
|
||||
/** A poll you participated in has concluded */
|
||||
POLL_RESULT_PARTICIPANT,
|
||||
/** Your post was featured */
|
||||
POST_FEATURED,
|
||||
/** You were mentioned in a post or comment */
|
||||
MENTION
|
||||
/** Someone viewed your post */
|
||||
POST_VIEWED,
|
||||
/** Someone replied to your post or comment */
|
||||
COMMENT_REPLY,
|
||||
/** Someone reacted to your post or comment */
|
||||
REACTION,
|
||||
/** A new post is waiting for review */
|
||||
POST_REVIEW_REQUEST,
|
||||
/** Your post under review was approved or rejected */
|
||||
POST_REVIEWED,
|
||||
/** An administrator deleted your post */
|
||||
POST_DELETED,
|
||||
/** A subscribed post received a new comment */
|
||||
POST_UPDATED,
|
||||
/** Someone subscribed to your post */
|
||||
POST_SUBSCRIBED,
|
||||
/** Someone unsubscribed from your post */
|
||||
POST_UNSUBSCRIBED,
|
||||
/** Someone you follow published a new post */
|
||||
FOLLOWED_POST,
|
||||
/** Someone started following you */
|
||||
USER_FOLLOWED,
|
||||
/** Someone unfollowed you */
|
||||
USER_UNFOLLOWED,
|
||||
/** A user you subscribe to created a post or comment */
|
||||
USER_ACTIVITY,
|
||||
/** A user requested registration approval */
|
||||
REGISTER_REQUEST,
|
||||
/** A user redeemed an activity reward */
|
||||
ACTIVITY_REDEEM,
|
||||
/** A user redeemed a point good */
|
||||
POINT_REDEEM,
|
||||
/** You won a lottery post */
|
||||
LOTTERY_WIN,
|
||||
/** Your lottery post was drawn */
|
||||
LOTTERY_DRAW,
|
||||
/** Someone participated in your poll */
|
||||
POLL_VOTE,
|
||||
/** Your poll post has concluded */
|
||||
POLL_RESULT_OWNER,
|
||||
/** A poll you participated in has concluded */
|
||||
POLL_RESULT_PARTICIPANT,
|
||||
/** Your post was featured */
|
||||
POST_FEATURED,
|
||||
/** You were mentioned in a post or comment */
|
||||
MENTION,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.openisle.model;
|
||||
|
||||
public enum PasswordStrength {
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH,
|
||||
}
|
||||
|
||||
@@ -12,15 +12,16 @@ import lombok.Setter;
|
||||
@NoArgsConstructor
|
||||
@Table(name = "point_goods")
|
||||
public class PointGood {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String name;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private int cost;
|
||||
@Column(nullable = false)
|
||||
private String name;
|
||||
|
||||
private String image;
|
||||
@Column(nullable = false)
|
||||
private int cost;
|
||||
|
||||
private String image;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/** Point change history for a user. */
|
||||
@Entity
|
||||
@Getter
|
||||
@@ -18,39 +17,40 @@ import java.time.LocalDateTime;
|
||||
@SQLDelete(sql = "UPDATE point_histories SET deleted_at = CURRENT_TIMESTAMP(6) WHERE id = ?")
|
||||
@Where(clause = "deleted_at IS NULL")
|
||||
public class PointHistory {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private PointHistoryType type;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@Column(nullable = false)
|
||||
private int amount;
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private PointHistoryType type;
|
||||
|
||||
@Column(nullable = false)
|
||||
private int balance;
|
||||
@Column(nullable = false)
|
||||
private int amount;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
@Column(nullable = false)
|
||||
private int balance;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "comment_id")
|
||||
private Comment comment;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "from_user_id")
|
||||
private User fromUser;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "comment_id")
|
||||
private Comment comment;
|
||||
|
||||
@Column(name = "created_at", nullable = false)
|
||||
private LocalDateTime createdAt;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "from_user_id")
|
||||
private User fromUser;
|
||||
|
||||
@Column(name = "deleted_at")
|
||||
private LocalDateTime deletedAt;
|
||||
@Column(name = "created_at", nullable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column(name = "deleted_at")
|
||||
private LocalDateTime deletedAt;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.openisle.model;
|
||||
|
||||
public enum PointHistoryType {
|
||||
POST,
|
||||
COMMENT,
|
||||
POST_LIKED,
|
||||
COMMENT_LIKED,
|
||||
POST_LIKE_CANCELLED,
|
||||
COMMENT_LIKE_CANCELLED,
|
||||
INVITE,
|
||||
FEATURE,
|
||||
SYSTEM_ONLINE,
|
||||
REDEEM,
|
||||
LOTTERY_JOIN,
|
||||
LOTTERY_REWARD
|
||||
POST,
|
||||
COMMENT,
|
||||
POST_LIKED,
|
||||
COMMENT_LIKED,
|
||||
POST_LIKE_CANCELLED,
|
||||
COMMENT_LIKE_CANCELLED,
|
||||
INVITE,
|
||||
FEATURE,
|
||||
SYSTEM_ONLINE,
|
||||
REDEEM,
|
||||
LOTTERY_JOIN,
|
||||
LOTTERY_REWARD,
|
||||
}
|
||||
|
||||
@@ -1,37 +1,39 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/** Daily experience gain counts for a user. */
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "point_logs",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = {"user_id", "log_date"}))
|
||||
@Table(
|
||||
name = "point_logs",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "user_id", "log_date" })
|
||||
)
|
||||
public class PointLog {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "log_date", nullable = false)
|
||||
private LocalDate logDate;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@Column(name = "post_count", nullable = false)
|
||||
private int postCount;
|
||||
@Column(name = "log_date", nullable = false)
|
||||
private LocalDate logDate;
|
||||
|
||||
@Column(name = "comment_count", nullable = false)
|
||||
private int commentCount;
|
||||
@Column(name = "post_count", nullable = false)
|
||||
private int postCount;
|
||||
|
||||
@Column(name = "reaction_count", nullable = false)
|
||||
private int reactionCount;
|
||||
@Column(name = "comment_count", nullable = false)
|
||||
private int commentCount;
|
||||
|
||||
@Column(name = "reaction_count", nullable = false)
|
||||
private int reactionCount;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "poll_posts")
|
||||
@Getter
|
||||
@@ -15,29 +14,32 @@ import java.util.*;
|
||||
@NoArgsConstructor
|
||||
@PrimaryKeyJoinColumn(name = "post_id")
|
||||
public class PollPost extends Post {
|
||||
@ElementCollection
|
||||
@CollectionTable(name = "poll_post_options", joinColumns = @JoinColumn(name = "post_id"))
|
||||
@Column(name = "option_text")
|
||||
private List<String> options = new ArrayList<>();
|
||||
|
||||
@ElementCollection
|
||||
@CollectionTable(name = "poll_post_votes", joinColumns = @JoinColumn(name = "post_id"))
|
||||
@MapKeyColumn(name = "option_index")
|
||||
@Column(name = "vote_count")
|
||||
private Map<Integer, Integer> votes = new HashMap<>();
|
||||
@ElementCollection
|
||||
@CollectionTable(name = "poll_post_options", joinColumns = @JoinColumn(name = "post_id"))
|
||||
@Column(name = "option_text")
|
||||
private List<String> options = new ArrayList<>();
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(name = "poll_participants",
|
||||
joinColumns = @JoinColumn(name = "post_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "user_id"))
|
||||
private Set<User> participants = new HashSet<>();
|
||||
@ElementCollection
|
||||
@CollectionTable(name = "poll_post_votes", joinColumns = @JoinColumn(name = "post_id"))
|
||||
@MapKeyColumn(name = "option_index")
|
||||
@Column(name = "vote_count")
|
||||
private Map<Integer, Integer> votes = new HashMap<>();
|
||||
|
||||
@Column
|
||||
private Boolean multiple = false;
|
||||
@ManyToMany
|
||||
@JoinTable(
|
||||
name = "poll_participants",
|
||||
joinColumns = @JoinColumn(name = "post_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "user_id")
|
||||
)
|
||||
private Set<User> participants = new HashSet<>();
|
||||
|
||||
@Column
|
||||
private LocalDateTime endTime;
|
||||
@Column
|
||||
private Boolean multiple = false;
|
||||
|
||||
@Column
|
||||
private boolean resultAnnounced = false;
|
||||
@Column
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Column
|
||||
private boolean resultAnnounced = false;
|
||||
}
|
||||
|
||||
@@ -6,23 +6,27 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "poll_votes", uniqueConstraints = @UniqueConstraint(columnNames = {"post_id", "user_id", "option_index"}))
|
||||
@Table(
|
||||
name = "poll_votes",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "post_id", "user_id", "option_index" })
|
||||
)
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class PollVote {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "post_id")
|
||||
private PollPost post;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "post_id")
|
||||
private PollPost post;
|
||||
|
||||
@Column(name = "option_index", nullable = false)
|
||||
private int optionIndex;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@Column(name = "option_index", nullable = false)
|
||||
private int optionIndex;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import com.openisle.model.Tag;
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.openisle.model.Tag;
|
||||
|
||||
|
||||
/**
|
||||
* Post entity representing an article posted by a user.
|
||||
*/
|
||||
@@ -24,58 +20,64 @@ import com.openisle.model.Tag;
|
||||
@Table(name = "posts")
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
public class Post {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, columnDefinition = "LONGTEXT")
|
||||
private String content;
|
||||
@Column(nullable = false)
|
||||
private String title;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false, updatable = false,
|
||||
columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6)")
|
||||
private LocalDateTime createdAt;
|
||||
@Column(nullable = false, columnDefinition = "LONGTEXT")
|
||||
private String content;
|
||||
|
||||
@ManyToOne(optional = false, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "author_id")
|
||||
private User author;
|
||||
@CreationTimestamp
|
||||
@Column(
|
||||
nullable = false,
|
||||
updatable = false,
|
||||
columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6)"
|
||||
)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@ManyToOne(optional = false, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "category_id")
|
||||
private Category category;
|
||||
@ManyToOne(optional = false, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "author_id")
|
||||
private User author;
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "post_tags",
|
||||
joinColumns = @JoinColumn(name = "post_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "tag_id"))
|
||||
private Set<Tag> tags = new HashSet<>();
|
||||
@ManyToOne(optional = false, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "category_id")
|
||||
private Category category;
|
||||
|
||||
@Column(nullable = false)
|
||||
private long views = 0;
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(
|
||||
name = "post_tags",
|
||||
joinColumns = @JoinColumn(name = "post_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "tag_id")
|
||||
)
|
||||
private Set<Tag> tags = new HashSet<>();
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private PostStatus status = PostStatus.PUBLISHED;
|
||||
@Column(nullable = false)
|
||||
private long views = 0;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private PostType type = PostType.NORMAL;
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private PostStatus status = PostStatus.PUBLISHED;
|
||||
|
||||
@Column(nullable = false)
|
||||
private boolean closed = false;
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private PostType type = PostType.NORMAL;
|
||||
|
||||
@Column
|
||||
private LocalDateTime pinnedAt;
|
||||
@Column(nullable = false)
|
||||
private boolean closed = false;
|
||||
|
||||
@Column(nullable = true)
|
||||
private Boolean rssExcluded = true;
|
||||
@Column
|
||||
private LocalDateTime pinnedAt;
|
||||
|
||||
@Column(nullable = false)
|
||||
private long commentCount = 0;
|
||||
@Column(nullable = true)
|
||||
private Boolean rssExcluded = true;
|
||||
|
||||
@Column(nullable = true)
|
||||
private LocalDateTime lastReplyAt;
|
||||
@Column(nullable = false)
|
||||
private long commentCount = 0;
|
||||
|
||||
@Column(nullable = true)
|
||||
private LocalDateTime lastReplyAt;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import lombok.Setter;
|
||||
@Entity
|
||||
@Table(name = "post_category_change_logs")
|
||||
public class PostCategoryChangeLog extends PostChangeLog {
|
||||
private String oldCategory;
|
||||
private String newCategory;
|
||||
|
||||
private String oldCategory;
|
||||
private String newCategory;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@@ -15,23 +14,24 @@ import java.time.LocalDateTime;
|
||||
@Table(name = "post_change_logs")
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
public abstract class PostChangeLog {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = true)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = true)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private PostChangeType type;
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private PostChangeType type;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.openisle.model;
|
||||
|
||||
public enum PostChangeType {
|
||||
CONTENT,
|
||||
TITLE,
|
||||
CATEGORY,
|
||||
TAG,
|
||||
CLOSED,
|
||||
PINNED,
|
||||
FEATURED,
|
||||
VOTE_RESULT,
|
||||
LOTTERY_RESULT
|
||||
CONTENT,
|
||||
TITLE,
|
||||
CATEGORY,
|
||||
TAG,
|
||||
CLOSED,
|
||||
PINNED,
|
||||
FEATURED,
|
||||
VOTE_RESULT,
|
||||
LOTTERY_RESULT,
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import lombok.Setter;
|
||||
@Entity
|
||||
@Table(name = "post_closed_change_logs")
|
||||
public class PostClosedChangeLog extends PostChangeLog {
|
||||
private boolean oldClosed;
|
||||
private boolean newClosed;
|
||||
|
||||
private boolean oldClosed;
|
||||
private boolean newClosed;
|
||||
}
|
||||
|
||||
@@ -13,9 +13,10 @@ import lombok.Setter;
|
||||
@Entity
|
||||
@Table(name = "post_content_change_logs")
|
||||
public class PostContentChangeLog extends PostChangeLog {
|
||||
@Column(name = "old_content", columnDefinition = "LONGTEXT")
|
||||
private String oldContent;
|
||||
|
||||
@Column(name = "new_content", columnDefinition = "LONGTEXT")
|
||||
private String newContent;
|
||||
@Column(name = "old_content", columnDefinition = "LONGTEXT")
|
||||
private String oldContent;
|
||||
|
||||
@Column(name = "new_content", columnDefinition = "LONGTEXT")
|
||||
private String newContent;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import lombok.Setter;
|
||||
@Entity
|
||||
@Table(name = "post_featured_change_logs")
|
||||
public class PostFeaturedChangeLog extends PostChangeLog {
|
||||
private boolean oldFeatured;
|
||||
private boolean newFeatured;
|
||||
|
||||
private boolean oldFeatured;
|
||||
private boolean newFeatured;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,4 @@ import lombok.Setter;
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "post_lottery_result_change_logs")
|
||||
public class PostLotteryResultChangeLog extends PostChangeLog {
|
||||
}
|
||||
|
||||
public class PostLotteryResultChangeLog extends PostChangeLog {}
|
||||
|
||||
@@ -2,18 +2,18 @@ package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "post_pinned_change_logs")
|
||||
public class PostPinnedChangeLog extends PostChangeLog {
|
||||
private LocalDateTime oldPinnedAt;
|
||||
private LocalDateTime newPinnedAt;
|
||||
|
||||
private LocalDateTime oldPinnedAt;
|
||||
private LocalDateTime newPinnedAt;
|
||||
}
|
||||
|
||||
@@ -1,32 +1,34 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/** Record of a user reading a post. */
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "post_reads",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = {"user_id", "post_id"}))
|
||||
@Table(
|
||||
name = "post_reads",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "user_id", "post_id" })
|
||||
)
|
||||
public class PostRead {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@Column(name = "last_read_at")
|
||||
private LocalDateTime lastReadAt;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
|
||||
@Column(name = "last_read_at")
|
||||
private LocalDateTime lastReadAt;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package com.openisle.model;
|
||||
* Status of a post during its lifecycle.
|
||||
*/
|
||||
public enum PostStatus {
|
||||
PUBLISHED,
|
||||
PENDING,
|
||||
REJECTED
|
||||
PUBLISHED,
|
||||
PENDING,
|
||||
REJECTED,
|
||||
}
|
||||
|
||||
@@ -10,18 +10,21 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "post_subscriptions",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = {"user_id", "post_id"}))
|
||||
@Table(
|
||||
name = "post_subscriptions",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "user_id", "post_id" })
|
||||
)
|
||||
public class PostSubscription {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
}
|
||||
|
||||
@@ -13,9 +13,10 @@ import lombok.Setter;
|
||||
@Entity
|
||||
@Table(name = "post_tag_change_logs")
|
||||
public class PostTagChangeLog extends PostChangeLog {
|
||||
@Column(name = "old_tags")
|
||||
private String oldTags;
|
||||
|
||||
@Column(name = "new_tags")
|
||||
private String newTags;
|
||||
@Column(name = "old_tags")
|
||||
private String oldTags;
|
||||
|
||||
@Column(name = "new_tags")
|
||||
private String newTags;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import lombok.Setter;
|
||||
@Entity
|
||||
@Table(name = "post_title_change_logs")
|
||||
public class PostTitleChangeLog extends PostChangeLog {
|
||||
private String oldTitle;
|
||||
private String newTitle;
|
||||
|
||||
private String oldTitle;
|
||||
private String newTitle;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.openisle.model;
|
||||
|
||||
public enum PostType {
|
||||
NORMAL,
|
||||
LOTTERY,
|
||||
POLL
|
||||
NORMAL,
|
||||
LOTTERY,
|
||||
POLL,
|
||||
}
|
||||
|
||||
@@ -11,6 +11,4 @@ import lombok.Setter;
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "post_vote_result_change_logs")
|
||||
public class PostVoteResultChangeLog extends PostChangeLog {
|
||||
}
|
||||
|
||||
public class PostVoteResultChangeLog extends PostChangeLog {}
|
||||
|
||||
@@ -4,6 +4,6 @@ package com.openisle.model;
|
||||
* Application-wide article publish mode.
|
||||
*/
|
||||
public enum PublishMode {
|
||||
DIRECT,
|
||||
REVIEW
|
||||
DIRECT,
|
||||
REVIEW,
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* Entity storing a browser push subscription for a user.
|
||||
*/
|
||||
@@ -17,24 +16,25 @@ import java.time.LocalDateTime;
|
||||
@NoArgsConstructor
|
||||
@Table(name = "push_subscriptions")
|
||||
public class PushSubscription {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, length = 512)
|
||||
private String endpoint;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@Column(nullable = false, length = 256)
|
||||
private String p256dh;
|
||||
@Column(nullable = false, length = 512)
|
||||
private String endpoint;
|
||||
|
||||
@Column(nullable = false, length = 256)
|
||||
private String auth;
|
||||
@Column(nullable = false, length = 256)
|
||||
private String p256dh;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
@Column(nullable = false, length = 256)
|
||||
private String auth;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
|
||||
@@ -13,39 +13,45 @@ import org.hibernate.annotations.CreationTimestamp;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "reactions",
|
||||
uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = {"user_id", "post_id", "type"}),
|
||||
@UniqueConstraint(columnNames = {"user_id", "comment_id", "type"}),
|
||||
@UniqueConstraint(columnNames = {"user_id", "message_id", "type"})
|
||||
})
|
||||
@Table(
|
||||
name = "reactions",
|
||||
uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "user_id", "post_id", "type" }),
|
||||
@UniqueConstraint(columnNames = { "user_id", "comment_id", "type" }),
|
||||
@UniqueConstraint(columnNames = { "user_id", "message_id", "type" }),
|
||||
}
|
||||
)
|
||||
public class Reaction {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private ReactionType type;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private ReactionType type;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "comment_id")
|
||||
private Comment comment;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "post_id")
|
||||
private Post post;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "message_id")
|
||||
private Message message;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "comment_id")
|
||||
private Comment comment;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false, updatable = false,
|
||||
columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6)")
|
||||
private java.time.LocalDateTime createdAt;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "message_id")
|
||||
private Message message;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(
|
||||
nullable = false,
|
||||
updatable = false,
|
||||
columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6)"
|
||||
)
|
||||
private java.time.LocalDateTime createdAt;
|
||||
}
|
||||
|
||||
@@ -4,29 +4,29 @@ package com.openisle.model;
|
||||
* Enum of possible reaction types for posts and comments.
|
||||
*/
|
||||
public enum ReactionType {
|
||||
LIKE,
|
||||
DISLIKE,
|
||||
SMILE,
|
||||
RECOMMEND,
|
||||
CONGRATULATIONS,
|
||||
ANGRY,
|
||||
FLUSHED,
|
||||
STAR_STRUCK,
|
||||
ROFL,
|
||||
HOLDING_BACK_TEARS,
|
||||
MIND_BLOWN,
|
||||
POOP,
|
||||
CLOWN,
|
||||
SKULL,
|
||||
FIRE,
|
||||
EYES,
|
||||
FROWN,
|
||||
HOT,
|
||||
EAGLE,
|
||||
SPIDER,
|
||||
BAT,
|
||||
CHINA,
|
||||
USA,
|
||||
JAPAN,
|
||||
KOREA,
|
||||
LIKE,
|
||||
DISLIKE,
|
||||
SMILE,
|
||||
RECOMMEND,
|
||||
CONGRATULATIONS,
|
||||
ANGRY,
|
||||
FLUSHED,
|
||||
STAR_STRUCK,
|
||||
ROFL,
|
||||
HOLDING_BACK_TEARS,
|
||||
MIND_BLOWN,
|
||||
POOP,
|
||||
CLOWN,
|
||||
SKULL,
|
||||
FIRE,
|
||||
EYES,
|
||||
FROWN,
|
||||
HOT,
|
||||
EAGLE,
|
||||
SPIDER,
|
||||
BAT,
|
||||
CHINA,
|
||||
USA,
|
||||
JAPAN,
|
||||
KOREA,
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ package com.openisle.model;
|
||||
* Application-wide user registration mode.
|
||||
*/
|
||||
public enum RegisterMode {
|
||||
DIRECT,
|
||||
WHITELIST
|
||||
DIRECT,
|
||||
WHITELIST,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.openisle.model;
|
||||
|
||||
public enum Role {
|
||||
ADMIN,
|
||||
USER
|
||||
ADMIN,
|
||||
USER,
|
||||
}
|
||||
|
||||
@@ -1,45 +1,48 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "tags")
|
||||
public class Tag {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
private String name;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column
|
||||
private String icon;
|
||||
@Column(nullable = false, unique = true)
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
private String smallIcon;
|
||||
@Column
|
||||
private String icon;
|
||||
|
||||
@Column(name = "description", nullable = false)
|
||||
private String description;
|
||||
@Column
|
||||
private String smallIcon;
|
||||
|
||||
@Column(nullable = false)
|
||||
private boolean approved = true;
|
||||
@Column(name = "description", nullable = false)
|
||||
private String description;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false, updatable = false,
|
||||
columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6)")
|
||||
private LocalDateTime createdAt;
|
||||
// 改用redis缓存之后选择立即加载策略
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "creator_id")
|
||||
private User creator;
|
||||
@Column(nullable = false)
|
||||
private boolean approved = true;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(
|
||||
nullable = false,
|
||||
updatable = false,
|
||||
columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6)"
|
||||
)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
// 改用redis缓存之后选择立即加载策略
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "creator_id")
|
||||
private User creator;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
/**
|
||||
* Simple user entity with basic fields and a role.
|
||||
@@ -21,67 +20,79 @@ import java.util.Set;
|
||||
@NoArgsConstructor
|
||||
@Table(name = "users")
|
||||
public class User {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
private String username;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
private String email;
|
||||
@Column(nullable = false, unique = true)
|
||||
private String username;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String password;
|
||||
@Column(nullable = false, unique = true)
|
||||
private String email;
|
||||
|
||||
@Column(nullable = false)
|
||||
private boolean verified = false;
|
||||
@Column(nullable = false)
|
||||
private String password;
|
||||
|
||||
private String verificationCode;
|
||||
@Column(nullable = false)
|
||||
private boolean verified = false;
|
||||
|
||||
private String passwordResetCode;
|
||||
private String verificationCode;
|
||||
|
||||
private String avatar;
|
||||
private String passwordResetCode;
|
||||
|
||||
@Column(nullable = false)
|
||||
private int experience = 0;
|
||||
private String avatar;
|
||||
|
||||
@Column(nullable = false)
|
||||
private int point = 0;
|
||||
@Column(nullable = false)
|
||||
private int experience = 0;
|
||||
|
||||
@Column(length = 1000)
|
||||
private String introduction;
|
||||
@Column(nullable = false)
|
||||
private int point = 0;
|
||||
|
||||
@Column(length = 1000)
|
||||
private String registerReason;
|
||||
@Column(length = 1000)
|
||||
private String introduction;
|
||||
|
||||
@Column(nullable = false)
|
||||
private boolean approved = true;
|
||||
@Column(length = 1000)
|
||||
private String registerReason;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private Role role = Role.USER;
|
||||
@Column(nullable = false)
|
||||
private boolean approved = true;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private MedalType displayMedal;
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private Role role = Role.USER;
|
||||
|
||||
@ElementCollection(targetClass = NotificationType.class)
|
||||
@CollectionTable(name = "user_disabled_notification_types", joinColumns = @JoinColumn(name = "user_id"))
|
||||
@Column(name = "notification_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Set<NotificationType> disabledNotificationTypes = EnumSet.of(
|
||||
NotificationType.POST_VIEWED,
|
||||
NotificationType.USER_ACTIVITY
|
||||
);
|
||||
@Enumerated(EnumType.STRING)
|
||||
private MedalType displayMedal;
|
||||
|
||||
@ElementCollection(targetClass = NotificationType.class)
|
||||
@CollectionTable(name = "user_disabled_email_notification_types", joinColumns = @JoinColumn(name = "user_id"))
|
||||
@Column(name = "notification_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Set<NotificationType> disabledEmailNotificationTypes = EnumSet.noneOf(NotificationType.class);
|
||||
@ElementCollection(targetClass = NotificationType.class)
|
||||
@CollectionTable(
|
||||
name = "user_disabled_notification_types",
|
||||
joinColumns = @JoinColumn(name = "user_id")
|
||||
)
|
||||
@Column(name = "notification_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Set<NotificationType> disabledNotificationTypes = EnumSet.of(
|
||||
NotificationType.POST_VIEWED,
|
||||
NotificationType.USER_ACTIVITY
|
||||
);
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false, updatable = false,
|
||||
columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6)")
|
||||
private LocalDateTime createdAt;
|
||||
@ElementCollection(targetClass = NotificationType.class)
|
||||
@CollectionTable(
|
||||
name = "user_disabled_email_notification_types",
|
||||
joinColumns = @JoinColumn(name = "user_id")
|
||||
)
|
||||
@Column(name = "notification_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Set<NotificationType> disabledEmailNotificationTypes = EnumSet.noneOf(
|
||||
NotificationType.class
|
||||
);
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(
|
||||
nullable = false,
|
||||
updatable = false,
|
||||
columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6)"
|
||||
)
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
|
||||
@@ -10,18 +10,21 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "user_subscriptions",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = {"subscriber_id", "target_id"}))
|
||||
@Table(
|
||||
name = "user_subscriptions",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "subscriber_id", "target_id" })
|
||||
)
|
||||
public class UserSubscription {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "subscriber_id")
|
||||
private User subscriber;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "target_id")
|
||||
private User target;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "subscriber_id")
|
||||
private User subscriber;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "target_id")
|
||||
private User target;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,30 @@
|
||||
package com.openisle.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/** Daily visit record for a user. */
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "user_visits",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = {"user_id", "visit_date"}))
|
||||
@Table(
|
||||
name = "user_visits",
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "user_id", "visit_date" })
|
||||
)
|
||||
public class UserVisit {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "visit_date", nullable = false)
|
||||
private LocalDate visitDate;
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@Column(name = "visit_date", nullable = false)
|
||||
private LocalDate visitDate;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user