2026-04-21 22:07:29 +08:00
|
|
|
package com.xuqm.im.entity;
|
|
|
|
|
|
2026-04-27 23:41:58 +08:00
|
|
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
2026-04-28 16:08:07 +08:00
|
|
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|
|
|
|
import com.xuqm.im.json.EpochMillisLocalDateTimeDeserializer;
|
2026-04-27 23:41:58 +08:00
|
|
|
import com.xuqm.im.json.EpochMillisLocalDateTimeSerializer;
|
2026-04-21 22:07:29 +08:00
|
|
|
import jakarta.persistence.Column;
|
|
|
|
|
import jakarta.persistence.Entity;
|
|
|
|
|
import jakarta.persistence.EnumType;
|
|
|
|
|
import jakarta.persistence.Enumerated;
|
|
|
|
|
import jakarta.persistence.Id;
|
|
|
|
|
import jakarta.persistence.Index;
|
|
|
|
|
import jakarta.persistence.Table;
|
2026-04-28 09:45:20 +08:00
|
|
|
import jakarta.persistence.Transient;
|
2026-04-21 22:07:29 +08:00
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
|
|
|
|
@Entity
|
|
|
|
|
@Table(name = "im_message", indexes = {
|
|
|
|
|
@Index(name = "idx_app_from", columnList = "appId,fromUserId"),
|
|
|
|
|
@Index(name = "idx_app_to", columnList = "appId,toId")
|
|
|
|
|
})
|
|
|
|
|
public class ImMessageEntity {
|
|
|
|
|
|
|
|
|
|
public enum ChatType { SINGLE, GROUP }
|
|
|
|
|
public enum MsgType {
|
|
|
|
|
TEXT, IMAGE, VIDEO, AUDIO, FILE, CUSTOM, LOCATION, NOTIFY,
|
2026-04-28 09:45:20 +08:00
|
|
|
RICH_TEXT, CALL_AUDIO, CALL_VIDEO, FORWARD, QUOTE, MERGE, REVOKED
|
2026-04-21 22:07:29 +08:00
|
|
|
}
|
|
|
|
|
public enum MsgStatus { SENT, DELIVERED, READ, REVOKED }
|
|
|
|
|
|
|
|
|
|
@Id
|
|
|
|
|
private String id;
|
|
|
|
|
|
|
|
|
|
@Column(nullable = false, length = 64)
|
|
|
|
|
private String appId;
|
|
|
|
|
|
|
|
|
|
@Column(nullable = false, length = 128)
|
|
|
|
|
private String fromUserId;
|
|
|
|
|
|
|
|
|
|
@Column(nullable = false, length = 128)
|
|
|
|
|
private String toId;
|
|
|
|
|
|
|
|
|
|
@Enumerated(EnumType.STRING)
|
|
|
|
|
@Column(nullable = false, length = 16)
|
|
|
|
|
private ChatType chatType;
|
|
|
|
|
|
|
|
|
|
@Enumerated(EnumType.STRING)
|
|
|
|
|
@Column(nullable = false, length = 16)
|
|
|
|
|
private MsgType msgType;
|
|
|
|
|
|
|
|
|
|
@Column(nullable = false, columnDefinition = "TEXT")
|
|
|
|
|
private String content;
|
|
|
|
|
|
|
|
|
|
@Enumerated(EnumType.STRING)
|
|
|
|
|
@Column(nullable = false, length = 16)
|
|
|
|
|
private MsgStatus status;
|
|
|
|
|
|
|
|
|
|
@Column(length = 128)
|
|
|
|
|
private String mentionedUserIds;
|
|
|
|
|
|
2026-04-28 09:45:20 +08:00
|
|
|
@Transient
|
|
|
|
|
private Integer groupReadCount;
|
|
|
|
|
|
2026-04-21 22:07:29 +08:00
|
|
|
@Column(nullable = false)
|
2026-04-27 23:41:58 +08:00
|
|
|
@JsonSerialize(using = EpochMillisLocalDateTimeSerializer.class)
|
2026-04-28 16:08:07 +08:00
|
|
|
@JsonDeserialize(using = EpochMillisLocalDateTimeDeserializer.class)
|
2026-04-21 22:07:29 +08:00
|
|
|
private LocalDateTime createdAt;
|
|
|
|
|
|
|
|
|
|
public String getId() { return id; }
|
|
|
|
|
public void setId(String id) { this.id = id; }
|
|
|
|
|
|
|
|
|
|
public String getAppId() { return appId; }
|
|
|
|
|
public void setAppId(String appId) { this.appId = appId; }
|
|
|
|
|
|
|
|
|
|
public String getFromUserId() { return fromUserId; }
|
|
|
|
|
public void setFromUserId(String fromUserId) { this.fromUserId = fromUserId; }
|
|
|
|
|
|
|
|
|
|
public String getToId() { return toId; }
|
|
|
|
|
public void setToId(String toId) { this.toId = toId; }
|
|
|
|
|
|
|
|
|
|
public ChatType getChatType() { return chatType; }
|
|
|
|
|
public void setChatType(ChatType chatType) { this.chatType = chatType; }
|
|
|
|
|
|
|
|
|
|
public MsgType getMsgType() { return msgType; }
|
|
|
|
|
public void setMsgType(MsgType msgType) { this.msgType = msgType; }
|
|
|
|
|
|
|
|
|
|
public String getContent() { return content; }
|
|
|
|
|
public void setContent(String content) { this.content = content; }
|
|
|
|
|
|
|
|
|
|
public MsgStatus getStatus() { return status; }
|
|
|
|
|
public void setStatus(MsgStatus status) { this.status = status; }
|
|
|
|
|
|
|
|
|
|
public String getMentionedUserIds() { return mentionedUserIds; }
|
|
|
|
|
public void setMentionedUserIds(String mentionedUserIds) { this.mentionedUserIds = mentionedUserIds; }
|
|
|
|
|
|
2026-04-28 09:45:20 +08:00
|
|
|
public Integer getGroupReadCount() { return groupReadCount; }
|
|
|
|
|
public void setGroupReadCount(Integer groupReadCount) { this.groupReadCount = groupReadCount; }
|
|
|
|
|
|
2026-04-27 23:41:58 +08:00
|
|
|
@JsonSerialize(using = EpochMillisLocalDateTimeSerializer.class)
|
2026-04-28 16:08:07 +08:00
|
|
|
@JsonDeserialize(using = EpochMillisLocalDateTimeDeserializer.class)
|
2026-04-21 22:07:29 +08:00
|
|
|
public LocalDateTime getCreatedAt() { return createdAt; }
|
|
|
|
|
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
|
|
|
|
|
}
|