44 lines
2.1 KiB
Go
44 lines
2.1 KiB
Go
package model
|
||
|
||
import "gorm.io/gorm"
|
||
|
||
// ChatGroupInfo 聊天群组信息结构体
|
||
// 存储群组的基本信息,如名称、头像、公告等
|
||
type ChatGroupInfo struct {
|
||
gorm.Model
|
||
ChatGroupID string `gorm:"column:chat_group_id;type:varchar(64);primary_key;comment:群唯一标识ID"` // 群组唯一ID
|
||
ChatGroupName string `gorm:"column:chat_group_name;type:varchar(128);not null;comment:群组名称"` // 群组名称
|
||
ChatGroupImageURL string `gorm:"column:chat_group_image_url;type:varchar(255);comment:群组头像图片URL地址"` // 群组头像URL
|
||
ChatGroupNotice string `gorm:"column:chat_group_notice;type:text;comment:群组公告内容"` // 群组公告
|
||
}
|
||
|
||
// TableName 指定数据库表名
|
||
func (c *ChatGroupInfo) TableName() string {
|
||
return "chat_group_info"
|
||
}
|
||
|
||
type ChatGroupRole int
|
||
|
||
const (
|
||
General ChatGroupRole = iota
|
||
Administrators
|
||
GroupLeader
|
||
)
|
||
|
||
// GroupUserRelation 群与用户关系结构体
|
||
// 记录用户与群组的关联关系及用户在群内的相关属性
|
||
type GroupUserRelation struct {
|
||
gorm.Model
|
||
ChatGroupID string `gorm:"column:chat_group_id;type:varchar(64);not null;index;comment:关联的群ID"` // 群组ID,关联ChatGroupInfo表
|
||
UserID string `gorm:"column:user_id;type:varchar(64);not null;index;comment:关联的用户ID"` // 用户ID,关联用户表
|
||
Role ChatGroupRole `gorm:"column:role;type:int;not null;default:0;comment:用户群内角色(0-普通成员,1-管理员,2-群主)"` // 用户在群内的角色
|
||
LastReadTime int64 `gorm:"column:last_read_time;type:bigint;default:0;comment:最后阅读消息时间(Unix时间戳)"` // 最后阅读时间(时间戳)
|
||
IsMuted bool `gorm:"column:is_muted;type:tinyint(1);default:false;comment:是否被禁言(true-是,false-否)"` // 是否被禁言
|
||
MuteExpireTime int64 `gorm:"column:mute_expire_time;type:bigint;default:0;comment:禁言过期时间(Unix时间戳,0表示永久)"` // 禁言过期时间
|
||
}
|
||
|
||
// TableName 指定数据库表名
|
||
func (g *GroupUserRelation) TableName() string {
|
||
return "group_user_relation"
|
||
}
|