package model import ( "time" ) // ContentType 表示消息类型的枚举 type ContentType string const ( ContentTypeText ContentType = "text" ContentTypeImage ContentType = "image" ContentTypeVoice ContentType = "voice" ContentTypeVideo ContentType = "video" ContentTypeFile ContentType = "file" ContentTypeLocation ContentType = "location" ContentTypeSystem ContentType = "system" ) // Message 表示微信消息 type Message struct { BaseModel RobotID uint `gorm:"column:robot_id;index" json:"robot_id"` ContactID uint `gorm:"column:contact_id;index" json:"contact_id"` SenderID string `gorm:"column:sender_id;index:idx_sender_id,length:64" json:"sender_id"` // 添加索引长度 SenderName string `gorm:"column:sender_name" json:"sender_name"` // 发送者昵称 Content string `gorm:"column:content;type:text" json:"content"` ContentType ContentType `gorm:"column:content_type" json:"content_type"` MediaURL string `gorm:"column:media_url" json:"media_url"` // 媒体文件URL SendTime time.Time `gorm:"column:send_time;index" json:"send_time"` IsFromMe bool `gorm:"column:is_from_me" json:"is_from_me"` // 是否由机器人发送 } // TableName 指定表名 func (Message) TableName() string { return "messages" }