package model import ( "github.com/flipped-aurora/gin-vue-admin/server/global" ) // MpMessage 微信公众号消息表 type MpMessage struct { global.GVA_MODEL Type string `json:"type" gorm:"type:varchar(32);not null;index;comment:消息类型"` OpenID string `json:"openid" gorm:"type:varchar(100);not null;index;comment:用户openid"` InMsgID *string `json:"inMsgId" gorm:"type:varchar(64);comment:微信消息id"` Content *string `json:"content" gorm:"type:text;comment:消息内容"` } // TableName 指定表名 func (MpMessage) TableName() string { return "mp_message" } // MessageType 消息类型常量 const ( MessageTypeText = "text" // 文本消息 MessageTypeImage = "image" // 图片消息 MessageTypeVoice = "voice" // 语音消息 MessageTypeVideo = "video" // 视频消息 MessageTypeMusic = "music" // 音乐消息 MessageTypeNews = "news" // 图文消息 MessageTypeLocation = "location" // 地理位置消息 MessageTypeLink = "link" // 链接消息 MessageTypeEvent = "event" // 事件消息 ) // IsTextMessage 是否为文本消息 func (m *MpMessage) IsTextMessage() bool { return m.Type == MessageTypeText } // IsEventMessage 是否为事件消息 func (m *MpMessage) IsEventMessage() bool { return m.Type == MessageTypeEvent }