69 lines
3.0 KiB
Go
69 lines
3.0 KiB
Go
package model
|
|
|
|
import (
|
|
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
|
)
|
|
|
|
// MpAutoReply 微信公众号自动回复表
|
|
type MpAutoReply struct {
|
|
global.GVA_MODEL
|
|
Type int `json:"type" gorm:"not null;index;comment:回复类型 1关注回复 2消息回复 3关键字回复"`
|
|
RequestKeyword *string `json:"requestKeyword" gorm:"type:varchar(255);index;comment:请求的关键字"`
|
|
RequestMatch *int `json:"requestMatch" gorm:"comment:请求的关键字的匹配 1完全匹配 2半匹配"`
|
|
RequestMessageType *string `json:"requestMessageType" gorm:"type:varchar(32);index;comment:请求的消息类型"`
|
|
ResponseMessageType string `json:"responseMessageType" gorm:"type:varchar(32);not null;comment:回复的消息类型"`
|
|
ResponseContent *string `json:"responseContent" gorm:"type:varchar(1024);comment:回复的消息内容"`
|
|
ResponseMediaID *string `json:"responseMediaId" gorm:"type:varchar(128);comment:回复的媒体文件 id"`
|
|
ResponseMediaURL *string `json:"responseMediaUrl" gorm:"type:varchar(1024);comment:回复的媒体文件 URL"`
|
|
ResponseTitle *string `json:"responseTitle" gorm:"type:varchar(128);comment:回复的标题"`
|
|
ResponseDescription *string `json:"responseDescription" gorm:"type:varchar(256);comment:回复的描述"`
|
|
ResponseThumbMediaID *string `json:"responseThumbMediaId" gorm:"type:varchar(128);comment:回复的缩略图的媒体 id"`
|
|
ResponseThumbMediaURL *string `json:"responseThumbMediaUrl" gorm:"type:varchar(1024);comment:回复的缩略图的媒体 URL"`
|
|
ResponseArticles *string `json:"responseArticles" gorm:"type:varchar(1024);comment:回复的图文消息数组"`
|
|
ResponseMusicURL *string `json:"responseMusicUrl" gorm:"type:varchar(1024);comment:回复的音乐链接"`
|
|
ResponseHqMusicURL *string `json:"responseHqMusicUrl" gorm:"type:varchar(1024);comment:回复的高质量音乐链接"`
|
|
}
|
|
|
|
// TableName 指定表名
|
|
func (MpAutoReply) TableName() string {
|
|
return "mp_auto_reply"
|
|
}
|
|
|
|
// AutoReplyType 自动回复类型常量
|
|
const (
|
|
AutoReplyTypeSubscribe = 1 // 关注回复
|
|
AutoReplyTypeMessage = 2 // 消息回复
|
|
AutoReplyTypeKeyword = 3 // 关键字回复
|
|
)
|
|
|
|
// MatchType 匹配类型常量
|
|
const (
|
|
MatchTypeExact = 1 // 完全匹配
|
|
MatchTypePartial = 2 // 半匹配
|
|
)
|
|
|
|
// IsSubscribeReply 是否为关注回复
|
|
func (m *MpAutoReply) IsSubscribeReply() bool {
|
|
return m.Type == AutoReplyTypeSubscribe
|
|
}
|
|
|
|
// IsMessageReply 是否为消息回复
|
|
func (m *MpAutoReply) IsMessageReply() bool {
|
|
return m.Type == AutoReplyTypeMessage
|
|
}
|
|
|
|
// IsKeywordReply 是否为关键字回复
|
|
func (m *MpAutoReply) IsKeywordReply() bool {
|
|
return m.Type == AutoReplyTypeKeyword
|
|
}
|
|
|
|
// IsExactMatch 是否为完全匹配
|
|
func (m *MpAutoReply) IsExactMatch() bool {
|
|
return m.RequestMatch != nil && *m.RequestMatch == MatchTypeExact
|
|
}
|
|
|
|
// IsPartialMatch 是否为部分匹配
|
|
func (m *MpAutoReply) IsPartialMatch() bool {
|
|
return m.RequestMatch != nil && *m.RequestMatch == MatchTypePartial
|
|
}
|