-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/chat/Attachment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.lcaohoanq.shoppe.domain.chat; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.lcaohoanq.shoppe.base.entity.BaseEntity; | ||
import com.lcaohoanq.shoppe.metadata.MediaMeta; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embedded; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.SequenceGenerator; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@Table(name = "attachments") | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class Attachment { | ||
|
||
@Id | ||
@SequenceGenerator(name = "attachments_seq", sequenceName = "attachments_id_seq", allocationSize = 1) | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "attachments_seq") | ||
@Column(name="id", unique=true, nullable=false) | ||
@JsonProperty("id") | ||
private Long id; | ||
|
||
@Embedded | ||
private MediaMeta mediaMeta; | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/chat/ChatRoom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.lcaohoanq.shoppe.domain.chat; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.lcaohoanq.shoppe.base.entity.BaseEntity; | ||
import com.lcaohoanq.shoppe.domain.user.User; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.SequenceGenerator; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@Table(name = "chat_rooms") | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class ChatRoom extends BaseEntity { | ||
|
||
@Id | ||
@SequenceGenerator(name = "chat_rooms_seq", sequenceName = "chat_rooms_id_seq", allocationSize = 1) | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "chat_rooms_seq") | ||
@Column(name = "id", unique = true, nullable = false) | ||
@JsonProperty("id") | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "user_1_id", nullable = false) | ||
private User user1; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "user_2_id", nullable = false) | ||
private User user2; | ||
|
||
@Column(name = "user1_typing_status") | ||
private Boolean user1TypingStatus = false; | ||
|
||
@Column(name = "user2_typing_status") | ||
private Boolean user2TypingStatus = false; | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/chat/Message.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.lcaohoanq.shoppe.domain.chat; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.lcaohoanq.shoppe.base.entity.BaseEntity; | ||
import com.lcaohoanq.shoppe.domain.user.User; | ||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.OneToOne; | ||
import jakarta.persistence.SequenceGenerator; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@Table(name = "messages") | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class Message extends BaseEntity { | ||
|
||
@Id | ||
@SequenceGenerator(name = "messages_seq", sequenceName = "messages_id_seq", allocationSize = 1) | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "messages_seq") | ||
@Column(name="id", unique=true, nullable=false) | ||
@JsonProperty("id") | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "chat_room_id", nullable = false) | ||
private ChatRoom chatRoom; | ||
|
||
@OneToOne(cascade = CascadeType.ALL) // If a message has one attachment | ||
@JoinColumn(name = "attachment_id") | ||
private Attachment attachment; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "user_id", nullable = false) | ||
private User user; | ||
|
||
@Column(name = "content", nullable = false) | ||
private String content; // Store the message text | ||
|
||
@Column(name="is_read", nullable = false) | ||
private Boolean isRead = false; | ||
|
||
// Timestamps from BaseEntity are inherited | ||
} | ||
|