package model // ContactType 表示联系人类型的枚举 type ContactType string const ( ContactTypeFriend ContactType = "friend" ContactTypeGroup ContactType = "group" ) // Contact 表示微信联系人,包括好友和群组 type Contact struct { BaseModel RobotID uint `gorm:"column:robot_id;index" json:"robot_id"` WechatID string `gorm:"column:wechat_id;index:idx_contact_wechat_id,length:64" json:"wechat_id"` // 添加索引长度 Nickname string `gorm:"column:nickname" json:"nickname"` Avatar string `gorm:"column:avatar" json:"avatar"` Type ContactType `gorm:"column:type" json:"type"` Remark string `gorm:"column:remark" json:"remark"` } // TableName 指定表名 func (Contact) TableName() string { return "contacts" } // IsGroup 判断联系人是否为群组 func (c *Contact) IsGroup() bool { return c.Type == ContactTypeGroup }