refactor: 移除内存存储,全部改为数据库持久化
- 新建 Asset 模型并添加自动迁移 - 移除 taskStore 内存中的任务缓存 - 新任务直接写入数据库 Task 表 - 任务状态更新同步写入数据库 - 素材上传结果保存到 Asset 表 - GetTask/GetAssets 从数据库查询 - 添加 Metadata 字段到 Task 模型存储完整元数据
This commit is contained in:
@@ -5,7 +5,7 @@ import "time"
|
||||
// Task 任务数据模型,对应数据库表。
|
||||
type Task struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
ExternalID string `gorm:"size:100;index" json:"externalId,omitempty"` // 外部任务ID,关联内存中的taskID
|
||||
ExternalID string `gorm:"size:100;index" json:"externalId,omitempty"` // 外部任务ID,关联taskID
|
||||
ProjectID uint `gorm:"index" json:"-"`
|
||||
Prompt string `gorm:"type:text" json:"prompt"`
|
||||
AssetType string `gorm:"size:50" json:"assetType"`
|
||||
@@ -14,6 +14,7 @@ type Task struct {
|
||||
Progress int `gorm:"default:0" json:"progress"`
|
||||
RetryCount int `gorm:"default:0" json:"retryCount"`
|
||||
Error string `gorm:"type:text" json:"error,omitempty"`
|
||||
Metadata string `gorm:"type:text" json:"-"` // 元数据(JSON格式)
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user