- 实现环境配置管理,支持外部和本地主机模式切换 - 集成Demo API接口,包含登录、注册、文件上传等功能 - 构建附件处理仓库,支持图片、视频、音频和文件发送 - 开发认证仓库,管理用户会话和IM令牌刷新机制 - 添加语音录制功能,支持实时音频消息录制 - 创建依赖注入容器,统一管理应用组件实例 - 实现登录界面,提供用户认证交互功能 - 开发聊天界面,集成消息收发和媒体处理功能
104 行
3.6 KiB
Java
104 行
3.6 KiB
Java
package com.xuqm.im.entity;
|
|
|
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|
import com.xuqm.im.json.EpochMillisLocalDateTimeDeserializer;
|
|
import com.xuqm.im.json.EpochMillisLocalDateTimeSerializer;
|
|
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;
|
|
import jakarta.persistence.Transient;
|
|
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,
|
|
RICH_TEXT, CALL_AUDIO, CALL_VIDEO, FORWARD, QUOTE, MERGE, REVOKED
|
|
}
|
|
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;
|
|
|
|
@Transient
|
|
private Integer groupReadCount;
|
|
|
|
@Column(nullable = false)
|
|
@JsonSerialize(using = EpochMillisLocalDateTimeSerializer.class)
|
|
@JsonDeserialize(using = EpochMillisLocalDateTimeDeserializer.class)
|
|
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; }
|
|
|
|
public Integer getGroupReadCount() { return groupReadCount; }
|
|
public void setGroupReadCount(Integer groupReadCount) { this.groupReadCount = groupReadCount; }
|
|
|
|
@JsonSerialize(using = EpochMillisLocalDateTimeSerializer.class)
|
|
@JsonDeserialize(using = EpochMillisLocalDateTimeDeserializer.class)
|
|
public LocalDateTime getCreatedAt() { return createdAt; }
|
|
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
|
|
}
|