27 lines
1.4 KiB
Go
27 lines
1.4 KiB
Go
|
|
package model
|
|||
|
|
|
|||
|
|
import "time"
|
|||
|
|
|
|||
|
|
// UploadedFile 聊天/通用文件上传记录
|
|||
|
|
// 用于跟踪 files/ 前缀下的 S3 对象,配合 FileCleanupWorker 实现 TTL 过期清理。
|
|||
|
|
// 注意:images/avatars/covers 等内容寻址资源不记录本表,不会被自动清理。
|
|||
|
|
type UploadedFile struct {
|
|||
|
|
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
|||
|
|
URL string `gorm:"size:512;index;not null" json:"url"` // 完整访问 URL,DTO 标记失效用
|
|||
|
|
ObjectName string `gorm:"size:256;index;not null" json:"object_name"` // S3 对象名 files/{folder}/{hash}{ext}
|
|||
|
|
Name string `gorm:"size:255" json:"name"` // 原始文件名
|
|||
|
|
Size int64 `json:"size"` // 字节数
|
|||
|
|
MimeType string `gorm:"size:128" json:"mime_type"`
|
|||
|
|
Folder string `gorm:"size:32;index" json:"folder"` // chat / post 等来源
|
|||
|
|
UploaderID string `gorm:"size:50;index" json:"uploader_id"` // 上传者 UUID
|
|||
|
|
Expired bool `gorm:"index;default:false" json:"expired"` // 是否已从 S3 清理
|
|||
|
|
ExpiredAt *time.Time `json:"expired_at,omitempty"` // 清理时间
|
|||
|
|
CreatedAt time.Time `gorm:"index" json:"created_at"` // 上传时间,TTL 计算基准
|
|||
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// TableName 表名
|
|||
|
|
func (UploadedFile) TableName() string {
|
|||
|
|
return "uploaded_files"
|
|||
|
|
}
|