This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
)
|
||||
|
||||
// MpMaterial 微信公众号素材表
|
||||
type MpMaterial struct {
|
||||
global.GVA_MODEL
|
||||
MediaID string `json:"mediaId" gorm:"type:varchar(128);not null;index;comment:公众号素材 id"`
|
||||
Type string `json:"type" gorm:"type:varchar(32);not null;index;comment:文件类型 image图片 voice语音 video视频 thumb缩略图"`
|
||||
Permanent bool `json:"permanent" gorm:"not null;default:false;index;comment:是否永久素材"`
|
||||
URL *string `json:"url" gorm:"type:varchar(1024);comment:文件服务器的 URL"`
|
||||
Name *string `json:"name" gorm:"type:varchar(255);comment:素材名字"`
|
||||
MpURL *string `json:"mpUrl" gorm:"type:varchar(1024);comment:公众号文件 URL"`
|
||||
Title *string `json:"title" gorm:"type:varchar(255);comment:视频素材的标题"`
|
||||
Introduction *string `json:"introduction" gorm:"type:varchar(255);comment:视频素材的描述"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
func (MpMaterial) TableName() string {
|
||||
return "mp_material"
|
||||
}
|
||||
|
||||
// MaterialType 素材类型常量
|
||||
const (
|
||||
MaterialTypeImage = "image" // 图片
|
||||
MaterialTypeVoice = "voice" // 语音
|
||||
MaterialTypeVideo = "video" // 视频
|
||||
MaterialTypeThumb = "thumb" // 缩略图
|
||||
MaterialTypeNews = "news" // 图文消息
|
||||
)
|
||||
|
||||
// IsImage 是否为图片素材
|
||||
func (m *MpMaterial) IsImage() bool {
|
||||
return m.Type == MaterialTypeImage
|
||||
}
|
||||
|
||||
// IsVoice 是否为语音素材
|
||||
func (m *MpMaterial) IsVoice() bool {
|
||||
return m.Type == MaterialTypeVoice
|
||||
}
|
||||
|
||||
// IsVideo 是否为视频素材
|
||||
func (m *MpMaterial) IsVideo() bool {
|
||||
return m.Type == MaterialTypeVideo
|
||||
}
|
||||
|
||||
// IsThumb 是否为缩略图素材
|
||||
func (m *MpMaterial) IsThumb() bool {
|
||||
return m.Type == MaterialTypeThumb
|
||||
}
|
||||
|
||||
// IsNews 是否为图文消息素材
|
||||
func (m *MpMaterial) IsNews() bool {
|
||||
return m.Type == MaterialTypeNews
|
||||
}
|
||||
|
||||
// IsPermanent 是否为永久素材
|
||||
func (m *MpMaterial) IsPermanent() bool {
|
||||
return m.Permanent
|
||||
}
|
||||
|
||||
// IsTemporary 是否为临时素材
|
||||
func (m *MpMaterial) IsTemporary() bool {
|
||||
return !m.Permanent
|
||||
}
|
||||
Reference in New Issue
Block a user