feat(phase2c): 群聊与已读回执功能完整实现
Phase 2c 全部 14 个 Task 完成,包含: 后端(Go): - MinIO 文件存储服务集成(Docker + Go SDK + 通用上传 API) - Group 模块完整实现(DAO + Service + Controller + Router + Wire) - 18 个群管理 REST API + 11 个 WS 群事件推送 - 群创建/解散/邀请/踢人/退出/转让群主/设管理员/禁言/全体禁言/群公告/群昵称/免打扰/搜索 - IM Service 扩展(群消息发送/撤回 + @提醒 + 管理员无时限撤回) - 已读回执后端(单聊会话级 last_read_msg_id + 群聊消息级 im_message_reads) - 管理端群组管理(列表/详情/解散) - 数据库迁移(3 张新表 + 2 张表字段扩展) 前端(uni-app): - 群聊 Store + API 封装 + 11 个 WS 事件监听 - 已读回执 UI(单聊已读/未读标记 + 群聊 X人已读 + 已读详情页) - 7 个群聊页面(对话/创建/设置/成员/邀请/审批/搜索) - 会话列表改造(全部/单聊/群聊 Tab + @标记 + 免打扰标识) 管理端(Vue 3 + Element Plus): - 群组列表页(搜索/分页/详情弹窗/解散群聊) - 侧边栏群组管理入口 文档同步:进度/架构/设计/API/规范文档全部更新 Made-with: Cursor
This commit is contained in:
@@ -4,17 +4,24 @@ import "time"
|
||||
|
||||
// ConversationMember 会话成员模型,对应 im_conversation_members 表
|
||||
// 每个会话的每个成员一条记录,存储置顶/未读/软删除等个人视图
|
||||
// 群聊场景下额外使用 Role/Nickname/IsMuted/IsDoNotDisturb/JoinedAt/AtMeCount 字段
|
||||
type ConversationMember struct {
|
||||
ID int64 `json:"id" gorm:"primaryKey;autoIncrement"` // 记录唯一标识
|
||||
ConversationID int64 `json:"conversation_id" gorm:"not null;uniqueIndex:idx_conv_user"` // 所属会话 ID
|
||||
UserID int64 `json:"user_id" gorm:"not null;uniqueIndex:idx_conv_user"` // 成员用户 ID
|
||||
IsPinned bool `json:"is_pinned" gorm:"default:false"` // 是否置顶该会话
|
||||
IsDeleted bool `json:"is_deleted" gorm:"default:false"` // 是否删除该会话(软删除,不影响对方)
|
||||
UnreadCount int `json:"unread_count" gorm:"default:0"` // 该成员在此会话中的未读消息数
|
||||
LastReadMsgID int64 `json:"last_read_msg_id" gorm:"default:0"` // 该成员最后已读消息 ID
|
||||
ClearBeforeMsgID int64 `json:"clear_before_msg_id" gorm:"default:0"` // 清空记录时的消息截止 ID(个人视图,不影响对方)
|
||||
CreatedAt time.Time `json:"created_at" gorm:"not null;autoCreateTime;type:timestamp(0)"` // 加入会话时间
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"not null;autoUpdateTime;type:timestamp(0)"` // 最后更新时间
|
||||
ID int64 `json:"id" gorm:"primaryKey;autoIncrement"` // 记录唯一标识
|
||||
ConversationID int64 `json:"conversation_id" gorm:"not null;uniqueIndex:idx_conv_user"` // 所属会话 ID
|
||||
UserID int64 `json:"user_id" gorm:"not null;uniqueIndex:idx_conv_user"` // 成员用户 ID
|
||||
IsPinned bool `json:"is_pinned" gorm:"default:false"` // 是否置顶该会话
|
||||
IsDeleted bool `json:"is_deleted" gorm:"default:false"` // 是否删除该会话(软删除,不影响对方)
|
||||
UnreadCount int `json:"unread_count" gorm:"default:0"` // 该成员在此会话中的未读消息数
|
||||
LastReadMsgID int64 `json:"last_read_msg_id" gorm:"default:0"` // 该成员最后已读消息 ID
|
||||
ClearBeforeMsgID int64 `json:"clear_before_msg_id" gorm:"default:0"` // 清空记录时的消息截止 ID(个人视图,不影响对方)
|
||||
Role int `json:"role" gorm:"not null;default:0"` // 成员角色:0=普通成员,1=管理员,2=群主
|
||||
Nickname string `json:"nickname" gorm:"size:50;default:''"` // 群内昵称(仅群聊有效)
|
||||
IsMuted bool `json:"is_muted" gorm:"not null;default:false"` // 是否被禁言
|
||||
IsDoNotDisturb bool `json:"is_do_not_disturb" gorm:"not null;default:false"` // 是否消息免打扰
|
||||
JoinedAt *time.Time `json:"joined_at" gorm:"type:timestamp(0)"` // 加入群聊时间
|
||||
AtMeCount int `json:"at_me_count" gorm:"default:0"` // 被@提醒未读计数
|
||||
CreatedAt time.Time `json:"created_at" gorm:"not null;autoCreateTime;type:timestamp(0)"` // 加入会话时间
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"not null;autoUpdateTime;type:timestamp(0)"` // 最后更新时间
|
||||
}
|
||||
|
||||
// TableName 指定数据库表名
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/echochat/backend/pkg/utils"
|
||||
)
|
||||
|
||||
// Message 消息模型,对应 im_messages 表
|
||||
// Type: 1=文本(预留 2=图片 3=语音 4=视频 5=文件)
|
||||
// Type: 1=文本(预留 2=图片 3=语音 4=视频 5=文件),10=系统消息
|
||||
// Status: 1=正常 2=已撤回 3=已删除
|
||||
type Message struct {
|
||||
ID int64 `json:"id" gorm:"primaryKey;autoIncrement"` // 消息唯一标识,自增主键
|
||||
ConversationID int64 `json:"conversation_id" gorm:"not null;index:idx_msg_conv_time;index:idx_msg_conv_id"` // 所属会话 ID
|
||||
SenderID int64 `json:"sender_id" gorm:"not null"` // 发送者用户 ID
|
||||
Type int `json:"type" gorm:"not null;default:1"` // 消息类型:1=文本(预留扩展)
|
||||
Content string `json:"content" gorm:"type:text;not null"` // 消息内容
|
||||
Extra *string `json:"extra" gorm:"type:jsonb"` // 扩展数据(JSON 格式,预留图片/语音等元信息)
|
||||
Status int `json:"status" gorm:"not null;default:1"` // 消息状态:1=正常,2=已撤回,3=已删除
|
||||
ClientMsgID string `json:"client_msg_id" gorm:"size:64;default:''"` // 客户端消息唯一 ID,用于幂等去重
|
||||
CreatedAt time.Time `json:"created_at" gorm:"not null;autoCreateTime;type:timestamp(0)"` // 消息发送时间
|
||||
ID int64 `json:"id" gorm:"primaryKey;autoIncrement"` // 消息唯一标识,自增主键
|
||||
ConversationID int64 `json:"conversation_id" gorm:"not null;index:idx_msg_conv_time;index:idx_msg_conv_id"` // 所属会话 ID
|
||||
SenderID int64 `json:"sender_id" gorm:"not null"` // 发送者用户 ID(系统消息为 0)
|
||||
Type int `json:"type" gorm:"not null;default:1"` // 消息类型:1=文本,10=系统消息
|
||||
Content string `json:"content" gorm:"type:text;not null"` // 消息内容
|
||||
Extra *string `json:"extra" gorm:"type:jsonb"` // 扩展数据(JSON 格式,预留图片/语音等元信息)
|
||||
Status int `json:"status" gorm:"not null;default:1"` // 消息状态:1=正常,2=已撤回,3=已删除
|
||||
ClientMsgID string `json:"client_msg_id" gorm:"size:64;default:''"` // 客户端消息唯一 ID,用于幂等去重
|
||||
AtUserIDs utils.Int64Array `json:"at_user_ids" gorm:"type:bigint[]"` // @提醒用户 ID 列表,nil=无@,含 0 表示 @所有人
|
||||
CreatedAt time.Time `json:"created_at" gorm:"not null;autoCreateTime;type:timestamp(0)"` // 消息发送时间
|
||||
}
|
||||
|
||||
// TableName 指定数据库表名
|
||||
|
||||
Reference in New Issue
Block a user