2025-04-09 16:15:16 +08:00

40 lines
1.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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:deleted,unique" json:"robot_id"`
WechatID string `gorm:"column:wechat_id;index:deleted,unique" json:"wechat_id"` // 添加索引长度
Alias string `gorm:"column:alias" json:"alias"` // 微信号
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"`
Pyinitial string `gorm:"column:pyinitial" json:"pyinitial"` // 昵称拼音首字母大写
QuanPin string `gorm:"column:quan_pin" json:"quan_pin"` // 昵称拼音全拼小写
Sex int `gorm:"column:sex" json:"sex"` // 性别 0未知 1男 2
Country string `gorm:"column:country" json:"country"` // 国家
Province string `gorm:"column:province" json:"province"` // 省份
City string `gorm:"column:city" json:"city"` // 城市
Signature string `gorm:"column:signature" json:"signature"` // 个性签名
SnsBackground string `gorm:"column:sns_background" json:"sns_background"` // 朋友圈背景图
}
// TableName 指定表名
func (Contact) TableName() string {
return "contacts"
}
// IsGroup 判断联系人是否为群组
func (c *Contact) IsGroup() bool {
return c.Type == ContactTypeGroup
}