部分联系人和会话接口

This commit is contained in:
2025-12-04 08:51:40 +08:00
parent f61d567c2a
commit 10a90b262d
6 changed files with 451 additions and 12 deletions

View File

@@ -183,6 +183,10 @@ type UserContact struct {
IsTop bool `gorm:"type:tinyint(1);default:0;comment:是否置顶" json:"is_top"`
// 是否免打扰
IsMuted bool `gorm:"type:tinyint(1);default:0;comment:是否免打扰" json:"is_muted"`
// 是否特别关心(高优先级提醒,类似 QQ 特别关心)
IsSpecialCare bool `gorm:"type:tinyint(1);default:0;comment:是否特别关心" json:"is_special_care"`
// 是否拉黑(加入黑名单,不再接收消息/出现在默认列表中)
IsBlocked bool `gorm:"type:tinyint(1);default:0;comment:是否拉黑" json:"is_blocked"`
// 最后聊天时间
LastChatTime *time.Time `gorm:"type:datetime;comment:最后聊天时间" json:"last_chat_time"`
// 最后一条消息
@@ -380,6 +384,45 @@ func (ApiRequestLog) TableName() string {
return "api_request_logs"
}
/**
* ChatConversation
* 对应数据库表:chat_conversations
* 作用:用户级别的最近会话列表,支持置顶、免打扰和未读计数等功能
*/
type ChatConversation struct {
// 主键ID
ID uint `gorm:"primaryKey;comment:主键ID" json:"id"`
// 所属用户ID(当前登录用户)
UserID string `gorm:"type:varchar(100);index;comment:用户ID" json:"user_id"`
// 目标ID:好友ID或群ID
TargetID string `gorm:"type:varchar(100);index;comment:目标ID(好友或群)" json:"target_id"`
// 房间ID:与 chat_messages / chat_rooms 中的 room_id 一致
RoomID string `gorm:"type:varchar(100);index;comment:房间ID" json:"room_id"`
// 会话类型:1-私聊 2-群聊
Type int `gorm:"type:int;comment:会话类型(1=私聊,2=群聊)" json:"type"`
// 是否置顶
IsTop bool `gorm:"type:tinyint(1);default:0;comment:是否置顶" json:"is_top"`
// 是否免打扰
IsMuted bool `gorm:"type:tinyint(1);default:0;comment:是否免打扰" json:"is_muted"`
// 是否特别关心(用于在前端高亮显示)
IsSpecialCare bool `gorm:"type:tinyint(1);default:0;comment:是否特别关心" json:"is_special_care"`
// 未读消息数
UnreadCount int `gorm:"type:int;default:0;comment:未读消息数" json:"unread_count"`
// 最后一条消息内容(用于列表摘要)
LastMessage string `gorm:"type:varchar(500);comment:最后一条消息内容" json:"last_message"`
// 最后消息时间
LastTime time.Time `gorm:"type:datetime;index;comment:最后消息时间" json:"last_time"`
// 创建时间
CreatedAt time.Time `gorm:"autoCreateTime;comment:创建时间" json:"created_at"`
// 更新时间
UpdatedAt time.Time `gorm:"autoUpdateTime;comment:更新时间" json:"updated_at"`
}
// TableName 指定表名和注释
func (ChatConversation) TableName() string {
return "chat_conversations"
}
/**
* LoginLog
* 对应数据库表:login_logs