refactor: 移除内存存储,全部改为数据库持久化
- 新建 Asset 模型并添加自动迁移 - 移除 taskStore 内存中的任务缓存 - 新任务直接写入数据库 Task 表 - 任务状态更新同步写入数据库 - 素材上传结果保存到 Asset 表 - GetTask/GetAssets 从数据库查询 - 添加 Metadata 字段到 Task 模型存储完整元数据
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// Asset 素材数据模型,对应数据库表。
|
||||
type Asset struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
TaskID uint `gorm:"index;not null"`
|
||||
Key string `gorm:"size:255;not null"` // 七牛云对象键
|
||||
URL string `gorm:"size:255;not null"` // CDN访问URL
|
||||
Format string `gorm:"size:20;not null"` // 文件格式
|
||||
Metadata string `gorm:"type:text"` // 元数据(JSON格式)
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
// AssetResponse 素材响应。
|
||||
type AssetResponse struct {
|
||||
Key string `json:"key"`
|
||||
URL string `json:"url"`
|
||||
Format string `json:"format"`
|
||||
}
|
||||
Reference in New Issue
Block a user