package test // Attachment 结构体 type Attachment struct { ID uint `gorm:"primarykey"` // 主键ID FileName string `json:"fileName" gorm:"type:varchar(127);comment:文件名"` FileUrl string `json:"FileUrl" gorm:"type:varchar(255);comment:文件地址"` Ext string `json:"ext" gorm:"type:varchar(15);comment:文件后缀名"` FileType FileType `json:"fileType" gorm:"type:varchar(31);comment:文件类型 pic:图片;thumbnail:缩略图;file:文件"` } // TableName MaterialAttachment 表名 func (Attachment) TableName() string { return "attachment" } type FileType string const ( FileType_File FileType = "file" //文件 FileType_Picture FileType = "picture" //图片 FileType_Thumbnail FileType = "thumbnail" //缩略图 )