Add models based on Db tables
This commit is contained in:
Generated
+1
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class ConnectionDb {
|
||||
private static final String JDBC_URL = "jdbc:postgresql://localhost:5432/Telegramdb";
|
||||
private static final String JDBC_URL = "jdbc:postgresql://localhost:5432/Telegram";
|
||||
private static final String USERNAME = "postgres";
|
||||
private static final String PASSWORD = "Partow@1384";
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.to.telegramfinalproject.Models;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Channel {
|
||||
private UUID internal_uuid;
|
||||
private String channel_id;
|
||||
private String channel_name;
|
||||
private UUID creator_id;
|
||||
private String image_url;
|
||||
private String description;
|
||||
private LocalDateTime created_at;
|
||||
private List<ChannelSubscribe> members;
|
||||
|
||||
public Channel(UUID internal_uuid, String channel_name, UUID creator_id, LocalDateTime created_at){
|
||||
this.internal_uuid = internal_uuid;
|
||||
this.channel_name = channel_name;
|
||||
this.creator_id = creator_id;
|
||||
this.created_at = created_at;
|
||||
}
|
||||
|
||||
public void setChannel_id(String Channel_id){this.channel_id = Channel_id;}
|
||||
public void setCreator_id(UUID creator_id){this.creator_id = creator_id;}
|
||||
public void setChannel_name(String channel_name){this.channel_name = channel_name;}
|
||||
public void setImage_url(String image_url){this.image_url = image_url;}
|
||||
public void setCreated_at(LocalDateTime created_at){this.created_at = created_at;}
|
||||
public void setDescription(String description){this.description =description;}
|
||||
public void setMembers(List<ChannelSubscribe> members){this.members = members;}
|
||||
|
||||
public String getChannel_id(){return this.channel_id;}
|
||||
public UUID getCreator_id(){return this.creator_id;}
|
||||
public String getChannel_name(){return this.channel_name;}
|
||||
public String getImage_url(){return this.image_url;}
|
||||
public LocalDateTime getCreated_at(){return this.created_at;}
|
||||
public String getDescription(){return this.description;}
|
||||
public List<ChannelSubscribe> getMembers(){return this.members;}
|
||||
public UUID getInternal_uuid() {
|
||||
return this.internal_uuid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.to.telegramfinalproject.Models;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChannelSubscribe {
|
||||
private UUID channel_id;
|
||||
private UUID user_id;
|
||||
private LocalDateTime join_at;
|
||||
|
||||
|
||||
public ChannelSubscribe(UUID channel_id, UUID user_id, String role){
|
||||
this.channel_id = channel_id;
|
||||
this.user_id = user_id;
|
||||
this.join_at = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public void setChannel_id(UUID group_id){this.channel_id = group_id;}
|
||||
public void setUser_id(UUID user_id){this.user_id = user_id;}
|
||||
public void setJoin_at(LocalDateTime join_at){this.join_at = join_at;}
|
||||
|
||||
|
||||
|
||||
public UUID getChannel_id(){return this.channel_id;}
|
||||
public UUID getUser_id(){return this.user_id;}
|
||||
public LocalDateTime getJoin_at(){return this.join_at;}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.to.telegramfinalproject.Models;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Contact {
|
||||
private UUID user_id;
|
||||
private UUID contact_id;
|
||||
private LocalDateTime add_at;
|
||||
private Boolean is_blocked;
|
||||
|
||||
public Contact(UUID user_id, UUID contact_id){
|
||||
this.user_id = user_id;
|
||||
this.contact_id = contact_id;
|
||||
this.add_at = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public void setUser_id(UUID user_id){this.user_id = user_id;}
|
||||
public void setContact_id(UUID contact_id){this.contact_id = contact_id;}
|
||||
public void setAdd_at(LocalDateTime add_at){this.add_at =add_at;}
|
||||
public void setIs_blocked(Boolean is_blocked){this.is_blocked =is_blocked;}
|
||||
|
||||
public UUID getUser_id(){
|
||||
return this.user_id;
|
||||
}
|
||||
|
||||
public UUID getContact_id(){return this.contact_id;}
|
||||
|
||||
public LocalDateTime getAdd_at() {
|
||||
return add_at;
|
||||
}
|
||||
public Boolean getIs_blocked(){
|
||||
return is_blocked;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.to.telegramfinalproject.Models;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Group {
|
||||
private UUID internal_uuid;
|
||||
private String group_id;
|
||||
private String group_name;
|
||||
private UUID creator_id;
|
||||
private String image_url;
|
||||
private String description;
|
||||
private LocalDateTime created_at;
|
||||
private List<GroupMember> members;
|
||||
|
||||
public Group(UUID internal_uuid, String group_name, UUID creator_id, LocalDateTime created_at){
|
||||
this.internal_uuid = internal_uuid;
|
||||
this.group_name = group_name;
|
||||
this.creator_id = creator_id;
|
||||
this.created_at = created_at;
|
||||
}
|
||||
|
||||
public void setGroup_id(String group_id){this.group_id = group_id;}
|
||||
public void setCreator_id(UUID creator_id){this.creator_id = creator_id;}
|
||||
public void setGroup_name(String group_name){this.group_name = group_name;}
|
||||
public void setImage_url(String image_url){this.image_url = image_url;}
|
||||
public void setCreated_at(LocalDateTime created_at){this.created_at = created_at;}
|
||||
public void setDescription(String description){this.description =description;}
|
||||
public void setMembers(List<GroupMember> members){this.members = members;}
|
||||
|
||||
public String getGroup_id(){return this.group_id;}
|
||||
public UUID getCreator_id(){return this.creator_id;}
|
||||
public String getGroup_name(){return this.group_name;}
|
||||
public String getImage_url(){return this.image_url;}
|
||||
public LocalDateTime getCreated_at(){return this.created_at;}
|
||||
public String getDescription(){return this.description;}
|
||||
public List<GroupMember> getMembers(){return this.members;}
|
||||
public UUID getInternal_uuid() {
|
||||
return this.internal_uuid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.to.telegramfinalproject.Models;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GroupMember {
|
||||
private UUID group_id;
|
||||
private UUID user_id;
|
||||
private LocalDateTime join_at;
|
||||
private String role;
|
||||
|
||||
public GroupMember(UUID group_id, UUID user_id, String role){
|
||||
this.group_id = group_id;
|
||||
this.user_id = user_id;
|
||||
this.join_at = LocalDateTime.now();
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public void setGroup_id(UUID group_id){this.group_id = group_id;}
|
||||
public void setUser_id(UUID user_id){this.user_id = user_id;}
|
||||
public void setJoin_at(LocalDateTime join_at){this.join_at = join_at;}
|
||||
public void setRole(String role){this.role = role;}
|
||||
|
||||
|
||||
|
||||
public UUID getGroup_id(){return this.group_id;}
|
||||
public UUID getUser_id(){return this.user_id;}
|
||||
public LocalDateTime getJoin_at(){return this.join_at;}
|
||||
public String getRole(){return this.role;}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package org.to.telegramfinalproject.Models;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Message {
|
||||
private UUID message_id;
|
||||
private UUID sender_id;
|
||||
private String receiver_type; // private, group, channel
|
||||
private UUID receiver_id;
|
||||
private String content;
|
||||
private String message_type; // TEXT, IMAGE, FILE, ...
|
||||
private String file_url;
|
||||
private LocalDateTime send_at;
|
||||
private String status; // SENT, DELIVERED, READ
|
||||
private UUID reply_to_id;
|
||||
private boolean is_edited;
|
||||
private UUID original_message_id;
|
||||
private UUID forwarded_by;
|
||||
private UUID forwarded_from;
|
||||
|
||||
public Message(UUID message_id, UUID sender_id, String receiver_type, UUID receiver_id, String content,
|
||||
String message_type, String file_url, LocalDateTime send_at, String status,
|
||||
UUID reply_to_id, boolean is_edited, UUID original_message_id,
|
||||
UUID forwarded_by, UUID forwarded_from) {
|
||||
this.message_id = message_id;
|
||||
this.sender_id = sender_id;
|
||||
this.receiver_type = receiver_type;
|
||||
this.receiver_id = receiver_id;
|
||||
this.content = content;
|
||||
this.message_type = message_type;
|
||||
this.file_url = file_url;
|
||||
this.send_at = send_at;
|
||||
this.status = status;
|
||||
this.reply_to_id = reply_to_id;
|
||||
this.is_edited = is_edited;
|
||||
this.original_message_id = original_message_id;
|
||||
this.forwarded_by = forwarded_by;
|
||||
this.forwarded_from = forwarded_from;
|
||||
}
|
||||
|
||||
|
||||
public UUID getMessage_id() {
|
||||
return message_id;
|
||||
}
|
||||
|
||||
|
||||
public UUID getSender_id() {
|
||||
return sender_id;
|
||||
}
|
||||
|
||||
public void setSender_id(UUID sender_id) {
|
||||
this.sender_id = sender_id;
|
||||
}
|
||||
|
||||
public String getReceiver_type() {
|
||||
return receiver_type;
|
||||
}
|
||||
|
||||
public void setReceiver_type(String receiver_type) {
|
||||
this.receiver_type = receiver_type;
|
||||
}
|
||||
|
||||
public UUID getReceiver_id() {
|
||||
return receiver_id;
|
||||
}
|
||||
|
||||
public void setReceiver_id(UUID receiver_id) {
|
||||
this.receiver_id = receiver_id;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getMessage_type() {
|
||||
return message_type;
|
||||
}
|
||||
|
||||
public void setMessage_type(String message_type) {
|
||||
this.message_type = message_type;
|
||||
}
|
||||
|
||||
public String getFile_url() {
|
||||
return file_url;
|
||||
}
|
||||
|
||||
public void setFile_url(String file_url) {
|
||||
this.file_url = file_url;
|
||||
}
|
||||
|
||||
public LocalDateTime getSend_at() {
|
||||
return send_at;
|
||||
}
|
||||
|
||||
public void setSend_at(LocalDateTime send_at) {
|
||||
this.send_at = send_at;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public UUID getReply_to_id() {
|
||||
return reply_to_id;
|
||||
}
|
||||
|
||||
public void setReply_to_id(UUID reply_to_id) {
|
||||
this.reply_to_id = reply_to_id;
|
||||
}
|
||||
|
||||
public boolean isIs_edited() {
|
||||
return is_edited;
|
||||
}
|
||||
|
||||
public void setIs_edited(boolean is_edited) {
|
||||
this.is_edited = is_edited;
|
||||
}
|
||||
|
||||
public UUID getOriginal_message_id() {
|
||||
return original_message_id;
|
||||
}
|
||||
|
||||
public void setOriginal_message_id(UUID original_message_id) {
|
||||
this.original_message_id = original_message_id;
|
||||
}
|
||||
|
||||
public UUID getForwarded_by() {
|
||||
return forwarded_by;
|
||||
}
|
||||
|
||||
public void setForwarded_by(UUID forwarded_by) {
|
||||
this.forwarded_by = forwarded_by;
|
||||
}
|
||||
|
||||
public UUID getForwarded_from() {
|
||||
return forwarded_from;
|
||||
}
|
||||
|
||||
public void setForwarded_from(UUID forwarded_from) {
|
||||
this.forwarded_from = forwarded_from;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.to.telegramfinalproject.Models;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PrivateChat {
|
||||
private UUID chat_id;
|
||||
private UUID user1_id;
|
||||
private UUID user2_id;
|
||||
private LocalDateTime created_at;
|
||||
|
||||
public PrivateChat(UUID chat_id, UUID user1_id, UUID user2_id, LocalDateTime created_at){
|
||||
this.chat_id = chat_id;
|
||||
this.user1_id =user1_id;
|
||||
this.user2_id =user2_id;
|
||||
this.created_at =created_at;
|
||||
}
|
||||
|
||||
public void setUser1_id(UUID user1_id){this.user1_id =user1_id;}
|
||||
public void setUser2_id(UUID user2_id){this.user2_id =user2_id;}
|
||||
public void setCreated_at(LocalDateTime created_at){this.created_at = created_at;}
|
||||
|
||||
public UUID getUser1_id(){return this.user1_id;}
|
||||
public UUID getChat_id(){return this.chat_id;}
|
||||
public UUID getUser2_id(){return this.user2_id;}
|
||||
public LocalDateTime getCreated_at(){return this.created_at;}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.to.telegramfinalproject.Models;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class User {
|
||||
@@ -13,6 +14,9 @@ public class User {
|
||||
private String image_url;
|
||||
private String status;
|
||||
private LocalDateTime last_seen;
|
||||
private List<Contact> contactList;
|
||||
private List<Group> groupList;
|
||||
private List<Channel> channelList;
|
||||
|
||||
public User(String user_id, UUID internal_uuid, String username, String password, String profile_name) {
|
||||
this.user_id = user_id;
|
||||
@@ -54,6 +58,12 @@ public class User {
|
||||
this.last_seen = last_seen;
|
||||
}
|
||||
|
||||
public void setContactList(List<Contact> contactList){this.contactList = contactList;}
|
||||
|
||||
public void setChannelList(List<Channel> channelList){this.channelList = channelList;}
|
||||
|
||||
public void setGroupList(List<Group> groupList){this.groupList = groupList;}
|
||||
|
||||
public UUID getInternal_uuid() {
|
||||
return this.internal_uuid;
|
||||
}
|
||||
@@ -89,5 +99,11 @@ public class User {
|
||||
public LocalDateTime getLast_seen() {
|
||||
return this.last_seen;
|
||||
}
|
||||
|
||||
public List<Contact> getContactList(){return this.contactList;}
|
||||
|
||||
public List<Channel> getChannelList(){return this.channelList;}
|
||||
|
||||
public List<Group> getGroupList(){return this.groupList;}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user