diff options
Diffstat (limited to 'src/main/java/com/juick/data/entities')
11 files changed, 612 insertions, 0 deletions
diff --git a/src/main/java/com/juick/data/entities/BaseMessagePropertyEntity.java b/src/main/java/com/juick/data/entities/BaseMessagePropertyEntity.java new file mode 100644 index 00000000..90c26dbb --- /dev/null +++ b/src/main/java/com/juick/data/entities/BaseMessagePropertyEntity.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@MappedSuperclass +public class BaseMessagePropertyEntity { + @ManyToOne + @JoinColumn(name = "message_id") + private MessageEntity message; + public MessageEntity getMessage() { + return message; + } + + public void setMessage(MessageEntity message) { + this.message = message; + } +} diff --git a/src/main/java/com/juick/data/entities/BaseUserPropertyEntity.java b/src/main/java/com/juick/data/entities/BaseUserPropertyEntity.java new file mode 100644 index 00000000..0397c409 --- /dev/null +++ b/src/main/java/com/juick/data/entities/BaseUserPropertyEntity.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@MappedSuperclass +public class BaseUserPropertyEntity { + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private UserEntity user; + public UserEntity getUser() { + return user; + } + + public void setUser(UserEntity user) { + this.user = user; + } +} diff --git a/src/main/java/com/juick/data/entities/EmailEntity.java b/src/main/java/com/juick/data/entities/EmailEntity.java new file mode 100644 index 00000000..10c14c1e --- /dev/null +++ b/src/main/java/com/juick/data/entities/EmailEntity.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@Entity +@Table(name = "emails") +public class EmailEntity extends BaseUserPropertyEntity { + @Id + @Column(name = "email") + private String email; + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/src/main/java/com/juick/data/entities/FacebookEntity.java b/src/main/java/com/juick/data/entities/FacebookEntity.java new file mode 100644 index 00000000..6c6b4557 --- /dev/null +++ b/src/main/java/com/juick/data/entities/FacebookEntity.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@Entity +@Table(name = "facebook") +public class FacebookEntity extends BaseUserPropertyEntity { + @Id + @Column(name = "fb_id") + private Long facebookId; + + public Long getFacebookId() { + return facebookId; + } + + public void setFacebookId(Long facebookId) { + this.facebookId = facebookId; + } +} diff --git a/src/main/java/com/juick/data/entities/LoginEntity.java b/src/main/java/com/juick/data/entities/LoginEntity.java new file mode 100644 index 00000000..69737b5d --- /dev/null +++ b/src/main/java/com/juick/data/entities/LoginEntity.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@Entity +@Table(name = "logins") +public class LoginEntity extends BaseUserPropertyEntity { + @Id + @Column(name = "hash", columnDefinition = "char(16)") + private String hash; + + public String getHash() { + return hash; + } + + public void setHash(String hash) { + this.hash = hash; + } +} diff --git a/src/main/java/com/juick/data/entities/MessageEntity.java b/src/main/java/com/juick/data/entities/MessageEntity.java new file mode 100644 index 00000000..21896fb9 --- /dev/null +++ b/src/main/java/com/juick/data/entities/MessageEntity.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; +import java.io.Serializable; +import java.time.Instant; +import java.util.HashSet; +import java.util.Set; + +@Entity +@Table(name = "messages") +public class MessageEntity implements Serializable { + @Id + @Column(name = "message_id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + @ManyToMany + @JoinTable(name = "messages_tags", + joinColumns = @JoinColumn(name = "message_id"), + inverseJoinColumns = @JoinColumn(name = "tag_id") + ) + private Set<TagEntity> tags = new HashSet<>(); + + @OneToMany(mappedBy = "message") + private Set<ReplyEntity> replies = new HashSet<>(); + + @ManyToOne(cascade = CascadeType.MERGE) + private UserEntity user; + + @Column(name = "ts") + private Instant ts; + + @Column(name = "txt") + private String text; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Set<TagEntity> getTags() { + return tags; + } + + public void setTags(Set<TagEntity> tags) { + this.tags = tags; + } + + public Set<ReplyEntity> getReplies() { + return replies; + } + + public void setReplies(Set<ReplyEntity> replies) { + this.replies = replies; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public UserEntity getUser() { + return user; + } + + public void setUser(UserEntity user) { + this.user = user; + } + + public Instant getTimestamp() { + return ts; + } + + public void setTimestamp(Instant ts) { + this.ts = ts; + } +} diff --git a/src/main/java/com/juick/data/entities/ReplyEntity.java b/src/main/java/com/juick/data/entities/ReplyEntity.java new file mode 100644 index 00000000..bc0795cf --- /dev/null +++ b/src/main/java/com/juick/data/entities/ReplyEntity.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@Entity +@Table(name = "replies") +public class ReplyEntity extends BaseMessagePropertyEntity { + @Id + @Column(name = "reply_id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long replyId; + @Column(name = "txt") + private String text; + @ManyToOne(cascade = CascadeType.MERGE) + private UserEntity user; + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Long getReplyId() { + return replyId; + } + + public void setReplyId(Long replyId) { + this.replyId = replyId; + } + + public UserEntity getUser() { + return user; + } + + public void setUser(UserEntity user) { + this.user = user; + } +} diff --git a/src/main/java/com/juick/data/entities/TagEntity.java b/src/main/java/com/juick/data/entities/TagEntity.java new file mode 100644 index 00000000..e5c5266d --- /dev/null +++ b/src/main/java/com/juick/data/entities/TagEntity.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +import java.util.Set; + +@Entity +@Table(name = "tags") +public class TagEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "tag_id") + private int id; + @Column(name = "name") + private String name; + + @ManyToMany(mappedBy = "tags") + private Set<MessageEntity> messages; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Set<MessageEntity> getMessages() { + return messages; + } + + public void setMessages(Set<MessageEntity> messages) { + this.messages = messages; + } +} diff --git a/src/main/java/com/juick/data/entities/TelegramEntity.java b/src/main/java/com/juick/data/entities/TelegramEntity.java new file mode 100644 index 00000000..ccb21022 --- /dev/null +++ b/src/main/java/com/juick/data/entities/TelegramEntity.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@Entity +@Table(name = "telegram") +public class TelegramEntity extends BaseUserPropertyEntity { + @Id + @Column(name = "tg_id") + private Long identifier; + + public Long getIdentifier() { + return identifier; + } + + public void setIdentifier(Long identifier) { + this.identifier = identifier; + } +} diff --git a/src/main/java/com/juick/data/entities/UserEntity.java b/src/main/java/com/juick/data/entities/UserEntity.java new file mode 100644 index 00000000..63edadd9 --- /dev/null +++ b/src/main/java/com/juick/data/entities/UserEntity.java @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +import java.time.OffsetDateTime; +import java.util.HashSet; +import java.util.Set; + +@Entity +@Table(name = "users") +public class UserEntity { + @Id + @Column(name = "id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @Column(name = "nick") + private String name; + + @Column(name = "passw") + private String password; + + @Column(name = "banned") + private boolean banned; + @Column(name = "last_seen") + private OffsetDateTime seen; + @Column + private boolean premium; + + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user") + private Set<EmailEntity> emails = new HashSet<>(); + + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user") + private Set<FacebookEntity> facebookIds = new HashSet<>(); + + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user") + private Set<VKEntity> vkIds = new HashSet<>(); + + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user") + private Set<LoginEntity> logins = new HashSet<>(); + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user") + private Set<TelegramEntity> tgIds = new HashSet<>(); + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public Integer getId() { + return id; + } + + public void setId(Integer uid) { + this.id = uid; + } + + public boolean isBanned() { + return banned; + } + + public void setBanned(boolean banned) { + this.banned = banned; + } + + public OffsetDateTime getSeen() { + return this.seen; + } + + public void setSeen(OffsetDateTime seen) { + this.seen = seen; + } + + public Set<EmailEntity> getEmails() { + return emails; + } + + public void setEmails(Set<EmailEntity> emails) { + this.emails = emails; + } + + public Set<FacebookEntity> getFacebookIds() { + return facebookIds; + } + + public void setFacebookIds(Set<FacebookEntity> facebookIds) { + this.facebookIds = facebookIds; + } + + public Set<VKEntity> getVkIds() { + return vkIds; + } + + public void setVkIds(Set<VKEntity> vkIds) { + this.vkIds = vkIds; + } + + public Set<LoginEntity> getLogins() { + return logins; + } + + public void setLogins(Set<LoginEntity> logins) { + this.logins = logins; + } + + public Set<TelegramEntity> getTgIds() { + return tgIds; + } + + public void setTgIds(Set<TelegramEntity> tgIds) { + this.tgIds = tgIds; + } + + public boolean isPremium() { + return premium; + } + + public void setPremium(boolean premium) { + this.premium = premium; + } +} diff --git a/src/main/java/com/juick/data/entities/VKEntity.java b/src/main/java/com/juick/data/entities/VKEntity.java new file mode 100644 index 00000000..17840377 --- /dev/null +++ b/src/main/java/com/juick/data/entities/VKEntity.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@Entity +@Table(name = "vk") +public class VKEntity extends BaseUserPropertyEntity { + @Id + @Column(name = "vk_id") + private Long vkId; + + public Long getVkId() { + return vkId; + } + + public void setVkId(Long vkId) { + this.vkId = vkId; + } +} |