群聊接口
This commit is contained in:
@@ -253,6 +253,8 @@ type ChatRoom struct {
|
||||
LastMessageTime *time.Time `gorm:"type:datetime;index;comment:最后消息时间" json:"last_message_time"`
|
||||
// 最后消息内容
|
||||
LastMessage string `gorm:"type:text;comment:最后消息内容" json:"last_message"`
|
||||
// 群公告 - 仅群聊使用
|
||||
Announcement string `gorm:"type:text;comment:群公告" json:"announcement"`
|
||||
// 创建时间
|
||||
CreatedAt time.Time `gorm:"autoCreateTime;comment:创建时间" json:"created_at"`
|
||||
// 更新时间
|
||||
@@ -278,6 +280,10 @@ type RoomMember struct {
|
||||
Role int8 `gorm:"type:tinyint(1);default:0;comment:成员角色(0=成员,1=管理员,2=群主)" json:"role"`
|
||||
// 加入时间
|
||||
JoinedAt time.Time `gorm:"type:datetime;autoCreateTime;comment:加入时间" json:"joined_at"`
|
||||
// 用户信息(关联查询,不存储在数据库中)
|
||||
User *User `gorm:"foreignKey:UserID;references:ID" json:"user,omitempty"`
|
||||
// 群名片(可选,用于群聊中显示的自定义昵称)
|
||||
Nickname string `gorm:"-" json:"nickname,omitempty"`
|
||||
}
|
||||
|
||||
// TableName 指定表名和注释
|
||||
@@ -442,7 +448,12 @@ type ChatConversation struct {
|
||||
// 更新时间
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime;comment:更新时间" json:"updated_at"`
|
||||
// 目标用户信息(关联查询,不存储在数据库中)
|
||||
TargetUser *User `gorm:"foreignKey:TargetID;references:ID" json:"target_user,omitempty"`
|
||||
// 注意:不使用外键约束,因为 target_id 可能是用户ID(私聊)或群ID(群聊)
|
||||
// 使用 - 前缀禁用 GORM 的自动外键创建
|
||||
TargetUser *User `gorm:"-" json:"target_user,omitempty"`
|
||||
// 群聊信息(关联查询,仅群聊时使用,不存储在数据库中)
|
||||
// 使用 - 前缀禁用 GORM 的自动外键创建,手动加载
|
||||
Room *ChatRoom `gorm:"-" json:"room,omitempty"`
|
||||
}
|
||||
|
||||
// TableName 指定表名和注释
|
||||
|
||||
Reference in New Issue
Block a user